Solving issue 735 : "Zooming with mouse wheel should zoom where the mouse is".
The scroll wheel is now used for scrolling the editor's tab content. If you want to change the spin button's/slider's value or combobox entry, press the SHIFT key while using the scroll wheel. This patch also: - reduce the spin buttons size (50px wide, instead of 70px) - reduce the minimum size of the combobox (tool panels can now be narrower before showing the horizontal scrollbar) Note to developers: ------------------- When creating GUI for editor tools, please use the MyComboBox, MyComboBoxText, MySpinButton and MyFileChooserButton derived class only in order to handle the scroll wheel properly (-> #include <guiutils.h>). Known bug: The MyFileChooserButton thas is a FILE_CHOOSER_ACTION_SELECT_FOLDER does not respond correctly to the new behaviour.
This commit is contained in:
@@ -227,3 +227,89 @@ void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int
|
||||
}
|
||||
cr->reset_clip ();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* 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 editor's tabs content.
|
||||
*
|
||||
*/
|
||||
MyComboBoxText::MyComboBoxText () {
|
||||
set_size_request(40, -1);
|
||||
}
|
||||
|
||||
bool MyComboBoxText::on_scroll_event (GdkEventScroll* event) {
|
||||
|
||||
// If Shift is pressed, the widget is modified
|
||||
if (event->state & GDK_SHIFT_MASK) {
|
||||
Gtk::ComboBoxText::on_scroll_event(event);
|
||||
return true;
|
||||
}
|
||||
// ... otherwise the scroll event is sent back to an upper level
|
||||
return false;
|
||||
}
|
||||
|
||||
MyComboBox::MyComboBox () {
|
||||
set_size_request(40, -1);
|
||||
}
|
||||
|
||||
bool MyComboBox::on_scroll_event (GdkEventScroll* event) {
|
||||
|
||||
// If Shift is pressed, the widget is modified
|
||||
if (event->state & GDK_SHIFT_MASK) {
|
||||
Gtk::ComboBox::on_scroll_event(event);
|
||||
return true;
|
||||
}
|
||||
// ... otherwise the scroll event is sent back to an upper level
|
||||
return false;
|
||||
}
|
||||
|
||||
MySpinButton::MySpinButton () {
|
||||
set_size_request(50, -1);
|
||||
Gtk::Border border;
|
||||
border.bottom = 0;
|
||||
border.top = 0;
|
||||
border.left = 0;
|
||||
border.right = 0;
|
||||
set_inner_border(border);
|
||||
}
|
||||
|
||||
bool MySpinButton::on_scroll_event (GdkEventScroll* event) {
|
||||
|
||||
// If Shift is pressed, the widget is modified
|
||||
if (event->state & GDK_SHIFT_MASK) {
|
||||
Gtk::SpinButton::on_scroll_event(event);
|
||||
return true;
|
||||
}
|
||||
// ... otherwise the scroll event is sent back to an upper level
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MyHScale::on_scroll_event (GdkEventScroll* event) {
|
||||
|
||||
// If Shift is pressed, the widget is modified
|
||||
if (event->state & GDK_SHIFT_MASK) {
|
||||
Gtk::HScale::on_scroll_event(event);
|
||||
return true;
|
||||
}
|
||||
// ... otherwise the scroll event is sent back to an upper level
|
||||
return false;
|
||||
}
|
||||
|
||||
MyFileChooserButton::MyFileChooserButton (const Glib::ustring& title, Gtk::FileChooserAction action) : Gtk::FileChooserButton(title, action) {
|
||||
set_size_request(20, -1);
|
||||
};
|
||||
|
||||
// For an unknown reason (a bug ?), it doesn't work when action = FILE_CHOOSER_ACTION_SELECT_FOLDER !
|
||||
bool MyFileChooserButton::on_scroll_event (GdkEventScroll* event) {
|
||||
|
||||
// If Shift is pressed, the widget is modified
|
||||
if (event->state & GDK_SHIFT_MASK) {
|
||||
Gtk::FileChooserButton::on_scroll_event(event);
|
||||
return true;
|
||||
}
|
||||
// ... otherwise the scroll event is sent back to an upper level
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user