summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-06-09 19:58:15 +0000
committerDavid Robillard <d@drobilla.net>2008-06-09 19:58:15 +0000
commit2b662dd993c1cce712148765c953dfaf92390a01 (patch)
tree57d422f94026cc45507ab44948032c93a7f7bf37 /src
parentdf38131db2c4eb5c83655d848a9776faa79331ca (diff)
downloadingen-2b662dd993c1cce712148765c953dfaf92390a01.tar.gz
ingen-2b662dd993c1cce712148765c953dfaf92390a01.tar.bz2
ingen-2b662dd993c1cce712148765c953dfaf92390a01.zip
Fix Ctrl 'editable' patch modifier (for control twiddling) ceasing to work in various scenarios (ticket #120).
git-svn-id: http://svn.drobilla.net/lad/ingen@1259 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/libs/gui/PatchCanvas.cpp48
-rw-r--r--src/libs/gui/PatchCanvas.hpp2
-rw-r--r--src/libs/gui/PatchWindow.cpp30
-rw-r--r--src/libs/gui/PatchWindow.hpp1
4 files changed, 61 insertions, 20 deletions
diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp
index b26c5737..a787b1ae 100644
--- a/src/libs/gui/PatchCanvas.cpp
+++ b/src/libs/gui/PatchCanvas.cpp
@@ -447,7 +447,7 @@ PatchCanvas::canvas_event(GdkEvent* event)
{
assert(event);
- static bool control_modded = false;
+ bool ret = false;
switch (event->type) {
@@ -456,34 +456,58 @@ PatchCanvas::canvas_event(GdkEvent* event)
_last_click_x = (int)event->button.x;
_last_click_y = (int)event->button.y;
show_menu(event);
+ ret = true;
}
break;
case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_Delete) {
+ case GDK_KEY_RELEASE:
+ ret = canvas_key_event(&event->key);
+
+ default:
+ break;
+ }
+
+ return (ret ? true : Canvas::canvas_event(event));
+}
+
+
+bool
+PatchCanvas::canvas_key_event(GdkEventKey* event)
+{
+ static bool control_modded = false;
+
+ switch (event->type) {
+ case GDK_KEY_PRESS:
+ switch (event->keyval) {
+ case GDK_Delete:
destroy_selection();
- } else if (event->key.keyval == GDK_Control_L || event->key.keyval == GDK_Control_R) {
+ return true;
+ case GDK_Control_L:
+ case GDK_Control_R:
if (_patch->get_editable() == true) {
control_modded = true;
_patch->set_editable(false);
}
+ return true;
+ default:
+ return 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) {
+ switch (event->keyval) {
+ case GDK_Control_L:
+ case GDK_Control_R:
+ if (_patch->get_editable() == false && control_modded) {
control_modded = false;
_patch->set_editable(true);
}
+ return true;
+ default:
+ return false;
}
- break;
-
default:
- break;
+ return false;
}
-
- return Canvas::canvas_event(event);
}
diff --git a/src/libs/gui/PatchCanvas.hpp b/src/libs/gui/PatchCanvas.hpp
index dfebab7e..bb766314 100644
--- a/src/libs/gui/PatchCanvas.hpp
+++ b/src/libs/gui/PatchCanvas.hpp
@@ -82,6 +82,8 @@ public:
void show_menu(GdkEvent* event)
{ _menu->popup(event->button.button, event->button.time); }
+ bool canvas_key_event(GdkEventKey* event);
+
private:
enum ControlType { NUMBER, BUTTON };
void menu_add_control(ControlType type);
diff --git a/src/libs/gui/PatchWindow.cpp b/src/libs/gui/PatchWindow.cpp
index 84c60fc9..865cc9eb 100644
--- a/src/libs/gui/PatchWindow.cpp
+++ b/src/libs/gui/PatchWindow.cpp
@@ -419,17 +419,31 @@ PatchWindow::on_hide()
bool
PatchWindow::on_key_press_event(GdkEventKey* event)
{
- if (event->keyval == GDK_Delete) {
- if (_view) {
- _view->canvas()->destroy_selection();
- }
- return true;
- } else {
- return Gtk::Window::on_key_press_event(event);
- }
+ bool ret = false;
+
+ ret = _view->canvas()->canvas_key_event(event);
+
+ if (!ret)
+ ret = Gtk::Window::on_key_press_event(event);
+
+ return ret;
}
+
+bool
+PatchWindow::on_key_release_event(GdkEventKey* event)
+{
+ bool ret = false;
+
+ ret = _view->canvas()->canvas_key_event(event);
+
+ if (!ret)
+ ret = Gtk::Window::on_key_release_event(event);
+
+ return ret;
+}
+
void
PatchWindow::event_quit()
{
diff --git a/src/libs/gui/PatchWindow.hpp b/src/libs/gui/PatchWindow.hpp
index 5120ba5a..def419fe 100644
--- a/src/libs/gui/PatchWindow.hpp
+++ b/src/libs/gui/PatchWindow.hpp
@@ -77,6 +77,7 @@ protected:
void on_show();
void on_hide();
bool on_key_press_event(GdkEventKey* event);
+ bool on_key_release_event(GdkEventKey* event);
private: