mirror of https://github.com/fltk/fltk
Improve visibility of selected tab in Fl_Tabs (#1032).
This commit is contained in:
parent
0654da9d4a
commit
68f437b63e
|
@ -260,7 +260,6 @@ protected:
|
|||
int on_insert(Fl_Widget*, int) FL_OVERRIDE;
|
||||
int on_move(int, int) FL_OVERRIDE;
|
||||
void on_remove(int) FL_OVERRIDE;
|
||||
void resize(int, int, int, int) FL_OVERRIDE;
|
||||
|
||||
virtual void redraw_tabs();
|
||||
virtual int tab_positions(); // allocate and calculate tab positions
|
||||
|
@ -276,7 +275,10 @@ protected:
|
|||
public:
|
||||
|
||||
Fl_Tabs(int X, int Y, int W, int H, const char *L = 0);
|
||||
virtual ~Fl_Tabs();
|
||||
~Fl_Tabs() FL_OVERRIDE;
|
||||
|
||||
void resize(int, int, int, int) FL_OVERRIDE;
|
||||
void show() FL_OVERRIDE;
|
||||
|
||||
int handle(int) FL_OVERRIDE;
|
||||
Fl_Widget *value();
|
||||
|
|
|
@ -72,6 +72,12 @@ void Fl_Tabs::resize(int X, int Y, int W, int H) {
|
|||
Fl_Group::resize(X, Y, W, H);
|
||||
}
|
||||
|
||||
/** Ensure proper placement of selected tab. */
|
||||
void Fl_Tabs::show() {
|
||||
Fl::damage(FL_DAMAGE_SCROLL);
|
||||
Fl_Group::show();
|
||||
}
|
||||
|
||||
/** Calculate tab positions and widths.
|
||||
|
||||
This protected method calculates the horizontal display positions and
|
||||
|
@ -739,9 +745,8 @@ int Fl_Tabs::value(Fl_Widget *newvalue) {
|
|||
o->hide();
|
||||
}
|
||||
}
|
||||
// make sure that the selected tab is visible
|
||||
// always make sure that the selected tab is visible
|
||||
if ( (selected >= 0)
|
||||
&& (ret == 1)
|
||||
&& ( (overflow_type == OVERFLOW_DRAG)
|
||||
|| (overflow_type == OVERFLOW_PULLDOWN) ) ) {
|
||||
int m = MARGIN;
|
||||
|
@ -769,8 +774,10 @@ void Fl_Tabs::draw() {
|
|||
// FL_DAMAGE_EXPOSE : this is set if some setting in a widget changed
|
||||
// Fl_Tabs uses this to indicate that the tabs area needs a full redraw
|
||||
// FL_DAMAGE_SCROLL : this is used as a custom flag in various widgets
|
||||
// Fl_Tabs honors this flag for back compatibly as FL_DAMAGE_EXPOSE
|
||||
// FL_DAMAGE_ALL : just redraw everything
|
||||
// Fl_Tabs uses FL_DAMAGE_EXPOSE to indicate that the
|
||||
// tabs bar needs repositioning and teh tabs must be
|
||||
// redrawn
|
||||
// FL_DAMAGE_ALL : just recalculate and redraw everything
|
||||
|
||||
// Anatomy of tabs on top:
|
||||
// +------+ +---+ <<-- selected tabs start at y()
|
||||
|
@ -834,6 +841,13 @@ void Fl_Tabs::draw() {
|
|||
clipped_child_area_h = h() - tabs_h - selection_border_h;
|
||||
}
|
||||
|
||||
// ---- recalculate the tabs so that the selected tab is visible
|
||||
if (damage() & (FL_DAMAGE_ALL|FL_DAMAGE_SCROLL)) {
|
||||
Fl_Widget *selected_tab = value();
|
||||
if (selected_tab)
|
||||
value(selected_tab);
|
||||
}
|
||||
|
||||
// ---- draw the tabs and the selection border
|
||||
if (damage() & (FL_DAMAGE_ALL|FL_DAMAGE_EXPOSE|FL_DAMAGE_SCROLL))
|
||||
{
|
||||
|
@ -1177,7 +1191,7 @@ void Fl_Tabs::handle_overflow(int ov) {
|
|||
overflow_type = ov;
|
||||
tab_offset = 0;
|
||||
has_overflow_menu = 0;
|
||||
damage(FL_DAMAGE_EXPOSE);
|
||||
damage(FL_DAMAGE_SCROLL);
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue