diff --git a/docs/releases.txt b/docs/releases.txt index 07c97bb2..804f2c1b 100644 --- a/docs/releases.txt +++ b/docs/releases.txt @@ -13,6 +13,7 @@ FEATURE: Implementing widget focusing. See gwinSetFocus() and gwinGetFocus() FEATURE: Adding more font metrics (BaselineX and BaselineY) FEATURE: Adding gdispGetStringWidthCount() FEATURE: Adding TextEdit widget +FEATURE: Added color to widget style for focused widgets *** Release 2.3 *** 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 // 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