diff options
author | Joel Bodenmann <joel@seriouslyembedded.com> | 2015-08-14 23:51:28 +0200 |
---|---|---|
committer | Joel Bodenmann <joel@seriouslyembedded.com> | 2015-08-14 23:51:28 +0200 |
commit | 668b161f0eead1b9687305281eb59be0e0713bbe (patch) | |
tree | 75bcf589f03dc528ed2ff960388d940fcf3a9b0d /src | |
parent | 755b7a45ab517a303510b728a9c54e48f9216557 (diff) | |
download | uGFX-668b161f0eead1b9687305281eb59be0e0713bbe.tar.gz uGFX-668b161f0eead1b9687305281eb59be0e0713bbe.tar.bz2 uGFX-668b161f0eead1b9687305281eb59be0e0713bbe.zip |
Adding color to widget style for focused widgets
Diffstat (limited to 'src')
-rw-r--r-- | src/gwin/gwin_textedit.c | 15 | ||||
-rw-r--r-- | src/gwin/gwin_widget.c | 18 | ||||
-rw-r--r-- | src/gwin/gwin_widget.h | 1 |
3 files changed, 23 insertions, 11 deletions
diff --git a/src/gwin/gwin_textedit.c b/src/gwin/gwin_textedit.c index eb6340a3..21415b9c 100644 --- a/src/gwin/gwin_textedit.c +++ b/src/gwin/gwin_textedit.c @@ -18,9 +18,10 @@ #include <string.h> // Some settings -const int TEXT_PADDING_LEFT = 4; -const int CURSOR_PADDING_LEFT = 0; -const int CURSOR_EXTRA_HEIGHT = 1; +const int TEXT_PADDING_LEFT = 4; +const int FOCUS_BORDER_THICKNESS = 3; +const int CURSOR_PADDING_LEFT = 0; +const int CURSOR_EXTRA_HEIGHT = 1; // Some flags #define GTEXTEDIT_FLG_BORDER (GWIN_FIRST_CONTROL_FLAG << 0) @@ -237,6 +238,14 @@ static void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param) gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.edge : gw->pstyle->disabled.edge); } + // Render highlighted border of focused + if (gwinGetFocus() == (GHandle)gw) { + int i = 0; + for (i = 0; i < FOCUS_BORDER_THICKNESS; i++) { + gdispGDrawBox(gw->g.display, gw->g.x+i, gw->g.y+i, gw->g.width-2*i, gw->g.height-2*i, gw->pstyle->focus); + } + } + // Render cursor (if focused) if (gwinGetFocus() == (GHandle)gw) { // Calculate cursor stuff diff --git a/src/gwin/gwin_widget.c b/src/gwin/gwin_widget.c index c536b88a..f135b306 100644 --- a/src/gwin/gwin_widget.c +++ b/src/gwin/gwin_widget.c @@ -24,13 +24,14 @@ static GListener gl; // Our default style - a white background theme const GWidgetStyle WhiteWidgetStyle = { HTML2COLOR(0xFFFFFF), // window background + HTML2COLOR(0x2A8FCD), // focused // enabled color set { HTML2COLOR(0x000000), // text HTML2COLOR(0x404040), // edge HTML2COLOR(0xE0E0E0), // fill - HTML2COLOR(0xE0E0E0), // progress - inactive area + HTML2COLOR(0xE0E0E0) // progress - inactive area }, // disabled color set @@ -38,7 +39,7 @@ const GWidgetStyle WhiteWidgetStyle = { HTML2COLOR(0xC0C0C0), // text HTML2COLOR(0x808080), // edge HTML2COLOR(0xE0E0E0), // fill - HTML2COLOR(0xC0E0C0), // progress - active area + HTML2COLOR(0xC0E0C0) // progress - active area }, // pressed color set @@ -46,20 +47,21 @@ const GWidgetStyle WhiteWidgetStyle = { HTML2COLOR(0x404040), // text HTML2COLOR(0x404040), // edge HTML2COLOR(0x808080), // fill - HTML2COLOR(0x00E000), // progress - active area - }, + HTML2COLOR(0x00E000) // progress - active area + } }; /* Our black style */ const GWidgetStyle BlackWidgetStyle = { HTML2COLOR(0x000000), // window background + HTML2COLOR(0x2A8FCD), // focused // enabled color set { HTML2COLOR(0xC0C0C0), // text HTML2COLOR(0xC0C0C0), // edge HTML2COLOR(0x606060), // fill - HTML2COLOR(0x404040), // progress - inactive area + HTML2COLOR(0x404040) // progress - inactive area }, // disabled color set @@ -67,7 +69,7 @@ const GWidgetStyle BlackWidgetStyle = { HTML2COLOR(0x808080), // text HTML2COLOR(0x404040), // edge HTML2COLOR(0x404040), // fill - HTML2COLOR(0x004000), // progress - active area + HTML2COLOR(0x004000) // progress - active area }, // pressed color set @@ -75,8 +77,8 @@ const GWidgetStyle BlackWidgetStyle = { HTML2COLOR(0xFFFFFF), // text HTML2COLOR(0xC0C0C0), // edge HTML2COLOR(0xE0E0E0), // fill - HTML2COLOR(0x008000), // progress - active area - }, + HTML2COLOR(0x008000) // progress - active area + } }; static const GWidgetStyle * defaultStyle = &BlackWidgetStyle; diff --git a/src/gwin/gwin_widget.h b/src/gwin/gwin_widget.h index d7b88b70..4f164184 100644 --- a/src/gwin/gwin_widget.h +++ b/src/gwin/gwin_widget.h @@ -49,6 +49,7 @@ typedef struct GColorSet { */ typedef struct GWidgetStyle { color_t background; // @< The window background color + color_t focus; // @< The color when a widget is focused GColorSet enabled; // @< The colors when enabled GColorSet disabled; // @< The colors when disabled GColorSet pressed; // @< The colors when pressed |