summaryrefslogtreecommitdiffstats
path: root/src/libs/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-07-26 22:18:33 +0000
committerDavid Robillard <d@drobilla.net>2007-07-26 22:18:33 +0000
commit23d74f838521320dc1682426341d1874061337a6 (patch)
tree25d26afb8f826f03d1321f425f6cc620f4bc7988 /src/libs/gui
parent3f445b19aaf42ae9442a9a7e40f95b4502f06047 (diff)
downloadingen-23d74f838521320dc1682426341d1874061337a6.tar.gz
ingen-23d74f838521320dc1682426341d1874061337a6.tar.bz2
ingen-23d74f838521320dc1682426341d1874061337a6.zip
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
Diffstat (limited to 'src/libs/gui')
-rw-r--r--src/libs/gui/PatchCanvas.cpp24
-rw-r--r--src/libs/gui/PatchView.cpp27
-rw-r--r--src/libs/gui/PatchView.hpp3
-rw-r--r--src/libs/gui/ingen_gui.glade29
4 files changed, 79 insertions, 4 deletions
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::RefPtr<Gnome::Glade::X
xml->get_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<PatchModel> 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();
}
@@ -111,6 +121,23 @@ PatchView::create(SharedPtr<PatchModel> 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()
{
if (!_enable_signal)
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 @@
<property name="expand">False</property>
</packing>
</child>
+ <child>
+ <widget class="GtkSeparatorToolItem" id="toolbutton1">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkToggleToolButton" id="patch_view_edit_mode_but">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="tooltip" translatable="yes">Enable edit mode to move objects.
+Disable edit mode to play controls.
+Hold &lt;Ctrl&gt; to play controls in either mode.</property>
+ <property name="label" translatable="yes">Edit</property>
+ <property name="stock_id">gtk-edit</property>
+ <property name="active">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -1507,6 +1531,11 @@
<widget class="GtkScrolledWindow" id="patch_view_scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_focus">True</property>
+ <property name="is_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="events">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</property>
<property name="border_width">1</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>