summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-04-22 22:53:39 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-05-31 15:30:41 -0400
commita48fada3c7743824783c44e5ee04e910e80e6c4b (patch)
treea3a2c295614362bcac1f48679b626eaf3549b037
parent02f2b90e969daa81a96b07c73ba5e7e57a75f7d8 (diff)
move new fractional pane utility functions into libs/gtkmm2ext
-rw-r--r--gtk2_ardour/mixer_ui.cc27
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/utils.h3
-rw-r--r--libs/gtkmm2ext/utils.cc20
3 files changed, 27 insertions, 23 deletions
diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc
index fdd0a2b3be..90a0944df5 100644
--- a/gtk2_ardour/mixer_ui.cc
+++ b/gtk2_ardour/mixer_ui.cc
@@ -1861,25 +1861,6 @@ Mixer_UI::set_state (const XMLNode& node, int version)
return 0;
}
-float
-paned_position_as_fraction (Gtk::Paned& paned, bool h)
-{
- const guint pos = gtk_paned_get_position (const_cast<GtkPaned*>(static_cast<const Paned*>(&paned)->gobj()));
- return (double) pos / (h ? paned.get_allocation().get_height() : paned.get_allocation().get_width());
-}
-
-void
-gtk_paned_set_position_as_fraction (Gtk::Paned& paned, float fraction, bool h)
-{
- gint v = (h ? paned.get_allocation().get_height() : paned.get_allocation().get_width());
-
- if (v < 1) {
- return;
- }
-
- paned.set_position ((guint) floor (fraction * v));
-}
-
XMLNode&
Mixer_UI::get_state ()
{
@@ -1984,7 +1965,7 @@ Mixer_UI::pane_allocation_handler (Allocation& allocation, Gtk::Paned* which)
}
} else {
if ((done[0] = (allocation.get_height() > 1.0/pos))) {
- gtk_paned_set_position_as_fraction (rhs_pane1, pos, true);
+ paned_set_position_as_fraction (rhs_pane1, pos, true);
}
}
}
@@ -2007,7 +1988,7 @@ Mixer_UI::pane_allocation_handler (Allocation& allocation, Gtk::Paned* which)
}
} else {
if ((done[1] = (allocation.get_height() > 1.0/pos))) {
- gtk_paned_set_position_as_fraction (rhs_pane2, pos, true);
+ paned_set_position_as_fraction (rhs_pane2, pos, true);
}
}
}
@@ -2030,7 +2011,7 @@ Mixer_UI::pane_allocation_handler (Allocation& allocation, Gtk::Paned* which)
}
} else {
if ((done[2] = (allocation.get_width() > 1.0/pos))) {
- gtk_paned_set_position_as_fraction (list_hpane, pos, false);
+ paned_set_position_as_fraction (list_hpane, pos, false);
}
}
}
@@ -2053,7 +2034,7 @@ Mixer_UI::pane_allocation_handler (Allocation& allocation, Gtk::Paned* which)
}
} else {
if ((done[3] = (allocation.get_width() > 1.0/pos))) {
- gtk_paned_set_position_as_fraction (inner_pane, pos, false);
+ paned_set_position_as_fraction (inner_pane, pos, false);
}
}
}
diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h
index a57de26ae3..b04d59a53e 100644
--- a/libs/gtkmm2ext/gtkmm2ext/utils.h
+++ b/libs/gtkmm2ext/gtkmm2ext/utils.h
@@ -172,6 +172,9 @@ namespace Gtkmm2ext {
LIBGTKMM2EXT_API std::string markup_escape_text (std::string const& s);
LIBGTKMM2EXT_API void add_volume_shortcuts (Gtk::FileChooser& c);
+
+ LIBGTKMM2EXT_API float paned_position_as_fraction (Gtk::Paned& paned, bool h);
+ LIBGTKMM2EXT_API void paned_set_position_as_fraction (Gtk::Paned& paned, float fraction, bool h);
};
#endif /* __gtkmm2ext_utils_h__ */
diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc
index 7590ed2d78..3210e0e63d 100644
--- a/libs/gtkmm2ext/utils.cc
+++ b/libs/gtkmm2ext/utils.cc
@@ -992,3 +992,23 @@ Gtkmm2ext::add_volume_shortcuts (Gtk::FileChooser& c)
}
#endif
}
+
+float
+Gtkmm2ext::paned_position_as_fraction (Gtk::Paned& paned, bool h)
+{
+ const guint pos = gtk_paned_get_position (const_cast<GtkPaned*>(static_cast<const Gtk::Paned*>(&paned)->gobj()));
+ return (double) pos / (h ? paned.get_allocation().get_height() : paned.get_allocation().get_width());
+}
+
+void
+Gtkmm2ext::paned_set_position_as_fraction (Gtk::Paned& paned, float fraction, bool h)
+{
+ gint v = (h ? paned.get_allocation().get_height() : paned.get_allocation().get_width());
+
+ if (v < 1) {
+ return;
+ }
+
+ paned.set_position ((guint) floor (fraction * v));
+}
+