Ensure a plugin generic UI doesn't exceed screen width
Do that by wrapping the packed controls box in a ScrolledWindow and making it request the same width than the box but capped to 90% of the screen width. Also, when the box width exceeds the maximum value, try again with one-letter automation buttons in case the reduced width avoids showing a scroll bar.
This commit is contained in:
parent
03f77792dd
commit
7033b34a65
|
@ -138,23 +138,29 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr<PluginInsert> pi, bool scrol
|
||||||
|
|
||||||
main_contents.pack_start (*constraint_hbox, false, false);
|
main_contents.pack_start (*constraint_hbox, false, false);
|
||||||
|
|
||||||
if (is_scrollable) {
|
|
||||||
Gtk::ScrolledWindow *scroller = manage (new Gtk::ScrolledWindow());
|
|
||||||
scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
|
||||||
scroller->set_name ("PluginEditor");
|
|
||||||
scroller->add (hpacker);
|
|
||||||
main_contents.pack_start (*scroller, true, true);
|
|
||||||
} else {
|
|
||||||
main_contents.pack_start (hpacker, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
pi->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&GenericPluginUI::processor_active_changed, this, boost::weak_ptr<Processor>(pi)), gui_context());
|
pi->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&GenericPluginUI::processor_active_changed, this, boost::weak_ptr<Processor>(pi)), gui_context());
|
||||||
|
|
||||||
bypass_button.set_active (!pi->enabled());
|
bypass_button.set_active (!pi->enabled());
|
||||||
|
|
||||||
|
/* ScrolledWindow will wrap hpacker in a Viewport */
|
||||||
|
scroller.add (hpacker);
|
||||||
|
Viewport* view = static_cast<Viewport*>(scroller.get_child());
|
||||||
|
view->set_shadow_type(Gtk::SHADOW_NONE);
|
||||||
|
|
||||||
|
main_contents.pack_start (scroller, true, true);
|
||||||
|
|
||||||
prefheight = 0;
|
prefheight = 0;
|
||||||
build ();
|
build ();
|
||||||
|
|
||||||
|
if (is_scrollable) {
|
||||||
|
scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
||||||
|
scroller.set_name ("PluginEditor");
|
||||||
|
} else {
|
||||||
|
scroller.signal_size_request().connect (sigc::mem_fun(*this, &GenericPluginUI::scroller_size_request));
|
||||||
|
scroller.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Listen for property changes that are not notified normally because
|
/* Listen for property changes that are not notified normally because
|
||||||
* AutomationControl has only support for numeric values currently.
|
* AutomationControl has only support for numeric values currently.
|
||||||
* The only case is Variant::PATH for now */
|
* The only case is Variant::PATH for now */
|
||||||
|
@ -172,6 +178,39 @@ GenericPluginUI::~GenericPluginUI ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GenericPluginUI::scroller_size_request (Gtk::Requisition* a)
|
||||||
|
{
|
||||||
|
Glib::RefPtr<Gdk::Screen> screen = get_screen();
|
||||||
|
if (!screen)
|
||||||
|
screen = Gdk::Screen::get_default();
|
||||||
|
|
||||||
|
int maximum_width;
|
||||||
|
{
|
||||||
|
Gdk::Rectangle monitor;
|
||||||
|
const int monitor_num = screen->get_monitor_at_window (get_window ());
|
||||||
|
screen->get_monitor_geometry (
|
||||||
|
(monitor_num < 0) ? 0 : monitor_num,
|
||||||
|
monitor);
|
||||||
|
|
||||||
|
maximum_width = monitor.get_width() * 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkRequisition request = hpacker.size_request();
|
||||||
|
|
||||||
|
if (request.width > maximum_width) {
|
||||||
|
for (vector<ControlUI*>::const_iterator cuip = input_controls.cbegin();
|
||||||
|
cuip != input_controls.cend();
|
||||||
|
++cuip) {
|
||||||
|
if (!(*cuip)->short_autostate)
|
||||||
|
set_short_autostate(*cuip, true);
|
||||||
|
}
|
||||||
|
request = hpacker.size_request();
|
||||||
|
}
|
||||||
|
|
||||||
|
a->width = min(request.width, maximum_width);
|
||||||
|
}
|
||||||
|
|
||||||
// Some functions for calculating the 'similarity' of two plugin
|
// Some functions for calculating the 'similarity' of two plugin
|
||||||
// control labels.
|
// control labels.
|
||||||
|
|
||||||
|
@ -220,7 +259,6 @@ std::size_t s1pos, s2pos, n = 0;
|
||||||
|
|
||||||
static const guint32 min_controls_per_column = 17, max_controls_per_column = 24;
|
static const guint32 min_controls_per_column = 17, max_controls_per_column = 24;
|
||||||
static const float default_similarity_threshold = 0.3;
|
static const float default_similarity_threshold = 0.3;
|
||||||
static const guint32 max_columns_for_big_autostate = 2;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GenericPluginUI::build ()
|
GenericPluginUI::build ()
|
||||||
|
@ -475,7 +513,6 @@ GenericPluginUI::automatic_layout (const std::vector<ControlUI*>& control_uis)
|
||||||
// starting a new column when necessary.
|
// starting a new column when necessary.
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
size_t columns = 1;
|
|
||||||
for (vector<ControlUI*>::iterator cuip = cui_controls_list.begin(); cuip != cui_controls_list.end(); ++cuip, ++i) {
|
for (vector<ControlUI*>::iterator cuip = cui_controls_list.begin(); cuip != cui_controls_list.end(); ++cuip, ++i) {
|
||||||
|
|
||||||
ControlUI* cui = *cuip;
|
ControlUI* cui = *cuip;
|
||||||
|
@ -495,7 +532,6 @@ GenericPluginUI::automatic_layout (const std::vector<ControlUI*>& control_uis)
|
||||||
frame->add (*box);
|
frame->add (*box);
|
||||||
hpacker.pack_start(*frame, true, true);
|
hpacker.pack_start(*frame, true, true);
|
||||||
x = 0;
|
x = 0;
|
||||||
++columns;
|
|
||||||
} else {
|
} else {
|
||||||
HSeparator *split = new HSeparator();
|
HSeparator *split = new HSeparator();
|
||||||
split->set_size_request(-1, 5);
|
split->set_size_request(-1, 5);
|
||||||
|
@ -506,14 +542,6 @@ GenericPluginUI::automatic_layout (const std::vector<ControlUI*>& control_uis)
|
||||||
box->pack_start (*cui, false, false);
|
box->pack_start (*cui, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columns > max_columns_for_big_autostate) {
|
|
||||||
for (vector<ControlUI*>::const_iterator cuip = control_uis.cbegin();
|
|
||||||
cuip != control_uis.cend();
|
|
||||||
++cuip) {
|
|
||||||
set_short_autostate(*cuip, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_scrollable) {
|
if (is_scrollable) {
|
||||||
prefheight = 30 * i;
|
prefheight = 30 * i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,6 +301,8 @@ private:
|
||||||
Gtk::FileChooserButton* widget);
|
Gtk::FileChooserButton* widget);
|
||||||
void path_property_changed (uint32_t key, const ARDOUR::Variant& value);
|
void path_property_changed (uint32_t key, const ARDOUR::Variant& value);
|
||||||
|
|
||||||
|
void scroller_size_request (Gtk::Requisition*);
|
||||||
|
Gtk::ScrolledWindow scroller;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PluginUIWindow : public ArdourWindow
|
class PluginUIWindow : public ArdourWindow
|
||||||
|
|
Loading…
Reference in New Issue
Block a user