summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-01-03 03:10:43 +0000
committerCarl Hetherington <carl@carlh.net>2011-01-03 03:10:43 +0000
commitcf45b07f73c9b2c8d19365d27b4f8f5004822095 (patch)
tree8d019dbc9b06f0e4b78eda878350c19fcda00a3d /libs
parent6ea84edab278854bca473f46639c44f494a2e1c6 (diff)
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
Diffstat (limited to 'libs')
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/trimming_bin.h24
-rw-r--r--libs/gtkmm2ext/trimming_bin.cc38
-rw-r--r--libs/gtkmm2ext/wscript1
3 files changed, 63 insertions, 0 deletions
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 <gtkmm/scrolledwindow.h>
+
+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 <iostream>
+#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'