summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-11-17 13:54:04 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-11-17 13:54:04 +0000
commit29d677e6681b02d6940346ac88a432558b6c2a43 (patch)
tree9db8a282b8f139e90518d31e89ef1ca0f3548114
parentd0cc6edadfd793b5207a63226402eedc15f101b4 (diff)
allow use of Return, KP_Enter and more in key binding editor; better display of such bindings; potential fix for "crashes" caused by an endless loop of enter/hide events involving the verbose canvas cursor
git-svn-id: svn://localhost/ardour2/branches/3.0@6109 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/actions.cc24
-rw-r--r--gtk2_ardour/actions.h2
-rw-r--r--gtk2_ardour/canvas-noevent-text.h45
-rw-r--r--gtk2_ardour/editor.cc7
-rw-r--r--gtk2_ardour/editor.h3
-rw-r--r--gtk2_ardour/editor_canvas.cc2
-rw-r--r--gtk2_ardour/keyeditor.cc17
-rw-r--r--gtk2_ardour/utils.cc44
-rw-r--r--gtk2_ardour/utils.h1
9 files changed, 119 insertions, 26 deletions
diff --git a/gtk2_ardour/actions.cc b/gtk2_ardour/actions.cc
index b446ee8569..1d70725163 100644
--- a/gtk2_ardour/actions.cc
+++ b/gtk2_ardour/actions.cc
@@ -36,6 +36,7 @@
#include "ardour/filesystem_paths.h"
#include "ardour/rc_configuration.h"
+#include "utils.h"
#include "actions.h"
#include "i18n.h"
@@ -248,14 +249,7 @@ ActionManager::get_all_actions (vector<string>& names, vector<string>& paths, ve
paths.push_back (accel_path);
AccelKey key;
- bool known = lookup_entry (accel_path, key);
-
- if (known) {
- keys.push_back (ui_manager->get_accel_group()->name (key.get_key(), Gdk::ModifierType (key.get_mod())));
- } else {
- keys.push_back (unbound_string);
- }
-
+ keys.push_back (get_key_representation (accel_path, key));
bindings.push_back (AccelKey (key.get_key(), Gdk::ModifierType (key.get_mod())));
}
}
@@ -442,3 +436,17 @@ ActionManager::map_some_state (const char* group, const char* action, sigc::slot
}
}
}
+
+string
+ActionManager::get_key_representation (const string& accel_path, AccelKey& key)
+{
+ bool known = lookup_entry (accel_path, key);
+
+ if (known) {
+ uint32_t k = possibly_translate_legal_accelerator_to_real_key (key.get_key());
+ key = AccelKey (k, Gdk::ModifierType (key.get_mod()));
+ return ui_manager->get_accel_group()->name (key.get_key(), Gdk::ModifierType (key.get_mod()));
+ }
+
+ return unbound_string;
+}
diff --git a/gtk2_ardour/actions.h b/gtk2_ardour/actions.h
index 187168e4b4..4557e7f8c4 100644
--- a/gtk2_ardour/actions.h
+++ b/gtk2_ardour/actions.h
@@ -67,6 +67,8 @@ class ActionManager
static void set_sensitive (std::vector<Glib::RefPtr<Gtk::Action> >& actions, bool);
+ static std::string get_key_representation (const std::string& accel_path, Gtk::AccelKey& key);
+
static std::string unbound_string; /* the key string returned if an action is not bound */
static Glib::RefPtr<Gtk::UIManager> ui_manager;
diff --git a/gtk2_ardour/canvas-noevent-text.h b/gtk2_ardour/canvas-noevent-text.h
new file mode 100644
index 0000000000..e897895cf5
--- /dev/null
+++ b/gtk2_ardour/canvas-noevent-text.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2009 Paul Davis <paul@linuxaudiosystems.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __gtk2_ardour_canvas_noevent_text_h__
+#define __gtk2_ardour_canvas_noevent_text_h__
+
+#include <libgnomecanvasmm/text.h>
+#include <libgnomecanvasmm/text.h>
+
+namespace Gnome { namespace Canvas {
+
+class NoEventText : public Text
+{
+ public:
+ NoEventText(Group& parent, double x, double y, const Glib::ustring& text)
+ : Text (parent, x, y, text) {}
+ NoEventText(Group& parent)
+ : Text (parent) {}
+
+ double point_vfunc(double, double, int, int, GnomeCanvasItem**) {
+ /* return a huge value to tell the canvas that we're never the item for an event */
+ return 9999999999999.0;
+ }
+};
+
+} } /* namespaces */
+
+#endif /* __gtk2_ardour_canvas_noevent_text_h__ */
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 3bc2980e15..8ec20014b5 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -3329,13 +3329,6 @@ Editor::show_verbose_canvas_cursor_with (const string & txt)
track_canvas->get_pointer (x, y);
track_canvas->window_to_world (x, y, wx, wy);
- /* move it away from the mouse pointer to avoid an
- infinite loop of enter/leave events.
- */
-
- wx += 20;
- wy += 20;
-
/* don't get too close to the edge */
verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (wx);
verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (wy);
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 0ecef0b60a..0f5b2f3edd 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -61,6 +61,7 @@
#include "editing.h"
#include "enums.h"
#include "editor_items.h"
+#include "canvas-noevent-text.h"
#include "region_selection.h"
#include "canvas.h"
#include "editor_summary.h"
@@ -626,7 +627,7 @@ class Editor : public PublicEditor
ArdourCanvas::Canvas* track_canvas;
- ArdourCanvas::Text* verbose_canvas_cursor;
+ ArdourCanvas::NoEventText* verbose_canvas_cursor;
bool verbose_cursor_visible;
void parameter_changed (std::string);
diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc
index 9342387dbe..f3a59f2c57 100644
--- a/gtk2_ardour/editor_canvas.cc
+++ b/gtk2_ardour/editor_canvas.cc
@@ -116,7 +116,7 @@ Editor::initialize_canvas ()
Pango::FontDescription* font = get_font_for_style (N_("VerboseCanvasCursor"));
- verbose_canvas_cursor = new ArdourCanvas::Text (*track_canvas->root());
+ verbose_canvas_cursor = new ArdourCanvas::NoEventText (*track_canvas->root());
verbose_canvas_cursor->property_font_desc() = *font;
verbose_canvas_cursor->property_anchor() = ANCHOR_NW;
diff --git a/gtk2_ardour/keyeditor.cc b/gtk2_ardour/keyeditor.cc
index b909812f10..b8bfb5677b 100644
--- a/gtk2_ardour/keyeditor.cc
+++ b/gtk2_ardour/keyeditor.cc
@@ -86,6 +86,8 @@ KeyEditor::unbind ()
unbind_button.set_sensitive (false);
+ cerr << "trying to unbind\n";
+
if (i != model->children().end()) {
string path = (*i)[columns.path];
@@ -168,24 +170,21 @@ KeyEditor::on_key_release_event (GdkEventKey* ev)
goto out;
}
+ cerr << "real lkeyval: " << ev->keyval << endl;
possibly_translate_keyval_to_make_legal_accelerator (ev->keyval);
+ cerr << "using keyval = " << ev->keyval << endl;
+
bool result = AccelMap::change_entry (path,
ev->keyval,
ModifierType (Keyboard::RelevantModifierKeyMask & ev->state),
true);
+ cerr << "New binding to " << ev->keyval << " worked: " << result << endl;
+
if (result) {
- bool known;
AccelKey key;
-
- known = ActionManager::lookup_entry (path, key);
-
- if (known) {
- (*i)[columns.binding] = ActionManager::ui_manager->get_accel_group()->name (key.get_key(), Gdk::ModifierType (key.get_mod()));
- } else {
- (*i)[columns.binding] = string();
- }
+ (*i)[columns.binding] = ActionManager::get_key_representation (path, key);
}
}
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index 0f53b0912f..e50a39b397 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -879,6 +879,14 @@ possibly_translate_keyval_to_make_legal_accelerator (uint32_t& keyval)
fakekey = GDK_leftarrow;
break;
+ case GDK_Return:
+ fakekey = GDK_3270_Enter;
+ break;
+
+ case GDK_KP_Enter:
+ fakekey = GDK_F35;
+ break;
+
default:
break;
}
@@ -891,6 +899,42 @@ possibly_translate_keyval_to_make_legal_accelerator (uint32_t& keyval)
return false;
}
+uint32_t
+possibly_translate_legal_accelerator_to_real_key (uint32_t keyval)
+{
+ switch (keyval) {
+ case GDK_nabla:
+ return GDK_Tab;
+ break;
+
+ case GDK_uparrow:
+ return GDK_Up;
+ break;
+
+ case GDK_downarrow:
+ return GDK_Down;
+ break;
+
+ case GDK_rightarrow:
+ return GDK_Right;
+ break;
+
+ case GDK_leftarrow:
+ return GDK_Left;
+ break;
+
+ case GDK_3270_Enter:
+ return GDK_Return;
+
+ case GDK_F35:
+ return GDK_KP_Enter;
+ break;
+ }
+
+ return keyval;
+}
+
+
inline guint8
convert_color_channel (guint8 src,
diff --git a/gtk2_ardour/utils.h b/gtk2_ardour/utils.h
index 18c4e860b8..a7da5cc997 100644
--- a/gtk2_ardour/utils.h
+++ b/gtk2_ardour/utils.h
@@ -85,6 +85,7 @@ void set_color (Gdk::Color&, int);
bool relay_key_press (GdkEventKey* ev, Gtk::Window* win);
bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev);
bool possibly_translate_keyval_to_make_legal_accelerator (uint32_t& keyval);
+uint32_t possibly_translate_legal_accelerator_to_real_key (uint32_t keyval);
Glib::RefPtr<Gdk::Pixbuf> get_xpm (std::string);
Glib::ustring get_icon_path (const char*);