summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-11-12 06:56:26 +0000
committerDavid Robillard <d@drobilla.net>2009-11-12 06:56:26 +0000
commit64bd557e75113743f179086b365ea7d97b72ee3e (patch)
tree6a6f5b72a8ce97616cd5ccff188f2e44e92d1ba8 /src/gui
parent023dcf4cb297928879eb0e53cf0216edb562f6fa (diff)
downloadingen-64bd557e75113743f179086b365ea7d97b72ee3e.tar.gz
ingen-64bd557e75113743f179086b365ea7d97b72ee3e.tar.bz2
ingen-64bd557e75113743f179086b365ea7d97b72ee3e.zip
String port support.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2255 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/Configuration.cpp7
-rw-r--r--src/gui/Configuration.hpp1
-rw-r--r--src/gui/ControlPanel.cpp22
-rw-r--r--src/gui/ControlPanel.hpp7
-rw-r--r--src/gui/Controls.cpp80
-rw-r--r--src/gui/Controls.hpp25
-rw-r--r--src/gui/NodeModule.cpp23
-rw-r--r--src/gui/PortMenu.cpp2
-rw-r--r--src/gui/ingen_gui.glade63
9 files changed, 206 insertions, 24 deletions
diff --git a/src/gui/Configuration.cpp b/src/gui/Configuration.cpp
index de0a0e94..c7a5b19c 100644
--- a/src/gui/Configuration.cpp
+++ b/src/gui/Configuration.cpp
@@ -41,6 +41,7 @@ Configuration::Configuration()
, _control_port_color(0x4A8A0EC0)
, _event_port_color( 0x960909C0)
// , _osc_port_color( 0x5C3566C0)
+ , _string_port_color( 0x00000000)
{
}
@@ -91,9 +92,11 @@ Configuration::get_port_color(const PortModel* p)
return _audio_port_color;
} else if (p->type().is_event()) {
return _event_port_color;
- } /*else if (p->type().is_osc()) {
+ /*} else if (p->type().is_osc()) {
return _osc_port_color;
- }*/
+ */} else if (p->type().is_string()) {
+ return _string_port_color;
+ }
cerr << "[Configuration] Unknown port type " << p->type().uri()
<< ", port will appear black." << endl;
diff --git a/src/gui/Configuration.hpp b/src/gui/Configuration.hpp
index b3d64ff8..480ed6d1 100644
--- a/src/gui/Configuration.hpp
+++ b/src/gui/Configuration.hpp
@@ -68,6 +68,7 @@ private:
uint32_t _audio_port_color;
uint32_t _control_port_color;
uint32_t _event_port_color;
+ uint32_t _string_port_color;
};
diff --git a/src/gui/ControlPanel.cpp b/src/gui/ControlPanel.cpp
index 99b66899..1e7d177b 100644
--- a/src/gui/ControlPanel.cpp
+++ b/src/gui/ControlPanel.cpp
@@ -111,22 +111,29 @@ ControlPanel::add_port(SharedPtr<PortModel> pm)
if (find_port(pm->path()) != NULL)
return;
- // Add port
- if (pm->type().is_control() && pm->is_input()) {
- Control* control = NULL;
+ Control* control = NULL;
- if (pm->is_toggle()) {
+ // Add port
+ if (pm->is_input()) {
+ if (pm->type().is_control() && pm->is_toggle()) {
ToggleControl* tc;
Glib::RefPtr<Gnome::Glade::Xml> xml = GladeFactory::new_glade_reference("toggle_control");
xml->get_widget_derived("toggle_control", tc);
control = tc;
+ } else if (pm->type().is_string()) {
+ StringControl* sc;
+ Glib::RefPtr<Gnome::Glade::Xml> xml = GladeFactory::new_glade_reference("string_control");
+ xml->get_widget_derived("string_control", sc);
+ control = sc;
} else {
SliderControl* sc;
Glib::RefPtr<Gnome::Glade::Xml> xml = GladeFactory::new_glade_reference("control_strip");
xml->get_widget_derived("control_strip", sc);
control = sc;
}
+ }
+ if (control) {
control->init(this, pm);
if (_controls.size() > 0)
@@ -223,20 +230,21 @@ ControlPanel::disable_port(const Path& path)
/** Callback for Controls to notify this of a change.
*/
void
-ControlPanel::value_changed(SharedPtr<PortModel> port, float val)
+ControlPanel::value_changed_atom(SharedPtr<PortModel> port, const Raul::Atom& val)
{
if (_callback_enabled) {
if (_all_voices_radio->get_active()) {
- App::instance().engine()->set_port_value(port->path(), Atom(val));
+ App::instance().engine()->set_port_value(port->path(), val);
port->value(val);
} else {
int voice = _voice_spinbutton->get_value_as_int();
- App::instance().engine()->set_voice_value(port->path(), voice, Atom(val));
+ App::instance().engine()->set_voice_value(port->path(), voice, val);
port->value(val);
}
}
}
+
void
ControlPanel::all_voices_selected()
{
diff --git a/src/gui/ControlPanel.hpp b/src/gui/ControlPanel.hpp
index 146173dd..375c0a72 100644
--- a/src/gui/ControlPanel.hpp
+++ b/src/gui/ControlPanel.hpp
@@ -66,7 +66,12 @@ public:
std::pair<int,int> ideal_size() const { return _ideal_size; }
// Callback for Control
- void value_changed(SharedPtr<PortModel> port_path, float val);
+ void value_changed_atom(SharedPtr<PortModel> port, const Raul::Atom& val);
+
+ template <typename T>
+ void value_changed(SharedPtr<PortModel> port, T val) {
+ this->value_changed_atom(port, Raul::Atom(val));
+ }
private:
void all_voices_selected();
diff --git a/src/gui/Controls.cpp b/src/gui/Controls.cpp
index a6a2ead3..39c18a88 100644
--- a/src/gui/Controls.cpp
+++ b/src/gui/Controls.cpp
@@ -279,7 +279,6 @@ SliderControl::update_value_from_spinner()
_control_panel->value_changed(_port_model, value);
- //m_port_model->value(value);
_enable_signal = true;
}
}
@@ -469,5 +468,84 @@ ToggleControl::toggled()
}
+// ///////////// StringControl ////////////// //
+
+
+StringControl::StringControl(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml)
+ : Control(cobject, xml)
+{
+ xml->get_widget("string_control_name_label", _name_label);
+ xml->get_widget("string_control_entry", _entry);
+}
+
+
+void
+StringControl::init(ControlPanel* panel, SharedPtr<PortModel> pm)
+{
+ _enable_signal = false;
+
+ Control::init(panel, pm);
+
+ assert(_name_label);
+ assert(_entry);
+
+ set_name(pm->path().name());
+
+ _entry->signal_activate().connect(sigc::mem_fun(*this, &StringControl::activated));
+ set_value(pm->value());
+
+ _enable_signal = true;
+ show_all();
+}
+
+
+void
+StringControl::set_name(const string& name)
+{
+ string name_label = "<span weight=\"bold\">";
+ name_label += name + "</span>";
+ _name_label->set_markup(name_label);
+}
+
+
+void
+StringControl::set_value(const Atom& val)
+{
+ _enable_signal = false;
+ if (val.type() == Atom::STRING)
+ _entry->set_text(val.get_string());
+ else
+ cerr << "ERROR: Non-string value for string port" << endl;
+ _enable_signal = true;
+}
+
+
+void
+StringControl::enable()
+{
+ _entry->property_sensitive() = true;
+ _name_label->property_sensitive() = true;
+}
+
+
+void
+StringControl::disable()
+{
+ _entry->property_sensitive() = false;
+ _name_label->property_sensitive() = false;
+}
+
+
+void
+StringControl::activated()
+{
+ if (_enable_signal) {
+ const string& value = _entry->get_text();
+ cerr << "String control activated: " << value << endl;
+ _control_panel->value_changed(_port_model, value.c_str());
+ }
+}
+
+
} // namespace GUI
} // namespace Ingen
diff --git a/src/gui/Controls.hpp b/src/gui/Controls.hpp
index 9a6a13f5..0f0dbd79 100644
--- a/src/gui/Controls.hpp
+++ b/src/gui/Controls.hpp
@@ -157,6 +157,31 @@ private:
};
+/** A text entry for string controls.
+ *
+ * \ingroup GUI
+ */
+class StringControl : public Control
+{
+public:
+ StringControl(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml);
+
+ void init(ControlPanel* panel, SharedPtr<Client::PortModel> pm);
+
+ void enable();
+ void disable();
+
+private:
+ void set_name(const std::string& name);
+ void set_value(const Raul::Atom& value);
+
+ void activated();
+
+ Gtk::Label* _name_label;
+ Gtk::Entry* _entry;
+};
+
+
} // namespace GUI
} // namespace Ingen
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index fbc89fc3..4df32263 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -144,20 +144,23 @@ NodeModule::show_human_names(bool b)
void
NodeModule::value_changed(uint32_t index, const Atom& value)
{
- float control = 0.0f;
+ if (!_plugin_ui)
+ return;
+
+ float float_val = 0.0f;
+ SLV2UIInstance inst = _plugin_ui->instance();
+ const LV2UI_Descriptor* ui_desc = slv2_ui_instance_get_descriptor(inst);
+ LV2UI_Handle ui = slv2_ui_instance_get_handle(inst);
+
switch (value.type()) {
case Atom::FLOAT:
- control = value.get_float();
- if (_plugin_ui) {
- SLV2UIInstance inst = _plugin_ui->instance();
- const LV2UI_Descriptor* ui_descriptor = slv2_ui_instance_get_descriptor(inst);
- LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(inst);
- if (ui_descriptor->port_event)
- ui_descriptor->port_event(ui_handle, index, 4, 0, &control);
- }
+ float_val = value.get_float();
+ if (ui_desc->port_event)
+ ui_desc->port_event(ui, index, 4, 0, &float_val);
break;
case Atom::STRING:
- cout << "Port value type is a string? (\"" << value.get_string() << "\")" << endl;
+ if (ui_desc->port_event)
+ ui_desc->port_event(ui, index, strlen(value.get_string()), 0, value.get_string());
break;
default:
break;
diff --git a/src/gui/PortMenu.cpp b/src/gui/PortMenu.cpp
index 834d1a32..c6229361 100644
--- a/src/gui/PortMenu.cpp
+++ b/src/gui/PortMenu.cpp
@@ -48,7 +48,7 @@ PortMenu::init(SharedPtr<PortModel> port, bool patch_port)
_destroy_menuitem->hide();
}
- if (port->type() == DataType::EVENT)
+ if (port->type() == DataType::EVENT || port->type() == DataType::STRING)
_polyphonic_menuitem->hide();
_enable_signal = true;
diff --git a/src/gui/ingen_gui.glade b/src/gui/ingen_gui.glade
index d1054c7e..371c7bd0 100644
--- a/src/gui/ingen_gui.glade
+++ b/src/gui/ingen_gui.glade
@@ -1230,7 +1230,7 @@
<child>
<widget class="GtkTable" id="table8">
<property name="visible">True</property>
- <property name="n_rows">5</property>
+ <property name="n_rows">6</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkVBox" id="toggle_control">
@@ -1244,7 +1244,6 @@
<widget class="GtkLabel" id="toggle_control_name_label">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="yalign">1</property>
<property name="xpad">4</property>
<property name="label" translatable="yes">&lt;b&gt;Name&lt;/b&gt;</property>
<property name="use_markup">True</property>
@@ -1715,6 +1714,66 @@
</packing>
</child>
<child>
+ <widget class="GtkVBox" id="string_control">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <widget class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="string_control_name_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">4</property>
+ <property name="label" translatable="yes">&lt;b&gt;Name&lt;/b&gt;</property>
+ <property name="use_markup">True</property>
+ <property name="single_line_mode">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <widget class="GtkEntry" id="string_control_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">&#x25CF;</property>
+ <property name="caps_lock_warning">False</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="y_padding">8</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<placeholder/>
</child>
<child>