From 2f0ac4597dd14cd10dca1f839d545fccc946f9cd Mon Sep 17 00:00:00 2001 From: michal-n Date: Sat, 4 Aug 2012 15:36:58 +0200 Subject: [PATCH] Improved rendering of GTabSet. --- gdraw/drawboxborder.c | 64 ++++++++++++++++++++++++++++--------------- gdraw/gtabset.c | 18 +++++++++--- htdocs/changelog.html | 2 ++ 3 files changed, 58 insertions(+), 26 deletions(-) diff --git a/gdraw/drawboxborder.c b/gdraw/drawboxborder.c index 5cf353e0da..24b6d4548f 100644 --- a/gdraw/drawboxborder.c +++ b/gdraw/drawboxborder.c @@ -1179,6 +1179,18 @@ int GBoxDrawnWidth(GWindow gw, GBox *box) { return( bp ); } +static void GBoxDrawTabBackground(GWindow pixmap, GRect *rect, int radius, Color color) +{ + GRect older, r = *rect; + + GDrawPushClip(pixmap,rect,&older); + GDrawSetLineWidth(pixmap,1); + r.height*=2; + if (2*radius>=r.height) r.height=2*radius+1; + BoxFillRoundRect(pixmap, &r, radius, color); + GDrawPopClip(pixmap,&older); +} + void GBoxDrawTabOutline(GWindow pixmap, GGadget *g, int x, int y, int width, int rowh, int active ) { GRect r; @@ -1191,38 +1203,46 @@ void GBoxDrawTabOutline(GWindow pixmap, GGadget *g, int x, int y, int inset = 0; enum border_type bt = design->border_type; Color cols[4]; + Color fg = g->state==gs_disabled?design->disabled_foreground: design->main_foreground==COLOR_DEFAULT?GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap)): design->main_foreground; - Color color_inner = design->border_inner == COLOR_DEFAULT ? fg : design->border_inner; - Color color_outer = design->border_outer == COLOR_DEFAULT ? fg : design->border_outer; + + Color color_inner = design->border_inner == COLOR_DEFAULT ? fg : design->border_inner; + Color color_outer = design->border_outer == COLOR_DEFAULT ? fg : design->border_outer; + + Color gbg = GDrawGetDefaultBackground(GDrawGetDisplayOfWindow(pixmap)); + Color mbg = design->main_background==COLOR_DEFAULT?gbg:design->main_background; + Color dbg = design->disabled_background==COLOR_DEFAULT?gbg:design->disabled_background; + Color pbg = design->depressed_background==COLOR_DEFAULT?gbg:design->depressed_background; + Color ibg; r.x = x; r.y = y; r.width = width; r.height = rowh; - FigureBorderCols(design,cols); - if ( active ) { - Color gbg = GDrawGetDefaultBackground(GDrawGetDisplayOfWindow(pixmap)); - Color mbg = design->main_background==COLOR_DEFAULT?gbg:design->main_background; - Color dbg = design->disabled_background==COLOR_DEFAULT?gbg:design->disabled_background; - Color ibg; - - r.x -= bp; r.y -= bp; r.width += 2*bp; r.height += dw+bp; - - if ( g->state == gs_disabled ) { - ibg=dbg; - GDrawSetStippled(pixmap,1,0,0); - } else - ibg=mbg; - - GDrawFillRect(pixmap,&r,ibg); - if ( g->state == gs_disabled ) - GDrawSetStippled(pixmap,0,0,0); - } if ( rr==0 ) - rr = GDrawPointsToPixels(pixmap,3); + rr = GDrawPointsToPixels(pixmap,3); + if ( !(scale&1)) --scale; if ( scale==0 ) scale = 1; + FigureBorderCols(design,cols); + + if ( active ) { + r.x -= bp; r.y -= bp; r.width += 2*bp; r.height += dw+bp; + } + + if ( g->state == gs_disabled ) { + ibg=dbg; + GDrawSetStippled(pixmap,1,0,0); + } else if ( !active && (design->flags & box_do_depressed_background )) + ibg=pbg; + else + ibg=mbg; + + GBoxDrawTabBackground(pixmap,&r,rr,ibg); + if ( g->state == gs_disabled ) + GDrawSetStippled(pixmap,0,0,0); + if ( design->flags & (box_foreground_border_outer|box_foreground_shadow_outer) ) { GDrawSetLineWidth(pixmap,scale); if ( design->flags&box_foreground_border_outer ) diff --git a/gdraw/gtabset.c b/gdraw/gtabset.c index c63cd6b699..380a57a7f4 100644 --- a/gdraw/gtabset.c +++ b/gdraw/gtabset.c @@ -153,13 +153,23 @@ return( false ); GDrawPushClip(pixmap,&g->r,&old1); - GBoxDrawBackground(pixmap,&g->r,g->box, - g->state==gs_enabled? gs_pressedactive: g->state,false); + GBoxDrawBackground(pixmap,&g->r,g->box,g->state,false); bounds = g->r; + if ( !gts->vertical ) { - bounds.y += gts->rcnt*gts->rowh+yoff-1; - bounds.height -= gts->rcnt*gts->rowh+yoff-1; + /* make room for tabs */ + bounds.y += gts->rcnt*gts->rowh+yoff-1; + bounds.height -= gts->rcnt*gts->rowh+yoff-1; + } + else if ( g->state==gs_enabled ) { + /* background for labels */ + GRect old2, vertListRect = g->r; + vertListRect.width = gts->vert_list_width+bw-1; + GDrawPushClip(pixmap,&vertListRect,&old2); + GBoxDrawBackground(pixmap,&g->r,g->box,gs_pressedactive,false); + GDrawPopClip(pixmap,&old2); } + GBoxDrawBorder(pixmap,&bounds,g->box,g->state,false); GDrawSetFont(pixmap,gts->font); diff --git a/htdocs/changelog.html b/htdocs/changelog.html index 9f5e7bab69..4eb91a347a 100644 --- a/htdocs/changelog.html +++ b/htdocs/changelog.html @@ -51,6 +51,8 @@