Skip to content

Commit

Permalink
Improved rendering of GTabSet.
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-n committed Aug 14, 2012
1 parent e1f2659 commit 2f0ac45
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 26 deletions.
64 changes: 42 additions & 22 deletions gdraw/drawboxborder.c
Expand Up @@ -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;
Expand All @@ -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 )
Expand Down
18 changes: 14 additions & 4 deletions gdraw/gtabset.c
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions htdocs/changelog.html
Expand Up @@ -51,6 +51,8 @@ <H1 ALIGN=Center>
<UL>
<LI>
<B>UI fixes and additions:</B>
<LI>
Improved rendering of GTabSet.
<LI>
Fixed mnemonics clash (<I><U>N</U>ext</I> &amp; <I>Glyph <U>N</U>ame</I>)
in glyph info dialog.
Expand Down

0 comments on commit 2f0ac45

Please sign in to comment.