Skip to content

Commit

Permalink
Updated Fl_Tabs to check the contrast of the label color against
Browse files Browse the repository at this point in the history
the tab background, and to highlight the top 5 lines of the tab
pane with the selection color so that selected tabs stand out
more.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4295 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
michaelrsweet committed Apr 21, 2005
1 parent 2eb4d42 commit 668ef91
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Expand Up @@ -2,6 +2,10 @@ CHANGES IN FLTK 1.1.7

- Documentation fixes (STR #648, STR #692, STR #730, STR
#744, STR #745)
- Updated Fl_Tabs to check the contrast of the label
color against the tab background, and to highlight the
top 5 lines of the tab pane with the selection color so
that selected tabs stand out more.
- The example programs can now compile separate from the
FLTK source distribution (STR #809)
- The example programs are now installed with the
Expand Down
50 changes: 43 additions & 7 deletions src/Fl_Tabs.cxx
Expand Up @@ -238,7 +238,21 @@ void Fl_Tabs::draw() {
int H = tab_height();

if (damage() & FL_DAMAGE_ALL) { // redraw the entire thing:
draw_box(box(), x(), y()+(H>=0?H:0), w(), h()-(H>=0?H:-H), v ? v->color() : color());
Fl_Color c = v ? v->color() : color();

draw_box(box(), x(), y()+(H>=0?H:0), w(), h()-(H>=0?H:-H), c);

if (selection_color() != c) {
// Draw the top 5 lines of the tab pane in the selection color so
// that the user knows which tab is selected...
if (H >= 0) fl_push_clip(x(), y() + H, w(), 5);
else fl_push_clip(x(), y() + h() - H - 4, w(), 5);

draw_box(box(), x(), y()+(H>=0?H:0), w(), h()-(H>=0?H:-H),
selection_color());

fl_pop_clip();
}
if (v) draw_child(*v);
} else { // redraw the child
if (v) update_child(*v);
Expand Down Expand Up @@ -272,12 +286,23 @@ void Fl_Tabs::draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int what) {

H += dh;

draw_box(box(), x1, y(), W, H,
sel ? fl_color_average(selection_color(), o->selection_color(), 0.5f)
: o->selection_color());
Fl_Color c = sel ? selection_color() : o->selection_color();

draw_box(box(), x1, y(), W, H, c);

// Make sure that the label contrasts the tab color...
c = fl_contrast(o->labelcolor(), c);

// Save the previous label color
Fl_Color oc = o->labelcolor();

// Draw the label using the contrast color...
o->labelcolor(c);
o->draw_label(x1, y(), W, H, FL_ALIGN_CENTER);

// Restore the original label color...
o->labelcolor(oc);

if (Fl::focus() == this && o->visible())
draw_focus(box(), x1, y(), W, H);

Expand All @@ -290,12 +315,23 @@ void Fl_Tabs::draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int what) {

H += dh;

draw_box(box(), x1, y() + h() - H, W, H,
sel ? fl_color_average(selection_color(), o->selection_color(), 0.5f)
: o->selection_color());
Fl_Color c = sel ? selection_color() : o->selection_color();

draw_box(box(), x1, y() + h() - H, W, H, c);

// Make sure that the label contrasts the tab color...
c = fl_contrast(o->labelcolor(), c);

// Save the previous label color
Fl_Color oc = o->labelcolor();

// Draw the label using the contrast color...
o->labelcolor(c);
o->draw_label(x1, y() + h() - H, W, H, FL_ALIGN_CENTER);

// Restore the original label color...
o->labelcolor(oc);

if (Fl::focus() == this && o->visible())
draw_focus(box(), x1, y() + h() - H, W, H);

Expand Down

0 comments on commit 668ef91

Please sign in to comment.