From 2124952b855e093d6253bfd763cd9ebfe69e9def Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 26 Mar 2007 05:27:56 +0000 Subject: Deleting selected states with delete key. Fixed loading all states as initial. git-svn-id: http://svn.drobilla.net/lad/machina@378 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/MachinaCanvas.cpp | 1 - src/gui/MachinaGUI.cpp | 29 ++++++++++++++++++++++++++++- src/gui/MachinaGUI.hpp | 1 + src/gui/NodeView.cpp | 14 ++++++++++---- src/gui/machina.glade | 1 + 5 files changed, 40 insertions(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp index e11532e..a6a565e 100644 --- a/src/gui/MachinaCanvas.cpp +++ b/src/gui/MachinaCanvas.cpp @@ -15,7 +15,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -//#include "config.h" #include #include #include "machina/Node.hpp" diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp index 381d8f4..ffbfb5a 100644 --- a/src/gui/MachinaGUI.cpp +++ b/src/gui/MachinaGUI.cpp @@ -75,7 +75,8 @@ MachinaGUI::MachinaGUI(SharedPtr engine) xml->get_widget("arrange_but", _arrange_button); _canvas_scrolledwindow->add(*_canvas); - //m_canvas_scrolledwindow->signal_event().connect(sigc::mem_fun(_canvas, &FlowCanvas::scroll_event_handler)); + _canvas_scrolledwindow->signal_event().connect(sigc::mem_fun(this, + &MachinaGUI::scrolled_window_event)); _canvas->scroll_to(static_cast(_canvas->width()/2 - 320), static_cast(_canvas->height()/2 - 240)); // FIXME: hardcoded @@ -195,6 +196,32 @@ MachinaGUI::idle_callback() } +bool +MachinaGUI::scrolled_window_event(GdkEvent* event) +{ + if (event->type == GDK_KEY_PRESS) { + if (event->key.keyval == GDK_Delete) { + + ItemList selection = _canvas->selected_items(); + _canvas->clear_selection(); + + for (ItemList::iterator i = selection.begin(); + i != selection.end(); ++i) { + SharedPtr view = PtrCast(*i); + if (view) { + machine()->remove_node(view->node()); + _canvas->remove_item(view); + } + } + + return true; + } + } + + return false; +} + + void MachinaGUI::update_toolbar() { diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp index 3c16f86..5dd943f 100644 --- a/src/gui/MachinaGUI.hpp +++ b/src/gui/MachinaGUI.hpp @@ -71,6 +71,7 @@ protected: void zoom_changed(); bool idle_callback(); void update_toolbar(); + bool scrolled_window_event(GdkEvent* ev); void on_pane_position_changed(); void on_messages_expander_changed(); diff --git a/src/gui/NodeView.cpp b/src/gui/NodeView.cpp index be40047..6ff21ee 100644 --- a/src/gui/NodeView.cpp +++ b/src/gui/NodeView.cpp @@ -43,10 +43,16 @@ NodeView::on_double_click(GdkEventButton*) void NodeView::on_click(GdkEventButton* event) { - if (event->button == 3) { - bool is_initial = _node->is_initial(); - _node->set_initial( ! is_initial ); - set_border_width(is_initial ? 1.0 : 2.0); + if (event->state & GDK_CONTROL_MASK) { + if (event->button == 1) { + bool is_initial = _node->is_initial(); + _node->set_initial( ! is_initial ); + set_border_width(is_initial ? 1.0 : 6.0); + } else if (event->button == 3) { + bool is_selector = _node->is_selector(); + _node->set_selector( ! is_selector ); + set_border_width(is_selector ? 1.0 : 3.0); + } } } diff --git a/src/gui/machina.glade b/src/gui/machina.glade index df73a85..5b12fa1 100644 --- a/src/gui/machina.glade +++ b/src/gui/machina.glade @@ -468,6 +468,7 @@ True True True + True GTK_POLICY_ALWAYS GTK_POLICY_ALWAYS GTK_SHADOW_IN -- cgit v1.2.1