summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-25 20:40:13 +0000
committerDavid Robillard <d@drobilla.net>2010-02-25 20:40:13 +0000
commit77a9beca75debd2d87d735fc4fe847694eee6f13 (patch)
treeae03699b999e84bc4c283abfd215c8037ecddaf6 /src/gui
parente22984efe9b82ab006494aea93814a592cd44ece (diff)
downloadingen-77a9beca75debd2d87d735fc4fe847694eee6f13.tar.gz
ingen-77a9beca75debd2d87d735fc4fe847694eee6f13.tar.bz2
ingen-77a9beca75debd2d87d735fc4fe847694eee6f13.zip
Work on contexts and polymorphic ports.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2492 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/App.cpp13
-rw-r--r--src/gui/App.hpp10
-rw-r--r--src/gui/Configuration.cpp20
-rw-r--r--src/gui/ControlPanel.cpp29
-rw-r--r--src/gui/NodeControlWindow.cpp2
-rw-r--r--src/gui/NodeMenu.cpp4
-rw-r--r--src/gui/NodeModule.cpp6
-rw-r--r--src/gui/PatchCanvas.cpp7
-rw-r--r--src/gui/PatchWindow.cpp23
-rw-r--r--src/gui/Port.cpp29
-rw-r--r--src/gui/PortMenu.cpp4
11 files changed, 70 insertions, 77 deletions
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index 3bf45761..968d5940 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -30,10 +30,11 @@
#include "module/World.hpp"
#include "engine/Engine.hpp"
#include "interface/EngineInterface.hpp"
+#include "shared/runtime_paths.hpp"
+#include "shared/LV2URIMap.hpp"
#include "client/ObjectModel.hpp"
#include "client/PatchModel.hpp"
#include "client/ClientStore.hpp"
-#include "shared/runtime_paths.hpp"
#include "NodeModule.hpp"
#include "ControlPanel.hpp"
#include "SubpatchModule.hpp"
@@ -389,6 +390,16 @@ App::icon_destroyed(void* data)
}
+bool
+App::can_control(const Shared::Port* port) const
+{
+ return port->is_a(PortType::CONTROL)
+ || (port->is_a(PortType::VALUE)
+ && (port->supports(uris().object_class_float32)
+ || port->supports(uris().object_class_string)));
+}
+
+
} // namespace GUI
} // namespace Ingen
diff --git a/src/gui/App.hpp b/src/gui/App.hpp
index 78839772..3ac881f6 100644
--- a/src/gui/App.hpp
+++ b/src/gui/App.hpp
@@ -35,11 +35,13 @@ namespace Ingen {
class EngineInterface;
class ClientInterface;
class World;
+ class Port;
}
namespace Client {
+ class ClientStore;
class PatchModel;
class PluginModel;
- class ClientStore;
+ class PortModel;
class SigClientInterface;
}
namespace Serialisation {
@@ -48,6 +50,7 @@ namespace Ingen {
}
namespace Ingen {
+
namespace GUI {
class MessagesWindow;
@@ -88,6 +91,7 @@ public:
void port_activity(Port* port);
void activity_port_destroyed(Port* port);
+ bool can_control(const Shared::Port* port) const;
bool signal() const { return _enable_signal; }
bool disable_signals() { bool old = _enable_signal; _enable_signal = false; return old; }
@@ -113,8 +117,8 @@ public:
static void init(Ingen::Shared::World* world);
static void run();
- inline Ingen::Shared::World* world() { return _world; }
- inline Ingen::Shared::LV2URIMap& uris() { return *_world->uris; }
+ inline Ingen::Shared::World* world() const { return _world; }
+ inline Ingen::Shared::LV2URIMap& uris() const { return *_world->uris; }
protected:
diff --git a/src/gui/Configuration.cpp b/src/gui/Configuration.cpp
index 03f84a5a..6154de72 100644
--- a/src/gui/Configuration.cpp
+++ b/src/gui/Configuration.cpp
@@ -89,24 +89,16 @@ Configuration::get_port_color(const PortModel* p)
{
assert(p != NULL);
- if (p->type().is_control()) {
- return _control_port_color;
- } else if (p->type().is_audio()) {
+ if (p->is_a(Shared::PortType::AUDIO)) {
return _audio_port_color;
- } else if (p->type().is_events()) {
- return _event_port_color;
- /*} else if (p->type().is_osc()) {
- return _osc_port_color;
- */} else if (p->type().is_value()) {
- return _value_port_color;
- } else if (p->type().is_message()) {
+ } else if (App::instance().can_control(p)) {
+ return _control_port_color;
+ } else if (p->is_a(Shared::PortType::EVENTS) || p->is_a(Shared::PortType::MESSAGE)) {
return _event_port_color;
}
- error << "[Configuration] Unknown port type " << p->type().uri()
- << ", port will appear black." << endl;
-
- return 0x000000FF;
+ warn << "[Configuration] No known port type for " << p->path() << endl;
+ return 0x666666FF;
}
diff --git a/src/gui/ControlPanel.cpp b/src/gui/ControlPanel.cpp
index eda1adc0..c0f6d19f 100644
--- a/src/gui/ControlPanel.cpp
+++ b/src/gui/ControlPanel.cpp
@@ -16,6 +16,7 @@
*/
#include "interface/EngineInterface.hpp"
+#include "interface/PortType.hpp"
#include "shared/LV2URIMap.hpp"
#include "client/NodeModel.hpp"
#include "client/PortModel.hpp"
@@ -89,21 +90,19 @@ ControlPanel::add_port(SharedPtr<PortModel> pm)
// Add port
if (pm->is_input()) {
- if (pm->type().is_control()) {
- if (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 {
- SliderControl* sc;
- Glib::RefPtr<Gnome::Glade::Xml> xml
- = GladeFactory::new_glade_reference("control_strip");
- xml->get_widget_derived("control_strip", sc);
- control = sc;
- }
- } else if (pm->type().is_value() || pm->type().is_message()) {
+ if (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->supports(App::instance().uris().object_class_float32)) {
+ SliderControl* sc;
+ Glib::RefPtr<Gnome::Glade::Xml> xml
+ = GladeFactory::new_glade_reference("control_strip");
+ xml->get_widget_derived("control_strip", sc);
+ control = sc;
+ } else if (pm->supports(App::instance().uris().object_class_string)) {
StringControl* sc;
Glib::RefPtr<Gnome::Glade::Xml> xml
= GladeFactory::new_glade_reference("string_control");
diff --git a/src/gui/NodeControlWindow.cpp b/src/gui/NodeControlWindow.cpp
index 4fce6636..bef6f15a 100644
--- a/src/gui/NodeControlWindow.cpp
+++ b/src/gui/NodeControlWindow.cpp
@@ -111,7 +111,7 @@ NodeControlWindow::on_show()
{
for (NodeModel::Ports::const_iterator i = _node->ports().begin();
i != _node->ports().end(); ++i)
- if ((*i)->type().is_control() && (*i)->is_input())
+ if ((*i)->is_input() && App::instance().can_control(i->get()))
App::instance().engine()->request_property((*i)->path(),
App::instance().uris().ingen_value);
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp
index be5d645b..faa61b56 100644
--- a/src/gui/NodeMenu.cpp
+++ b/src/gui/NodeMenu.cpp
@@ -149,7 +149,7 @@ NodeMenu::on_menu_randomize()
const NodeModel* const nm = (NodeModel*)_object.get();
for (NodeModel::Ports::const_iterator i = nm->ports().begin(); i != nm->ports().end(); ++i) {
- if ((*i)->is_input() && (*i)->type().is_control()) {
+ if ((*i)->is_input() && App::instance().can_control(i->get())) {
float min = 0.0f, max = 1.0f;
nm->port_value_range(*i, min, max);
const float val = ((rand() / (float)RAND_MAX) * (max - min) + min);
@@ -209,7 +209,7 @@ NodeMenu::has_control_inputs()
{
const NodeModel* const nm = (NodeModel*)_object.get();
for (NodeModel::Ports::const_iterator i = nm->ports().begin(); i != nm->ports().end(); ++i)
- if ((*i)->is_input() && (*i)->type().is_control())
+ if ((*i)->is_input() && (*i)->is_numeric())
return true;
return false;
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index 03182942..30762f99 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -222,7 +222,7 @@ NodeModule::embed_gui(bool embed)
for (NodeModel::Ports::const_iterator p = _node->ports().begin();
p != _node->ports().end(); ++p)
- if ((*p)->type().is_control() && (*p)->is_output())
+ if ((*p)->is_output() && App::instance().can_control(p->get()))
App::instance().engine()->set_property((*p)->path(), uris.ingen_broadcast, true);
}
@@ -232,7 +232,7 @@ NodeModule::embed_gui(bool embed)
_plugin_ui.reset();
for (NodeModel::Ports::const_iterator p = _node->ports().begin(); p != _node->ports().end(); ++p)
- if ((*p)->type().is_control() && (*p)->is_output())
+ if ((*p)->is_output() && App::instance().can_control(p->get()))
App::instance().engine()->set_property((*p)->path(), uris.ingen_broadcast, false);
}
@@ -351,7 +351,7 @@ NodeModule::set_control_values()
{
uint32_t index=0;
for (NodeModel::Ports::const_iterator p = _node->ports().begin(); p != _node->ports().end(); ++p) {
- if ((*p)->type().is_control())
+ if (App::instance().can_control(p->get()))
value_changed(index, (*p)->value());
++index;
}
diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp
index 83e921b3..69cb0414 100644
--- a/src/gui/PatchCanvas.cpp
+++ b/src/gui/PatchCanvas.cpp
@@ -499,12 +499,7 @@ PatchCanvas::connect(boost::shared_ptr<FlowCanvas::Connectable> src_port,
if (!src || !dst)
return;
- // Midi binding/learn shortcut
- if (src->model()->type().is_events() && dst->model()->type().is_control()) {
- LOG(error) << "TODO: MIDI binding shortcut" << endl;
- } else {
- App::instance().engine()->connect(src->model()->path(), dst->model()->path());
- }
+ App::instance().engine()->connect(src->model()->path(), dst->model()->path());
}
diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp
index d4fb24cc..27e2737e 100644
--- a/src/gui/PatchWindow.cpp
+++ b/src/gui/PatchWindow.cpp
@@ -237,7 +237,7 @@ PatchWindow::set_patch(SharedPtr<PatchModel> patch, SharedPtr<PatchView> view)
for (NodeModel::Ports::const_iterator p = patch->ports().begin();
p != patch->ports().end(); ++p) {
- if ((*p)->type().is_control() && (*p)->is_input()) {
+ if (App::instance().can_control(p->get())) {
_menu_view_control_window->property_sensitive() = true;
break;
}
@@ -266,7 +266,7 @@ PatchWindow::set_patch(SharedPtr<PatchModel> patch, SharedPtr<PatchView> view)
void
PatchWindow::patch_port_added(SharedPtr<PortModel> port)
{
- if (port->type().is_control() && port->is_input()) {
+ if (port->is_input() && App::instance().can_control(port.get())) {
_menu_view_control_window->property_sensitive() = true;
}
}
@@ -275,19 +275,18 @@ PatchWindow::patch_port_added(SharedPtr<PortModel> port)
void
PatchWindow::patch_port_removed(SharedPtr<PortModel> port)
{
- if (port->type().is_control() && port->is_input()) {
-
- bool found_control = false;
+ if (!(port->is_input() && App::instance().can_control(port.get())))
+ return;
- for (NodeModel::Ports::const_iterator i = _patch->ports().begin(); i != _patch->ports().end(); ++i) {
- if ((*i)->type().is_control() && (*i)->is_input()) {
- found_control = true;
- break;
- }
+ for (NodeModel::Ports::const_iterator i = _patch->ports().begin();
+ i != _patch->ports().end(); ++i) {
+ if ((*i)->is_input() && App::instance().can_control(i->get())) {
+ _menu_view_control_window->property_sensitive() = true;
+ return;
}
-
- _menu_view_control_window->property_sensitive() = found_control;
}
+
+ _menu_view_control_window->property_sensitive() = false;
}
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index e353190d..4e1a5460 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -89,7 +89,7 @@ Port::Port(
pm->signal_moved.connect(sigc::mem_fun(this, &Port::moved));
- if (pm->type().is_control()) {
+ if (App::instance().can_control(pm.get())) {
set_toggled(pm->is_toggle());
show_control();
pm->signal_property.connect(sigc::mem_fun(this, &Port::property_changed));
@@ -114,7 +114,7 @@ void
Port::update_metadata()
{
SharedPtr<PortModel> pm = _port_model.lock();
- if (pm && pm->type().is_control()) {
+ if (App::instance().can_control(pm.get()) && pm->is_numeric()) {
boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(pm->parent());
if (parent) {
float min = 0.0f;
@@ -191,22 +191,15 @@ Port::set_control(float value, bool signal)
if (signal) {
App& app = App::instance();
Ingen::Shared::World* const world = app.world();
- if (model()->type() == PortType::CONTROL) {
- app.engine()->set_property(model()->path(),
- world->uris->ingen_value, Atom(value));
- PatchWindow* pw = app.window_factory()->patch_window(
- PtrCast<PatchModel>(model()->parent()));
- if (!pw)
- pw = app.window_factory()->patch_window(
- PtrCast<PatchModel>(model()->parent()->parent()));
- if (pw)
- pw->show_port_status(model().get(), value);
-
- } else if (model()->type() == PortType::EVENTS) {
- app.engine()->set_property(model()->path(),
- world->uris->ingen_value,
- Atom("http://example.org/ev#BangEvent", 0, NULL));
- }
+ app.engine()->set_property(model()->path(),
+ world->uris->ingen_value, Atom(value));
+ PatchWindow* pw = app.window_factory()->patch_window(
+ PtrCast<PatchModel>(model()->parent()));
+ if (!pw)
+ pw = app.window_factory()->patch_window(
+ PtrCast<PatchModel>(model()->parent()->parent()));
+ if (pw)
+ pw->show_port_status(model().get(), value);
}
FlowCanvas::Port::set_control(value);
diff --git a/src/gui/PortMenu.cpp b/src/gui/PortMenu.cpp
index b9c538e1..6e15cc9a 100644
--- a/src/gui/PortMenu.cpp
+++ b/src/gui/PortMenu.cpp
@@ -61,10 +61,10 @@ PortMenu::init(SharedPtr<PortModel> port, bool patch_port)
_destroy_menuitem->hide();
}
- if (port->type() == PortType::EVENTS)
+ if (port->is_a(PortType::EVENTS))
_polyphonic_menuitem->hide();
- if (port->type() == PortType::CONTROL) {
+ if (App::instance().can_control(port.get()) && port->is_numeric()) {
_learn_menuitem->show();
_unlearn_menuitem->show();