diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index fd494ba30..3e15ad31f 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -49,7 +49,7 @@ private: private: void prepareProfileBox () { - profileBox.set_size_request(90, -1); + profileBox.setPreferredWidth(70, 200); setExpandAlignProperties (&profileBox, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_FILL); profileBox.append (M ("PREFERENCES_PROFILE_NONE")); diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index e63825d69..740c99a52 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -938,6 +938,7 @@ void MyScrolledWindow::get_preferred_height_for_width_vfunc (int width, int &min MyComboBoxText::MyComboBoxText (bool has_entry) : Gtk::ComboBoxText(has_entry) { + minimumWidth = naturalWidth = 70; Gtk::CellRendererText* cellRenderer = dynamic_cast(get_first_cell()); cellRenderer->property_ellipsize() = Pango::ELLIPSIZE_MIDDLE; } @@ -955,6 +956,39 @@ bool MyComboBoxText::on_scroll_event (GdkEventScroll* event) return false; } +void MyComboBoxText::setPreferredWidth (int minimum_width, int natural_width) +{ + if (natural_width == -1 && minimum_width == -1) { + naturalWidth = minimumWidth = 70; + } else if (natural_width == -1) { + naturalWidth = minimumWidth = minimum_width; + } else if (minimum_width == -1) { + naturalWidth = natural_width; + minimumWidth = rtengine::max(naturalWidth / 2, 20); + minimumWidth = rtengine::min(naturalWidth, minimumWidth); + } else { + naturalWidth = natural_width; + minimumWidth = minimum_width; + } +} + +void MyComboBoxText::get_preferred_width_vfunc (int &minimum_width, int &natural_width) const +{ + natural_width = rtengine::max(naturalWidth, 10); + minimum_width = rtengine::max(minimumWidth, 10); +} +void MyComboBoxText::get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const +{ + natural_width = rtengine::max(naturalWidth, 10); + minimum_width = rtengine::max(minimumWidth, 10); +} + + +MyComboBox::MyComboBox () +{ + minimumWidth = naturalWidth = 70; +} + bool MyComboBox::on_scroll_event (GdkEventScroll* event) { @@ -968,6 +1002,33 @@ bool MyComboBox::on_scroll_event (GdkEventScroll* event) return false; } +void MyComboBox::setPreferredWidth (int minimum_width, int natural_width) +{ + if (natural_width == -1 && minimum_width == -1) { + naturalWidth = minimumWidth = 70; + } else if (natural_width == -1) { + naturalWidth = minimumWidth = minimum_width; + } else if (minimum_width == -1) { + naturalWidth = natural_width; + minimumWidth = rtengine::max(naturalWidth / 2, 20); + minimumWidth = rtengine::min(naturalWidth, minimumWidth); + } else { + naturalWidth = natural_width; + minimumWidth = minimum_width; + } +} + +void MyComboBox::get_preferred_width_vfunc (int &minimum_width, int &natural_width) const +{ + natural_width = rtengine::max(naturalWidth, 10); + minimum_width = rtengine::max(minimumWidth, 10); +} +void MyComboBox::get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const +{ + natural_width = rtengine::max(naturalWidth, 10); + minimum_width = rtengine::max(minimumWidth, 10); +} + MySpinButton::MySpinButton () { Gtk::Border border; diff --git a/rtgui/guiutils.h b/rtgui/guiutils.h index 756f78492..ff3c7f83f 100644 --- a/rtgui/guiutils.h +++ b/rtgui/guiutils.h @@ -273,7 +273,16 @@ public: */ class MyComboBox : public Gtk::ComboBox { + int naturalWidth, minimumWidth; + bool on_scroll_event (GdkEventScroll* event); + void get_preferred_width_vfunc (int &minimum_width, int &natural_width) const; + void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const; + +public: + MyComboBox (); + + void setPreferredWidth (int minimum_width, int natural_width); }; /** @@ -281,10 +290,16 @@ class MyComboBox : public Gtk::ComboBox */ class MyComboBoxText : public Gtk::ComboBoxText { + int naturalWidth, minimumWidth; + bool on_scroll_event (GdkEventScroll* event); + void get_preferred_width_vfunc (int &minimum_width, int &natural_width) const; + void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const; public: MyComboBoxText (bool has_entry = false); + + void setPreferredWidth (int minimum_width, int natural_width); }; /** diff --git a/rtgui/profilepanel.cc b/rtgui/profilepanel.cc index e87833de9..94b48e565 100644 --- a/rtgui/profilepanel.cc +++ b/rtgui/profilepanel.cc @@ -58,7 +58,6 @@ ProfilePanel::ProfilePanel () : storedPProfile(nullptr), lastFilename(""), image // Create the Combobox profiles = Gtk::manage (new ProfileStoreComboBox ()); setExpandAlignProperties(profiles, true, true, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); - profiles->set_size_request(90); load = Gtk::manage (new Gtk::Button ()); load->add (*Gtk::manage (new RTImage ("gtk-open.png"))); diff --git a/rtgui/profilestore.cc b/rtgui/profilestore.cc index 673992e97..95bc4ca68 100644 --- a/rtgui/profilestore.cc +++ b/rtgui/profilestore.cc @@ -516,6 +516,7 @@ ProfileStoreLabel::ProfileStoreLabel(const ProfileStoreEntry *entry) : Gtk::Labe ProfileStoreComboBox::ProfileStoreComboBox () { updateProfileList(); + setPreferredWidth(50, 120); Gtk::CellRendererText* cellRenderer = dynamic_cast(get_first_cell()); cellRenderer->property_ellipsize() = Pango::ELLIPSIZE_MIDDLE; cellRenderer->property_ellipsize_set() = true;