aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin/button.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gwin/button.c')
-rw-r--r--src/gwin/button.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/gwin/button.c b/src/gwin/button.c
index 72d75225..f34e4ba3 100644
--- a/src/gwin/button.c
+++ b/src/gwin/button.c
@@ -25,6 +25,8 @@
#define RND_CNR_SIZE 5 // Rounded corner size for rounded buttons
#define ARROWHEAD_DIVIDER 4 // A quarter of the height for the arrow head
#define ARROWBODY_DIVIDER 4 // A quarter of the width for the arrow body
+#define TOP_FADE 50 // (TOP_FADE/255)% fade to white for top of button
+#define BOTTOM_FADE 25 // (BOTTOM_FADE/255)% fade to black for bottom of button
// Our pressed state
#define GBUTTON_FLG_PRESSED (GWIN_FIRST_CONTROL_FLAG<<0)
@@ -109,7 +111,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 +166,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, TOP_FADE);
+ bcol = gdispBlendColor(Black, pcol->fill, BOTTOM_FADE);
+ 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) {