From caffc3a23dea682c6706fb5728a16c16c5f4b2c0 Mon Sep 17 00:00:00 2001 From: Hombre Date: Thu, 6 Sep 2018 23:10:16 +0200 Subject: [PATCH] Bugfix: the scrollable toolbars was freezing under some circumstances --- rtgui/guiutils.cc | 22 +++++++++++++++++++++- rtgui/guiutils.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index 447c9d8af..1e4f4eac8 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -991,8 +991,11 @@ void MyScrolledWindow::get_preferred_height_for_width_vfunc (int width, int &min MyScrolledToolbar::MyScrolledToolbar () { set_policy (Gtk::POLICY_EXTERNAL, Gtk::POLICY_NEVER); - set_propagate_natural_height(true); get_style_context()->add_class("scrollableToolbar"); + + // Works fine with Gtk 3.22, but a a custom made get_preferred_height had to be created as a workaround + // taken from the official Gtk3.22 source code + //set_propagate_natural_height(true); } bool MyScrolledToolbar::on_scroll_event (GdkEventScroll* event) @@ -1032,6 +1035,23 @@ bool MyScrolledToolbar::on_scroll_event (GdkEventScroll* event) return true; } +void MyScrolledToolbar::get_preferred_height (int &minimumHeight, int &naturalHeight) +{ + int currMinHeight = 0; + int currNatHeight = 0; + std::vector childs = get_children(); + minimumHeight = naturalHeight = 0; + + for (auto child : childs) + { + if(child->is_visible()) { + child->get_preferred_height(currMinHeight, currNatHeight); + minimumHeight = rtengine::max(currMinHeight, minimumHeight); + naturalHeight = rtengine::max(currNatHeight, naturalHeight); + } + } +} + MyComboBoxText::MyComboBoxText (bool has_entry) : Gtk::ComboBoxText(has_entry) { minimumWidth = naturalWidth = 70; diff --git a/rtgui/guiutils.h b/rtgui/guiutils.h index 89d05bfce..fb627a78a 100644 --- a/rtgui/guiutils.h +++ b/rtgui/guiutils.h @@ -300,6 +300,7 @@ class MyScrolledToolbar : public Gtk::ScrolledWindow { bool on_scroll_event (GdkEventScroll* event); + void get_preferred_height (int &minimumHeight, int &naturalHeight); public: MyScrolledToolbar();