From 23d74f838521320dc1682426341d1874061337a6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 26 Jul 2007 22:18:33 +0000 Subject: Make canvas grab events. Remove silly ctrl+click zoom event grabs. Add concept of "edit mode", old behaviour = edit mode, edit mode off = no connections or module moving. git-svn-id: http://svn.drobilla.net/lad/ingen@641 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/gui/PatchCanvas.cpp | 24 ++++++++++++++++++++---- src/libs/gui/PatchView.cpp | 27 +++++++++++++++++++++++++++ src/libs/gui/PatchView.hpp | 3 +++ src/libs/gui/ingen_gui.glade | 29 +++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 4 deletions(-) (limited to 'src/libs/gui') diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp index e209a43f..cbe931ab 100644 --- a/src/libs/gui/PatchCanvas.cpp +++ b/src/libs/gui/PatchCanvas.cpp @@ -393,6 +393,8 @@ PatchCanvas::canvas_event(GdkEvent* event) { assert(event); + static bool control_modded = false; + switch (event->type) { case GDK_BUTTON_PRESS: @@ -403,11 +405,25 @@ PatchCanvas::canvas_event(GdkEvent* event) } break; - /*case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Delete) - destroy_selected(); + case GDK_KEY_PRESS: + if (event->key.keyval == GDK_Delete) { + destroy_selection(); + } else if (event->key.keyval == GDK_Control_L || event->key.keyval == GDK_Control_R) { + if (_patch->get_editable() == true) { + control_modded = true; + _patch->set_editable(false); + } + } + break; + + case GDK_KEY_RELEASE: + if (event->key.keyval == GDK_Control_L || event->key.keyval == GDK_Control_R) { + if (_patch->get_editable() == false &&control_modded) { + control_modded = false; + _patch->set_editable(true); + } + } break; - */ default: break; diff --git a/src/libs/gui/PatchView.cpp b/src/libs/gui/PatchView.cpp index 0246b98c..0a624dc0 100644 --- a/src/libs/gui/PatchView.cpp +++ b/src/libs/gui/PatchView.cpp @@ -51,6 +51,7 @@ PatchView::PatchView(BaseObjectType* cobject, const Glib::RefPtrget_widget("patch_view_save_but", _save_but); xml->get_widget("patch_view_zoom_full_but", _zoom_full_but); xml->get_widget("patch_view_zoom_normal_but", _zoom_normal_but); + xml->get_widget("patch_view_edit_mode_but", _edit_mode_but); xml->get_widget("patch_view_scrolledwindow", _canvas_scrolledwindow); } @@ -88,6 +89,15 @@ PatchView::set_patch(SharedPtr patch) _zoom_full_but->signal_clicked().connect( sigc::mem_fun(_canvas.get(), &PatchCanvas::zoom_full)); + + patch->editable_sig.connect(sigc::mem_fun( + *this, &PatchView::on_editable_sig)); + + _edit_mode_but->signal_toggled().connect(sigc::mem_fun( + *this, &PatchView::editable_toggled)); + + + _canvas->grab_focus(); } @@ -110,6 +120,23 @@ PatchView::create(SharedPtr patch) } +void +PatchView::on_editable_sig(bool editable) +{ + _edit_mode_but->set_active(editable); + _canvas->lock(!editable); +} + + +void +PatchView::editable_toggled() +{ + const bool editable = _edit_mode_but->get_active(); + _patch->set_editable(editable); + _canvas->lock(!editable); +} + + void PatchView::process_toggled() { diff --git a/src/libs/gui/PatchView.hpp b/src/libs/gui/PatchView.hpp index c3d0fc8a..dcc2ffcc 100644 --- a/src/libs/gui/PatchView.hpp +++ b/src/libs/gui/PatchView.hpp @@ -71,6 +71,8 @@ private: void process_toggled(); void clear_clicked(); void refresh_clicked(); + void on_editable_sig(bool locked); + void editable_toggled(); void enable(); void disable(); @@ -90,6 +92,7 @@ private: Gtk::ToolButton* _save_but; Gtk::ToolButton* _zoom_normal_but; Gtk::ToolButton* _zoom_full_but; + Gtk::ToggleToolButton* _edit_mode_but; Gtk::Viewport* _breadcrumb_container; bool _enable_signal; diff --git a/src/libs/gui/ingen_gui.glade b/src/libs/gui/ingen_gui.glade index a4609be7..44ffc699 100644 --- a/src/libs/gui/ingen_gui.glade +++ b/src/libs/gui/ingen_gui.glade @@ -1491,6 +1491,30 @@ False + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Enable edit mode to move objects. +Disable edit mode to play controls. +Hold <Ctrl> to play controls in either mode. + Edit + gtk-edit + True + + + False + + False @@ -1507,6 +1531,11 @@ True True + True + True + True + True + GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK | GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK | GDK_VISIBILITY_NOTIFY_MASK | GDK_PROXIMITY_IN_MASK | GDK_PROXIMITY_OUT_MASK | GDK_SUBSTRUCTURE_MASK | GDK_SCROLL_MASK 1 GTK_SHADOW_IN -- cgit v1.2.1