Adding color to widget style for focused widgets

ugfx_release_2.6
Joel Bodenmann 2015-08-14 23:51:28 +02:00
parent 755b7a45ab
commit 668b161f0e
4 changed files with 24 additions and 11 deletions

View File

@ -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 ***

View File

@ -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

View File

@ -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;

View File

@ -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