aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/MachinaCanvas.cpp4
-rw-r--r--src/gui/MachinaCanvas.hpp2
-rw-r--r--src/gui/MachinaGUI.cpp66
-rw-r--r--src/gui/NodeView.cpp4
4 files changed, 44 insertions, 32 deletions
diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp
index 36b39d8..6d3c2ec 100644
--- a/src/gui/MachinaCanvas.cpp
+++ b/src/gui/MachinaCanvas.cpp
@@ -82,7 +82,7 @@ MachinaCanvas::node_clicked(WeakPtr<NodeView> item, GdkEventButton* event)
}
bool
-MachinaCanvas::canvas_event(GdkEvent* event)
+MachinaCanvas::on_event(GdkEvent* event)
{
if (event->type == GDK_BUTTON_RELEASE
&& event->button.button == 3
@@ -92,7 +92,7 @@ MachinaCanvas::canvas_event(GdkEvent* event)
return true;
} else {
- return Canvas::canvas_event(event);
+ return Canvas::on_event(event);
}
}
diff --git a/src/gui/MachinaCanvas.hpp b/src/gui/MachinaCanvas.hpp
index 8eba8d2..e4b19b1 100644
--- a/src/gui/MachinaCanvas.hpp
+++ b/src/gui/MachinaCanvas.hpp
@@ -44,7 +44,7 @@ public:
MachinaGUI* app() { return _app; }
protected:
- bool canvas_event(GdkEvent* event);
+ bool on_event(GdkEvent* event);
bool node_clicked(WeakPtr<NodeView> item, GdkEventButton* ev);
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp
index 87c7807..7992111 100644
--- a/src/gui/MachinaGUI.cpp
+++ b/src/gui/MachinaGUI.cpp
@@ -224,24 +224,25 @@ MachinaGUI::idle_callback()
return true;
}
+static void
+erase_node(FlowCanvasNode* node, void* data)
+{
+ Machina::Controller* controller = (Machina::Controller*)data;
+ NodeView* const view = dynamic_cast<NodeView*>(
+ Glib::wrap(FLOW_CANVAS_NODE(node)));
+ if (view) {
+ controller->erase(view->node()->id());
+ //_engine->machine()->remove_node(view->node());
+ //_canvas->remove_item(view);
+ }
+}
+
bool
MachinaGUI::scrolled_window_event(GdkEvent* event)
{
if (event->type == GDK_KEY_PRESS) {
if (event->key.keyval == GDK_Delete) {
-
- Canvas::Items selection = _canvas->selected_items();
- _canvas->clear_selection();
-
- for (Canvas::Items::iterator i = selection.begin(); i != selection.end(); ++i) {
- NodeView* const view = dynamic_cast<NodeView*>(*i);
- if (view) {
- _controller->erase(view->node()->id());
- //_engine->machine()->remove_node(view->node());
- //_canvas->remove_item(view);
- }
- }
-
+ _canvas->for_each_selected_node(erase_node, _controller.get());
return true;
}
}
@@ -593,27 +594,38 @@ MachinaGUI::show_toolbar_toggled()
_toolbar->hide();
}
-void
-MachinaGUI::show_labels_toggled()
+static void
+show_node_label(FlowCanvasNode* node, void* data)
{
- const bool show = _menu_view_labels->get_active();
-
- for (Canvas::Items::const_iterator i = _canvas->items().begin();
- i != _canvas->items().end(); ++i) {
- NodeView* const nv = dynamic_cast<NodeView*>(*i);
- if (nv)
- nv->show_label(show);
+ bool show = *(bool*)data;
+ FlowCanvas::Node* nodemm = Glib::wrap(node);
+ NodeView* const nv = dynamic_cast<NodeView*>(nodemm);
+ if (nv) {
+ nv->show_label(show);
}
+}
- for (Canvas::Edges::const_iterator c = _canvas->edges().begin();
- c != _canvas->edges().end(); ++c) {
- EdgeView* const ev = dynamic_cast<EdgeView*>(*c);
- if (ev)
- ev->show_label(show);
+static void
+show_edge_label(FlowCanvasEdge* edge, void* data)
+{
+ bool show = *(bool*)data;
+ FlowCanvas::Edge* edgemm = Glib::wrap(edge);
+ EdgeView* const ev = dynamic_cast<EdgeView*>(edgemm);
+ if (ev) {
+ ev->show_label(show);
}
}
void
+MachinaGUI::show_labels_toggled()
+{
+ bool show = _menu_view_labels->get_active();
+
+ _canvas->for_each_node(show_node_label, &show);
+ _canvas->for_each_edge(show_edge_label, &show);
+}
+
+void
MachinaGUI::menu_help_about()
{
_about_window->set_transient_for(*_main_window);
diff --git a/src/gui/NodeView.cpp b/src/gui/NodeView.cpp
index 5aadde1..71852ab 100644
--- a/src/gui/NodeView.cpp
+++ b/src/gui/NodeView.cpp
@@ -102,13 +102,13 @@ NodeView::show_label(bool show)
if (_enter_action) {
Raul::Atom note_number = _enter_action->get(URIs::instance().machina_note_number);
if (note_number.is_valid()) {
- set_name(midi_note_name(note_number.get_int32()));
+ set_label(midi_note_name(note_number.get_int32()).c_str());
return;
}
}
}
- set_name("");
+ set_label("");
}
void