Accommodate recently introduced source(s) in our MSVC project (gtkmm2ext)
[ardour.git] / libs / gtkmm2ext / utils.cc
index 7590ed2d78c674ccda81d466d4839a000ff4f4ab..3210e0e63d5503e9a4625cd3e6c9abc42c9fe31e 100644 (file)
@@ -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));
+}
+