From 168979e6fb9e338ba9c6033d14dba7c2c04782f6 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sun, 5 Mar 2017 14:52:10 +0000 Subject: 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 --- src/Fl_Tabs.cxx | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'src') 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); } /** -- cgit v1.2.3