summaryrefslogtreecommitdiffstats
path: root/src/gui/GraphPortModule.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-03-09 08:33:21 +0100
committerDavid Robillard <d@drobilla.net>2017-03-09 08:33:21 +0100
commit83d366452af8e93f0722658d730528d699f21e2b (patch)
treedb66b0653d57ca2e2939a1352b3d45aeada4689e /src/gui/GraphPortModule.cpp
parente360392489fe62dbae1f0c28b7f5fb839851f5f6 (diff)
downloadingen-83d366452af8e93f0722658d730528d699f21e2b.tar.gz
ingen-83d366452af8e93f0722658d730528d699f21e2b.tar.bz2
ingen-83d366452af8e93f0722658d730528d699f21e2b.zip
Preliminary port groups workgroups
Diffstat (limited to 'src/gui/GraphPortModule.cpp')
-rw-r--r--src/gui/GraphPortModule.cpp90
1 files changed, 65 insertions, 25 deletions
diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp
index 7a0ce102..40851b6d 100644
--- a/src/gui/GraphPortModule.cpp
+++ b/src/gui/GraphPortModule.cpp
@@ -22,6 +22,7 @@
#include "ingen/Interface.hpp"
#include "ingen/client/BlockModel.hpp"
#include "ingen/client/GraphModel.hpp"
+#include "ingen/client/GroupModel.hpp"
#include "App.hpp"
#include "Style.hpp"
@@ -42,46 +43,74 @@ using namespace Client;
namespace GUI {
-GraphPortModule::GraphPortModule(GraphCanvas& canvas,
- SPtr<const Client::PortModel> model)
+GraphPortModule::GraphPortModule(GraphCanvas& canvas,
+ SPtr<const Client::GroupModel> gm,
+ SPtr<const Client::PortModel> pm)
: Ganv::Module(canvas, "", 0, 0, false) // FIXME: coords?
- , _model(model)
- , _port(NULL)
+ , _group(gm)
{
- assert(model);
-
- assert(dynamic_ptr_cast<const GraphModel>(model->parent()));
-
- set_stacked(model->polyphonic());
- if (model->is_input() && !model->is_numeric()) {
- set_is_source(true);
+ if (pm) {
+ set_stacked(pm->polyphonic());
+ if (pm->is_input() && !pm->is_numeric()) {
+ set_is_source(true);
+ }
}
- model->signal_property().connect(
- sigc::mem_fun(this, &GraphPortModule::property_changed));
+ if (gm) {
+ gm->signal_property().connect(
+ sigc::mem_fun(this, &GraphPortModule::property_changed));
+ } else if (pm) {
+ pm->signal_property().connect(
+ sigc::mem_fun(this, &GraphPortModule::property_changed));
+ }
signal_moved().connect(
sigc::mem_fun(this, &GraphPortModule::store_location));
}
GraphPortModule*
-GraphPortModule::create(GraphCanvas& canvas,
- SPtr<const PortModel> model)
+GraphPortModule::create(GraphCanvas& canvas,
+ SPtr<const GroupModel> gm,
+ SPtr<const PortModel> pm)
{
- GraphPortModule* ret = new GraphPortModule(canvas, model);
- Port* port = Port::create(canvas.app(), *ret, model, true);
+ GraphPortModule* ret = new GraphPortModule(canvas, gm, pm);
+
+ if (pm) {
+ Port* port = Port::create(canvas.app(), *ret, pm, true);
- ret->set_port(port);
- if (model->is_numeric()) {
- port->show_control();
+ if (pm->is_numeric()) {
+ port->show_control();
+ }
}
- for (const auto& p : model->properties())
+ for (const auto& p : ret->model()->properties()) {
ret->property_changed(p.first, p.second);
+ }
return ret;
}
+SPtr<const ObjectModel>
+GraphPortModule::model()
+{
+ if (_group) {
+ return _group;
+ } else if (Port* const port = get_port()) {
+ return port->model();
+ }
+ return SPtr<const ObjectModel>();
+}
+
+Port*
+GraphPortModule::get_port()
+{
+ if (begin() == end()) {
+ return nullptr;
+ }
+
+ return dynamic_cast<Port*>(*begin());
+}
+
App&
GraphPortModule::app() const
{
@@ -91,12 +120,18 @@ GraphPortModule::app() const
bool
GraphPortModule::show_menu(GdkEventButton* ev)
{
- return _port->show_menu(ev);
+ if (Port* const port = get_port()) {
+ return port->show_menu(ev);
+ }
+ fprintf(stderr, "ERR\n");
+ return false;
}
void
GraphPortModule::store_location(double ax, double ay)
{
+ fprintf(stderr, "FIXME\n");
+#if 0
const URIs& uris = app().uris();
const Atom x(app().forge().make(static_cast<float>(ax)));
@@ -110,24 +145,29 @@ GraphPortModule::store_location(double ax, double ay)
{{uris.ingen_canvasX, Property(x, Property::Graph::INTERNAL)},
{uris.ingen_canvasY, Property(y, Property::Graph::INTERNAL)}});
}
+#endif
}
void
GraphPortModule::show_human_names(bool b)
{
const URIs& uris = app().uris();
- const Atom& name = _model->get_property(uris.lv2_name);
+ const Atom& name = model()->get_property(uris.lv2_name);
if (b && name.type() == uris.forge.String) {
set_name(name.ptr<char>());
} else {
- set_name(_model->symbol().c_str());
+ set_name(model()->symbol().c_str());
}
}
void
GraphPortModule::set_name(const std::string& n)
{
- _port->set_label(n.c_str());
+ if (_group) {
+ set_label(n.c_str());
+ } else if (Port* port = get_port()) {
+ port->set_label(n.c_str());
+ }
}
void