From cf45b07f73c9b2c8d19365d27b4f8f5004822095 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 3 Jan 2011 03:10:43 +0000 Subject: [PATCH] Somewhat experimental fix to try to stop the editor window jumping around on small screens. git-svn-id: svn://localhost/ardour2/branches/3.0@8412 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 6 ++-- gtk2_ardour/editor.h | 10 ++++--- libs/gtkmm2ext/gtkmm2ext/trimming_bin.h | 24 ++++++++++++++++ libs/gtkmm2ext/trimming_bin.cc | 38 +++++++++++++++++++++++++ libs/gtkmm2ext/wscript | 1 + 5 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 libs/gtkmm2ext/gtkmm2ext/trimming_bin.h create mode 100644 libs/gtkmm2ext/trimming_bin.cc diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index ab6c171411..f231a93f6a 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -612,7 +612,7 @@ Editor::Editor () Glib::PropertyProxy proxy = edit_pane.property_position(); proxy.signal_changed().connect (bind (sigc::ptr_fun (pane_size_watcher), static_cast (&edit_pane))); #endif - top_hbox.pack_start (toolbar_frame, false, true); + top_hbox.pack_start (toolbar_frame); HBox *hbox = manage (new HBox); hbox->pack_start (edit_pane, true, true); @@ -2862,9 +2862,11 @@ Editor::setup_toolbar () toolbar_base.set_name ("ToolBarBase"); toolbar_base.add (toolbar_hbox); + _toolbar_trimmer.add (toolbar_base); + toolbar_frame.set_shadow_type (SHADOW_OUT); toolbar_frame.set_name ("BaseFrame"); - toolbar_frame.add (toolbar_base); + toolbar_frame.add (_toolbar_trimmer); DPIReset.connect (sigc::mem_fun (*this, &Editor::resize_text_widgets)); } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 6d7b94d0dc..fb2361048b 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -39,9 +39,10 @@ #include #include -#include -#include -#include +#include "gtkmm2ext/selector.h" +#include "gtkmm2ext/click_box.h" +#include "gtkmm2ext/dndtreeview.h" +#include "gtkmm2ext/trimming_bin.h" #include "pbd/stateful.h" #include "pbd/signals.h" @@ -1588,7 +1589,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD Gtk::HBox toolbar_hbox; Gtk::EventBox toolbar_base; Gtk::Frame toolbar_frame; - + Gtkmm2ext::TrimmingBin _toolbar_trimmer; + /* midi toolbar */ Gtk::HBox panic_box; diff --git a/libs/gtkmm2ext/gtkmm2ext/trimming_bin.h b/libs/gtkmm2ext/gtkmm2ext/trimming_bin.h new file mode 100644 index 0000000000..4566d71cba --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/trimming_bin.h @@ -0,0 +1,24 @@ +#include + +namespace Gtkmm2ext { + +/** A somewhat specialised adaption of Gtk::ScrolledWindow which is the same, + * except that the scrollbars are never visible. It is useful for long toolbars + * which may not fit horizontally on smaller screens; it lets them extend off the + * right-hand side of the screen without causing the parent window to jump around. + * + * It is not the same as a Gtk::ScrolledWindow with policies to never display + * scrollbars, as these do not behave as we require in this case. + * + * It is hard-wired to perform as if it were a Gtk::ScrolledWindow with a + * vertical scrollbar policy of POLICY_NEVER and a horizontal policy of + * POLICY_AUTOMATIC. This could be generalised. + */ +class TrimmingBin : public Gtk::ScrolledWindow +{ +public: + void on_size_request (Gtk::Requisition *); + void on_size_allocate (Gtk::Allocation &); +}; + +} diff --git a/libs/gtkmm2ext/trimming_bin.cc b/libs/gtkmm2ext/trimming_bin.cc new file mode 100644 index 0000000000..0aba116870 --- /dev/null +++ b/libs/gtkmm2ext/trimming_bin.cc @@ -0,0 +1,38 @@ +#include +#include "gtkmm2ext/trimming_bin.h" + +using namespace std; +using namespace Gtkmm2ext; + +void +TrimmingBin::on_size_request (Gtk::Requisition* r) +{ + Gtk::ScrolledWindow::on_size_request (r); + + /* Munge the height request so that it is that of the child; + the Gtk::ScrolledWindow's request may include space for + a horizontal scrollbar, which we will never show. + */ + + Gtk::Widget* c = get_child (); + if (c && c->is_visible ()) { + Gtk::Requisition cr; + c->size_request (cr); + r->height = cr.height; + } +} + +void +TrimmingBin::on_size_allocate (Gtk::Allocation& a) +{ + /* We replace Gtk::ScrolledWindow's on_size_allocate with this + which accepts what we are given and forces the child to use + the same allocation (which may result in it being shrunk). + */ + + set_allocation (a); + Widget* c = get_child (); + if (c && c->is_visible ()) { + c->size_allocate (a); + } +} diff --git a/libs/gtkmm2ext/wscript b/libs/gtkmm2ext/wscript index 0425b66149..40896ac3ad 100644 --- a/libs/gtkmm2ext/wscript +++ b/libs/gtkmm2ext/wscript @@ -51,6 +51,7 @@ gtkmm2ext_sources = [ 'tearoff.cc', 'textviewer.cc', 'treeutils.cc', + 'trimming_bin.cc', 'utils.cc', 'version.cc', 'window_title.cc'