From 2ad7b1dab1cbbc9a35fe84ce784179d78fba3a29 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 14 Aug 2008 03:31:38 +0000 Subject: Clamp range of voice selector in node control window. Only show voice controls for polyphonic nodes (and dynamically show/hide). git-svn-id: http://svn.drobilla.net/lad/ingen@1366 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/gui/ControlPanel.cpp | 25 +++++++++++++++++++++---- src/libs/gui/ControlPanel.hpp | 1 + src/libs/gui/NodeControlWindow.cpp | 7 ++++--- src/libs/gui/WindowFactory.cpp | 2 +- 4 files changed, 27 insertions(+), 8 deletions(-) (limited to 'src/libs') diff --git a/src/libs/gui/ControlPanel.cpp b/src/libs/gui/ControlPanel.cpp index 7e82c7dc..3bd7cb2d 100644 --- a/src/libs/gui/ControlPanel.cpp +++ b/src/libs/gui/ControlPanel.cpp @@ -62,10 +62,14 @@ ControlPanel::init(SharedPtr node, uint32_t poly) assert(node != NULL); assert(poly > 0); + cout << "CONTROL PANEL " << poly << endl; + if (node->polyphonic()) { + cout << "POLY" << endl; _voice_spinbutton->set_range(0, poly - 1); _voice_control_box->show(); } else { + cout << "NO POLY" << endl; //remove(*_voice_control_box); _voice_control_box->hide(); } @@ -73,12 +77,16 @@ ControlPanel::init(SharedPtr node, uint32_t poly) for (PortModelList::const_iterator i = node->ports().begin(); i != node->ports().end(); ++i) { add_port(*i); } + + node->signal_polyphonic.connect( + sigc::mem_fun(this, &ControlPanel::polyphonic_changed)); - if (node->parent()) + if (node->parent()) { ((PatchModel*)node->parent().get())->signal_polyphony.connect( sigc::mem_fun(this, &ControlPanel::polyphony_changed)); - else + } else { cerr << "[ControlPanel] No parent, polyphonic controls disabled" << endl; + } _callback_enabled = true; } @@ -237,7 +245,7 @@ ControlPanel::value_changed(SharedPtr port, float val) sizeof(float), &val); port->value(val); } else { - int voice = _voice_spinbutton->get_value_as_int(); + int voice = _voice_spinbutton->get_value_as_int() - 1; App::instance().engine()->set_port_value_immediate(port->path(), "ingen:Float", voice, sizeof(float), &val); port->value(val); @@ -263,10 +271,19 @@ ControlPanel::specific_voice_selected() void ControlPanel::polyphony_changed(uint32_t poly) { - cerr << "POLY CHANGED" << endl; _voice_spinbutton->set_range(0, poly - 1); } + +void +ControlPanel::polyphonic_changed(bool poly) +{ + if (poly) + _voice_control_box->show(); + else + _voice_control_box->hide(); +} + } // namespace GUI } // namespace Ingen diff --git a/src/libs/gui/ControlPanel.hpp b/src/libs/gui/ControlPanel.hpp index bab865b2..b7a1c4b2 100644 --- a/src/libs/gui/ControlPanel.hpp +++ b/src/libs/gui/ControlPanel.hpp @@ -74,6 +74,7 @@ private: void all_voices_selected(); void specific_voice_selected(); void polyphony_changed(uint32_t poly); + void polyphonic_changed(bool poly); bool _callback_enabled; diff --git a/src/libs/gui/NodeControlWindow.cpp b/src/libs/gui/NodeControlWindow.cpp index 3f3ccc97..c0698230 100644 --- a/src/libs/gui/NodeControlWindow.cpp +++ b/src/libs/gui/NodeControlWindow.cpp @@ -50,11 +50,12 @@ NodeControlWindow::NodeControlWindow(SharedPtr node, uint32_t poly) Glib::RefPtr xml = GladeFactory::new_glade_reference("warehouse_win"); xml->get_widget_derived("control_panel_vbox", _control_panel); - _control_panel->reparent(*this); + show_all_children(); + _control_panel->reparent(*this); _control_panel->init(_node, poly); - - show_all_children(); + _control_panel->show(); + resize(); _callback_enabled = true; diff --git a/src/libs/gui/WindowFactory.cpp b/src/libs/gui/WindowFactory.cpp index a20b8fc9..125a242b 100644 --- a/src/libs/gui/WindowFactory.cpp +++ b/src/libs/gui/WindowFactory.cpp @@ -225,7 +225,7 @@ WindowFactory::new_control_window(SharedPtr node) { uint32_t poly = 1; if (node->polyphonic() && node->parent()) - poly = ((PatchModel*)node->parent().get())->poly(); + poly = ((PatchModel*)node->parent().get())->internal_polyphony(); NodeControlWindow* win = new NodeControlWindow(node, poly); -- cgit v1.2.1