aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinmarket <inmarket@ugfx.org>2018-06-23 03:01:37 +0200
committerGogs <gogs@fake.local>2018-06-23 03:01:37 +0200
commit3b97fb798e96514057bcf17263c1e5dbdcd7da26 (patch)
tree5a52cd87dc5f1736448a5d8006c00acee9d325db
parentb9b7d27c5785da70adc60cd7aec7d2a5deb5cb09 (diff)
parentc119ca4a5dd8df57d39a57a530cc5b01adf699e8 (diff)
downloaduGFX-3b97fb798e96514057bcf17263c1e5dbdcd7da26.tar.gz
uGFX-3b97fb798e96514057bcf17263c1e5dbdcd7da26.tar.bz2
uGFX-3b97fb798e96514057bcf17263c1e5dbdcd7da26.zip
Merge branch 'master' of Steffen/uGFX into master
-rw-r--r--src/gwin/gwin_class.h17
-rw-r--r--src/gwin/gwin_radio.c30
-rw-r--r--src/gwin/gwin_widget.c13
3 files changed, 59 insertions, 1 deletions
diff --git a/src/gwin/gwin_class.h b/src/gwin/gwin_class.h
index ea5c260c..4b173e3c 100644
--- a/src/gwin/gwin_class.h
+++ b/src/gwin/gwin_class.h
@@ -359,9 +359,26 @@ bool_t _gwinWMAdd(GHandle gh, const GWindowInit *pInit);
*/
void _gwidgetDrawFocusRect(GWidgetObject *gw, coord_t x, coord_t y, coord_t cx, coord_t cy);
+ /**
+ * @brief Draw a simple focus circle in the default style.
+ *
+ * @param[in] gw The widget
+ * @param[in] radius The radius of the circle
+ *
+ * @note Assumes the widget is in a state where it can draw.
+ * @note Nothing is drawn if the window doesn't have focus.
+ * @note The focus circle may be more than one pixel thick.
+ *
+ * @notapi
+ */
+ #if GDISP_NEED_CIRCLE
+ void _gwidgetDrawFocusCircle(GWidgetObject *gx, coord_t radius);
+ #endif
+
#else
#define _gwinFixFocus(gh)
#define _gwidgetDrawFocusRect(gh,x,y,cx,cy)
+ #define _gwidgetDrawFocusCircle(gh,radius)
#endif
#if GWIN_NEED_FLASHING || defined(__DOXYGEN__)
diff --git a/src/gwin/gwin_radio.c b/src/gwin/gwin_radio.c
index 47110c35..8e0b4e64 100644
--- a/src/gwin/gwin_radio.c
+++ b/src/gwin/gwin_radio.c
@@ -53,6 +53,20 @@ static void SendRadioEvent(GWidgetObject *gw) {
}
#endif
+#if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD
+ static void RadioKeyboard(GWidgetObject* gw, GEventKeyboard* pke)
+ {
+ // Only react on KEYDOWN events. Ignore KEYUP events.
+ if ((pke->keystate & GKEYSTATE_KEYUP))
+ return;
+
+ // ENTER and SPACE keys to check/uncheck the checkbox
+ if (pke->c[0] == GKEY_ENTER || pke->c[0] == GKEY_SPACE) {
+ gwinRadioPress((GHandle)gw);
+ }
+ }
+#endif
+
#if GINPUT_NEED_TOGGLE
// A toggle on has occurred
static void RadioToggleOn(GWidgetObject *gw, uint16_t role) {
@@ -91,7 +105,7 @@ static const gwidgetVMT radioVMT = {
#endif
#if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD
{
- 0 // Process keyboard events
+ RadioKeyboard // Process keyboard events
},
#endif
#if GINPUT_NEED_TOGGLE
@@ -194,6 +208,8 @@ void gwinRadioDraw_Radio(GWidgetObject *gw, void *param) {
gdispGFillArea(gw->g.display, gw->g.x+df, gw->g.y+df, ld-2*df, ld-2*df, pcol->fill);
#endif
+ _gwidgetDrawFocusCircle(gw, df);
+
gdispGFillStringBox(gw->g.display, gw->g.x+ld+1, gw->g.y, gw->g.width-ld-1, gw->g.height, gw->text, gw->g.font, pcol->text, gw->pstyle->background, justifyLeft);
#undef gcw
}
@@ -214,6 +230,9 @@ void gwinRadioDraw_Radio(GWidgetObject *gw, void *param) {
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
+
+ // Render highlighted border if focused
+ _gwidgetDrawFocusRect(gw, 1, 1, gw->g.width-2, gw->g.height-2);
}
void gwinRadioDraw_Tab(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
@@ -235,6 +254,9 @@ void gwinRadioDraw_Radio(GWidgetObject *gw, void *param) {
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
}
+
+ // Render highlighted border if focused
+ _gwidgetDrawFocusRect(gw, 0, 0, gw->g.width-1, gw->g.height-1);
}
#else
void gwinRadioDraw_Button(GWidgetObject *gw, void *param) {
@@ -258,6 +280,9 @@ void gwinRadioDraw_Radio(GWidgetObject *gw, void *param) {
gdispGDrawStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, justifyCenter);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
+
+ // Render highlighted border if focused
+ _gwidgetDrawFocusRect(gw, 0, 0, gw->g.width-1, gw->g.height-1);
}
void gwinRadioDraw_Tab(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
@@ -286,6 +311,9 @@ void gwinRadioDraw_Radio(GWidgetObject *gw, void *param) {
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
}
+
+ // Render highlighted border if focused
+ _gwidgetDrawFocusRect(gw, 0, 0, gw->g.width-1, gw->g.height-1);
}
#endif
diff --git a/src/gwin/gwin_widget.c b/src/gwin/gwin_widget.c
index 34b047eb..38b4e236 100644
--- a/src/gwin/gwin_widget.c
+++ b/src/gwin/gwin_widget.c
@@ -330,6 +330,19 @@ static void gwidgetEvent(void *param, GEvent *pe) {
}
}
+ #if GDISP_NEED_CIRCLE
+ void _gwidgetDrawFocusCircle(GWidgetObject *gx, coord_t radius) {
+ coord_t i;
+
+ // Don't do anything if we don't have the focus
+ if (&gx->g != _widgetInFocus)
+ return;
+
+ for (i = 0; i < GWIN_FOCUS_HIGHLIGHT_WIDTH; i++) {
+ gdispGDrawCircle(gx->g.display, gx->g.x + radius, gx->g.y + radius, radius + i, gx->pstyle->focus);
+ }
+ }
+ #endif
#endif
#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE