summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2017-03-05 14:52:10 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2017-03-05 14:52:10 +0000
commit168979e6fb9e338ba9c6033d14dba7c2c04782f6 (patch)
treee8e79782ab5e4f43541325642cc150beff16c917 /src
parent843183478b9a5329d4c761f65d36602efeb76d2c (diff)
Simplify Fl_Tabs label drawing code (remove code duplication).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12184 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Tabs.cxx29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/Fl_Tabs.cxx b/src/Fl_Tabs.cxx
index 26e092f3e..d57b92bc9 100644
--- a/src/Fl_Tabs.cxx
+++ b/src/Fl_Tabs.cxx
@@ -377,7 +377,11 @@ void Fl_Tabs::draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int what) {
char prev_draw_shortcut = fl_draw_shortcut;
fl_draw_shortcut = 1;
- Fl_Boxtype bt = (o==push_ &&!sel) ? fl_down(box()) : box();
+ Fl_Boxtype bt = (o == push_ && !sel) ? fl_down(box()) : box();
+ Fl_Color bc = sel ? selection_color() : o->selection_color();
+
+ // Save the label color
+ Fl_Color oc = o->labelcolor();
// compute offsets to make selected tab look bigger
int yofs = sel ? 0 : BORDER;
@@ -390,20 +394,12 @@ void Fl_Tabs::draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int what) {
H += dh;
- Fl_Color c = sel ? selection_color() : o->selection_color();
-
- draw_box(bt, x1, y() + yofs, W, H + 10 - yofs, c);
-
- // Save the previous label color
- Fl_Color oc = o->labelcolor();
+ draw_box(bt, x1, y() + yofs, W, H + 10 - yofs, bc);
// Draw the label using the current color...
o->labelcolor(sel ? labelcolor() : o->labelcolor());
o->draw_label(x1, y() + yofs, W, H - yofs, FL_ALIGN_CENTER);
- // Restore the original label color...
- o->labelcolor(oc);
-
if (Fl::focus() == this && o->visible())
draw_focus(box(), x1, y(), W, H);
@@ -416,26 +412,21 @@ void Fl_Tabs::draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int what) {
H += dh;
- Fl_Color c = sel ? selection_color() : o->selection_color();
-
- draw_box(bt, x1, y() + h() - H - 10, W, H + 10 - yofs, c);
-
- // Save the previous label color
- Fl_Color oc = o->labelcolor();
+ draw_box(bt, x1, y() + h() - H - 10, W, H + 10 - yofs, bc);
// Draw the label using the current color...
o->labelcolor(sel ? labelcolor() : o->labelcolor());
o->draw_label(x1, y() + h() - H, W, H - yofs, 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);
fl_pop_clip();
}
fl_draw_shortcut = prev_draw_shortcut;
+
+ // Restore the original label color
+ o->labelcolor(oc);
}
/**