diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-05-01 13:57:44 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-05-01 13:57:44 +1000 |
commit | ef0a1ef054d100eace7cc58941b27c2d5ed67518 (patch) | |
tree | bd4bb2aac9cbff05f921db1f9f2a6c2612d9489c /src/gwin/button.c | |
parent | 96cec5349a40bb55b9c65e19234234d2ab197b48 (diff) | |
download | uGFX-ef0a1ef054d100eace7cc58941b27c2d5ed67518.tar.gz uGFX-ef0a1ef054d100eace7cc58941b27c2d5ed67518.tar.bz2 uGFX-ef0a1ef054d100eace7cc58941b27c2d5ed67518.zip |
Much improved appearance for buttons and tabs.
Also add GWIN_FLAT_STYLING to allow low color (eg monochrome) displays to get the old simplified look.
Diffstat (limited to 'src/gwin/button.c')
-rw-r--r-- | src/gwin/button.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/gwin/button.c b/src/gwin/button.c index 72d75225..59c7f689 100644 --- a/src/gwin/button.c +++ b/src/gwin/button.c @@ -109,7 +109,7 @@ static const gwidgetVMT buttonVMT = { _gwidgetRedraw, // The redraw routine 0, // The after-clear routine }, - gwinButtonDraw_3D, // The default drawing routine + gwinButtonDraw_Normal, // The default drawing routine #if GINPUT_NEED_MOUSE { MouseDown, // Process mouse down events @@ -164,17 +164,42 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) { return &gw->pstyle->enabled; } -void gwinButtonDraw_3D(GWidgetObject *gw, void *param) { - const GColorSet * pcol; - (void) param; +#if GWIN_FLAT_STYLING + void gwinButtonDraw_Normal(GWidgetObject *gw, void *param) { + const GColorSet * pcol; + (void) param; + + if (gw->g.vmt != (gwinVMT *)&buttonVMT) return; + pcol = getDrawColors(gw); + + 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); + } +#else + void gwinButtonDraw_Normal(GWidgetObject *gw, void *param) { + const GColorSet * pcol; + fixed alpha; + fixed dalpha; + coord_t i; + color_t tcol, bcol; + (void) param; - if (gw->g.vmt != (gwinVMT *)&buttonVMT) return; - pcol = getDrawColors(gw); + if (gw->g.vmt != (gwinVMT *)&buttonVMT) return; + pcol = getDrawColors(gw); - 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); -} + /* Fill the box blended from variants of the fill color */ + tcol = gdispBlendColor(White, pcol->fill, 50); + bcol = gdispBlendColor(Black, pcol->fill, 25); + dalpha = FIXED(255)/gw->g.height; + for(alpha = 0, i = 0; i < gw->g.height; i++, alpha += dalpha) + gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+i, gw->g.x+gw->g.width-2, gw->g.y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha))); + + 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); + } +#endif #if GDISP_NEED_ARC void gwinButtonDraw_Rounded(GWidgetObject *gw, void *param) { |