diff options
Diffstat (limited to 'src/gui/MachinaGUI.cpp')
-rw-r--r-- | src/gui/MachinaGUI.cpp | 66 |
1 files changed, 39 insertions, 27 deletions
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); |