Adding color to widget style for focused widgets
This commit is contained in:
parent
755b7a45ab
commit
668b161f0e
4 changed files with 24 additions and 11 deletions
|
@ -13,6 +13,7 @@ FEATURE: Implementing widget focusing. See gwinSetFocus() and gwinGetFocus()
|
||||||
FEATURE: Adding more font metrics (BaselineX and BaselineY)
|
FEATURE: Adding more font metrics (BaselineX and BaselineY)
|
||||||
FEATURE: Adding gdispGetStringWidthCount()
|
FEATURE: Adding gdispGetStringWidthCount()
|
||||||
FEATURE: Adding TextEdit widget
|
FEATURE: Adding TextEdit widget
|
||||||
|
FEATURE: Added color to widget style for focused widgets
|
||||||
|
|
||||||
|
|
||||||
*** Release 2.3 ***
|
*** Release 2.3 ***
|
||||||
|
|
|
@ -18,9 +18,10 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// Some settings
|
// Some settings
|
||||||
const int TEXT_PADDING_LEFT = 4;
|
const int TEXT_PADDING_LEFT = 4;
|
||||||
const int CURSOR_PADDING_LEFT = 0;
|
const int FOCUS_BORDER_THICKNESS = 3;
|
||||||
const int CURSOR_EXTRA_HEIGHT = 1;
|
const int CURSOR_PADDING_LEFT = 0;
|
||||||
|
const int CURSOR_EXTRA_HEIGHT = 1;
|
||||||
|
|
||||||
// Some flags
|
// Some flags
|
||||||
#define GTEXTEDIT_FLG_BORDER (GWIN_FIRST_CONTROL_FLAG << 0)
|
#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);
|
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)
|
// Render cursor (if focused)
|
||||||
if (gwinGetFocus() == (GHandle)gw) {
|
if (gwinGetFocus() == (GHandle)gw) {
|
||||||
// Calculate cursor stuff
|
// Calculate cursor stuff
|
||||||
|
|
|
@ -24,13 +24,14 @@ static GListener gl;
|
||||||
// Our default style - a white background theme
|
// Our default style - a white background theme
|
||||||
const GWidgetStyle WhiteWidgetStyle = {
|
const GWidgetStyle WhiteWidgetStyle = {
|
||||||
HTML2COLOR(0xFFFFFF), // window background
|
HTML2COLOR(0xFFFFFF), // window background
|
||||||
|
HTML2COLOR(0x2A8FCD), // focused
|
||||||
|
|
||||||
// enabled color set
|
// enabled color set
|
||||||
{
|
{
|
||||||
HTML2COLOR(0x000000), // text
|
HTML2COLOR(0x000000), // text
|
||||||
HTML2COLOR(0x404040), // edge
|
HTML2COLOR(0x404040), // edge
|
||||||
HTML2COLOR(0xE0E0E0), // fill
|
HTML2COLOR(0xE0E0E0), // fill
|
||||||
HTML2COLOR(0xE0E0E0), // progress - inactive area
|
HTML2COLOR(0xE0E0E0) // progress - inactive area
|
||||||
},
|
},
|
||||||
|
|
||||||
// disabled color set
|
// disabled color set
|
||||||
|
@ -38,7 +39,7 @@ const GWidgetStyle WhiteWidgetStyle = {
|
||||||
HTML2COLOR(0xC0C0C0), // text
|
HTML2COLOR(0xC0C0C0), // text
|
||||||
HTML2COLOR(0x808080), // edge
|
HTML2COLOR(0x808080), // edge
|
||||||
HTML2COLOR(0xE0E0E0), // fill
|
HTML2COLOR(0xE0E0E0), // fill
|
||||||
HTML2COLOR(0xC0E0C0), // progress - active area
|
HTML2COLOR(0xC0E0C0) // progress - active area
|
||||||
},
|
},
|
||||||
|
|
||||||
// pressed color set
|
// pressed color set
|
||||||
|
@ -46,20 +47,21 @@ const GWidgetStyle WhiteWidgetStyle = {
|
||||||
HTML2COLOR(0x404040), // text
|
HTML2COLOR(0x404040), // text
|
||||||
HTML2COLOR(0x404040), // edge
|
HTML2COLOR(0x404040), // edge
|
||||||
HTML2COLOR(0x808080), // fill
|
HTML2COLOR(0x808080), // fill
|
||||||
HTML2COLOR(0x00E000), // progress - active area
|
HTML2COLOR(0x00E000) // progress - active area
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Our black style */
|
/* Our black style */
|
||||||
const GWidgetStyle BlackWidgetStyle = {
|
const GWidgetStyle BlackWidgetStyle = {
|
||||||
HTML2COLOR(0x000000), // window background
|
HTML2COLOR(0x000000), // window background
|
||||||
|
HTML2COLOR(0x2A8FCD), // focused
|
||||||
|
|
||||||
// enabled color set
|
// enabled color set
|
||||||
{
|
{
|
||||||
HTML2COLOR(0xC0C0C0), // text
|
HTML2COLOR(0xC0C0C0), // text
|
||||||
HTML2COLOR(0xC0C0C0), // edge
|
HTML2COLOR(0xC0C0C0), // edge
|
||||||
HTML2COLOR(0x606060), // fill
|
HTML2COLOR(0x606060), // fill
|
||||||
HTML2COLOR(0x404040), // progress - inactive area
|
HTML2COLOR(0x404040) // progress - inactive area
|
||||||
},
|
},
|
||||||
|
|
||||||
// disabled color set
|
// disabled color set
|
||||||
|
@ -67,7 +69,7 @@ const GWidgetStyle BlackWidgetStyle = {
|
||||||
HTML2COLOR(0x808080), // text
|
HTML2COLOR(0x808080), // text
|
||||||
HTML2COLOR(0x404040), // edge
|
HTML2COLOR(0x404040), // edge
|
||||||
HTML2COLOR(0x404040), // fill
|
HTML2COLOR(0x404040), // fill
|
||||||
HTML2COLOR(0x004000), // progress - active area
|
HTML2COLOR(0x004000) // progress - active area
|
||||||
},
|
},
|
||||||
|
|
||||||
// pressed color set
|
// pressed color set
|
||||||
|
@ -75,8 +77,8 @@ const GWidgetStyle BlackWidgetStyle = {
|
||||||
HTML2COLOR(0xFFFFFF), // text
|
HTML2COLOR(0xFFFFFF), // text
|
||||||
HTML2COLOR(0xC0C0C0), // edge
|
HTML2COLOR(0xC0C0C0), // edge
|
||||||
HTML2COLOR(0xE0E0E0), // fill
|
HTML2COLOR(0xE0E0E0), // fill
|
||||||
HTML2COLOR(0x008000), // progress - active area
|
HTML2COLOR(0x008000) // progress - active area
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GWidgetStyle * defaultStyle = &BlackWidgetStyle;
|
static const GWidgetStyle * defaultStyle = &BlackWidgetStyle;
|
||||||
|
|
|
@ -49,6 +49,7 @@ typedef struct GColorSet {
|
||||||
*/
|
*/
|
||||||
typedef struct GWidgetStyle {
|
typedef struct GWidgetStyle {
|
||||||
color_t background; // @< The window background color
|
color_t background; // @< The window background color
|
||||||
|
color_t focus; // @< The color when a widget is focused
|
||||||
GColorSet enabled; // @< The colors when enabled
|
GColorSet enabled; // @< The colors when enabled
|
||||||
GColorSet disabled; // @< The colors when disabled
|
GColorSet disabled; // @< The colors when disabled
|
||||||
GColorSet pressed; // @< The colors when pressed
|
GColorSet pressed; // @< The colors when pressed
|
||||||
|
|
Loading…
Add table
Reference in a new issue