aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/client/ClientObject.hpp4
-rw-r--r--src/engine/machina/URIs.hpp6
-rw-r--r--src/gui/MachinaCanvas.cpp5
-rw-r--r--src/gui/NodeView.cpp29
-rw-r--r--src/gui/NodeView.hpp2
5 files changed, 30 insertions, 16 deletions
diff --git a/src/client/ClientObject.hpp b/src/client/ClientObject.hpp
index 9850b01..658d603 100644
--- a/src/client/ClientObject.hpp
+++ b/src/client/ClientObject.hpp
@@ -47,6 +47,9 @@ public:
virtual ~View() {}
};
+ typedef std::map<URIInt, Raul::Atom> Properties;
+ const Properties& properties() { return _properties; }
+
SharedPtr<View> view() const { return _view; }
void set_view(SharedPtr<View> view) { _view = view; }
@@ -54,7 +57,6 @@ private:
uint64_t _id;
SharedPtr<View> _view;
- typedef std::map<URIInt, Raul::Atom> Properties;
Properties _properties;
};
diff --git a/src/engine/machina/URIs.hpp b/src/engine/machina/URIs.hpp
index ae6cd2f..4838761 100644
--- a/src/engine/machina/URIs.hpp
+++ b/src/engine/machina/URIs.hpp
@@ -51,9 +51,9 @@ public:
private:
URIs()
- : machina_Edge(43)
- , machina_MidiAction(43)
- , machina_Node(42)
+ : machina_Edge(100)
+ , machina_MidiAction(101)
+ , machina_Node(102)
, machina_active(1)
, machina_canvas_x(2)
, machina_canvas_y(3)
diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp
index 57cffc9..a2bb2ac 100644
--- a/src/gui/MachinaCanvas.cpp
+++ b/src/gui/MachinaCanvas.cpp
@@ -121,6 +121,11 @@ MachinaCanvas::on_new_object(SharedPtr<Client::ClientObject> object)
SharedPtr<Machina::Client::ClientObject> head = _app->client_model()->find(
object->get(uris.machina_head_id).get_int32());
+ if (!tail || !head) {
+ std::cerr << "Invalid arc" << std::endl;
+ return;
+ }
+
SharedPtr<NodeView> tail_view = PtrCast<NodeView>(tail->view());
SharedPtr<NodeView> head_view = PtrCast<NodeView>(head->view());
diff --git a/src/gui/NodeView.cpp b/src/gui/NodeView.cpp
index bf7c0b6..d388921 100644
--- a/src/gui/NodeView.cpp
+++ b/src/gui/NodeView.cpp
@@ -47,10 +47,11 @@ NodeView::NodeView(Gtk::Window* window,
sigc::mem_fun(this, &NodeView::on_property));
}
-void
+bool
NodeView::on_double_click(GdkEventButton*)
{
NodePropertiesWindow::present(_window, _node);
+ return true;
}
bool
@@ -83,6 +84,8 @@ NodeView::on_event(GdkEvent* event)
} else {
_signal_clicked.emit(&event->button);
}
+ } else if (event->type == GDK_2BUTTON_PRESS) {
+ return on_double_click(&event->button);
}
return false;
}
@@ -103,13 +106,11 @@ midi_note_name(uint8_t num)
void
NodeView::show_label(bool show)
{
- if (show) {
- if (_enter_action) {
- Raul::Atom note_number = _enter_action->get(URIs::instance().machina_note_number);
- if (note_number.is_valid()) {
- set_label(midi_note_name(note_number.get_int32()).c_str());
- return;
- }
+ if (show && _enter_action) {
+ Raul::Atom note_number = _enter_action->get(URIs::instance().machina_note_number);
+ if (note_number.is_valid()) {
+ set_label(midi_note_name(note_number.get_int32()).c_str());
+ return;
}
}
@@ -150,8 +151,13 @@ NodeView::on_property(Machina::URIInt key, const Raul::Atom& value)
MachinaCanvas* canvas = dynamic_cast<MachinaCanvas*>(this->canvas());
_enter_action_connection.disconnect();
_enter_action = canvas->app()->client_model()->find(action_id);
- _enter_action_connection = _enter_action->signal_property.connect(
- sigc::mem_fun(this, &NodeView::on_action_property));
+ if (_enter_action) {
+ _enter_action_connection = _enter_action->signal_property.connect(
+ sigc::mem_fun(this, &NodeView::on_action_property));
+ for (auto i : _enter_action->properties()) {
+ on_action_property(i.first, i.second);
+ }
+ }
} else {
cout << "Unknown property " << key << endl;
}
@@ -160,8 +166,9 @@ NodeView::on_property(Machina::URIInt key, const Raul::Atom& value)
void
NodeView::on_action_property(Machina::URIInt key, const Raul::Atom& value)
{
- if (key == URIs::instance().machina_note_number)
+ if (key == URIs::instance().machina_note_number) {
show_label(true);
+ }
}
void
diff --git a/src/gui/NodeView.hpp b/src/gui/NodeView.hpp
index eb7a61f..61e4838 100644
--- a/src/gui/NodeView.hpp
+++ b/src/gui/NodeView.hpp
@@ -48,7 +48,7 @@ public:
private:
bool on_event(GdkEvent* ev);
- void on_double_click(GdkEventButton* ev);
+ bool on_double_click(GdkEventButton* ev);
void on_property(Machina::URIInt key, const Raul::Atom& value);
void on_action_property(Machina::URIInt key, const Raul::Atom& value);
void set_selected(gboolean selected);