summaryrefslogtreecommitdiff
path: root/src/Fl_Tabs.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2005-04-21 18:25:22 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2005-04-21 18:25:22 +0000
commit668ef918e834bf8ac40d238d5477b5de7e914e3e (patch)
treec93ac3f742644c6199c4e56d3f9cfc6d27c3d9ea /src/Fl_Tabs.cxx
parent2eb4d42349193daa75ad08b63c575d37d5299af5 (diff)
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. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4295 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Tabs.cxx')
-rw-r--r--src/Fl_Tabs.cxx50
1 files changed, 43 insertions, 7 deletions
diff --git a/src/Fl_Tabs.cxx b/src/Fl_Tabs.cxx
index 5cad140f9..e046ef16e 100644
--- a/src/Fl_Tabs.cxx
+++ b/src/Fl_Tabs.cxx
@@ -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);
@@ -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);
@@ -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);