mirror of
https://github.com/fltk/fltk.git
synced 2026-05-22 07:01:34 +08:00
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
This commit is contained in:
+10
-19
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user