Reduce page increment of GTK wxSpinButton for narrow range
Gradually reduce the page increment in the case of a narrow range for convenience and to limit possible EVT_SPIN_UP/EVT_SPIN_DOWN ambiguity when wrapping is on. Closes https://github.com/wxWidgets/wxWidgets/pull/1900
This commit is contained in:
committed by
Vadim Zeitlin
parent
350ae65cb6
commit
99cd70e7b8
@@ -186,6 +186,26 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
|
||||
GtkDisableEvents();
|
||||
gtk_spin_button_set_range((GtkSpinButton*)m_widget, minVal, maxVal);
|
||||
m_pos = int(gtk_spin_button_get_value((GtkSpinButton*)m_widget));
|
||||
|
||||
// Use smaller page increment in the case of a narrow range for convenience
|
||||
// and to limit possible up/down ambiguity in gtk_value_changed() when
|
||||
// wrapping is on (The maximal page increment of 10 is consistent with the
|
||||
// default page increment set by gtk_spin_button_new_with_range(0, 100, 1)
|
||||
// in wxSpinButton::Create().)
|
||||
const int range = maxVal - minVal;
|
||||
int pageInc;
|
||||
if ( range < 10 )
|
||||
pageInc = 1;
|
||||
else if ( range < 20 )
|
||||
pageInc = 2;
|
||||
else if ( range < 50 )
|
||||
pageInc = 5;
|
||||
else
|
||||
pageInc = 10;
|
||||
|
||||
GtkAdjustment* adj = gtk_spin_button_get_adjustment((GtkSpinButton*)m_widget);
|
||||
gtk_adjustment_set_page_increment(adj, pageInc);
|
||||
|
||||
GtkEnableEvents();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user