Partially hidden toolbars can now be scrolled with the mouse wheel

...thanks to the new MyScrolledToolbar class (guiutils.h/cc). This is
valid for the FileBrowser tab (first and second line can be scrolled
individually) and the top and bottom bar of the Editor(s) tab.

see #4035
This commit is contained in:
Hombre
2018-09-02 10:47:44 +02:00
parent 61e033ae14
commit 20118c4019
5 changed files with 97 additions and 17 deletions

View File

@@ -955,7 +955,7 @@ bool MyScrolledWindow::on_scroll_event (GdkEventScroll* event)
if (value2 != value) {
scroll->set_value(value2);
}
} else {
} else if (event->direction == GDK_SCROLL_UP) {
value2 = value - step;
if (value2 < lower) {
@@ -981,6 +981,57 @@ void MyScrolledWindow::get_preferred_height_for_width_vfunc (int width, int &min
natural_height = minimum_height = 50;
}
/*
*
* Derived class of some widgets to properly handle the scroll wheel ;
* the user has to use the Shift key to be able to change the widget's value,
* otherwise the mouse wheel will scroll the toolbar.
*
*/
MyScrolledToolbar::MyScrolledToolbar ()
{
set_policy (Gtk::POLICY_EXTERNAL, Gtk::POLICY_NEVER);
set_propagate_natural_height(true);
}
bool MyScrolledToolbar::on_scroll_event (GdkEventScroll* event)
{
Glib::RefPtr<Gtk::Adjustment> adjust = get_hadjustment();
Gtk::Scrollbar *scroll = get_hscrollbar();
if (adjust && scroll) {
double upper = adjust->get_upper();
double lower = adjust->get_lower();
double value = adjust->get_value();
double step = adjust->get_step_increment() * 2;
double value2 = 0.;
if (event->direction == GDK_SCROLL_DOWN) {
value2 = value + step;
if (value2 > upper) {
value2 = upper;
}
if (value2 != value) {
scroll->set_value(value2);
}
} else if (event->direction == GDK_SCROLL_UP) {
value2 = value - step;
if (value2 < lower) {
value2 = lower;
}
if (value2 != value) {
scroll->set_value(value2);
}
}
}
return true;
}
MyComboBoxText::MyComboBoxText (bool has_entry) : Gtk::ComboBoxText(has_entry)
{
minimumWidth = naturalWidth = 70;