Remove internal edit mode and add "content" tool.
[ardour.git] / gtk2_ardour / patch_change.cc
index 18ef5da00434e1565eef5aa4bf015a5730c77eed..ebad5518cf5b29a212076dae1339577879b9781b 100644 (file)
 #include "canvas/debug.h"
 
 #include "ardour_ui.h"
-#include "midi_region_view.h"
-#include "patch_change.h"
 #include "editor.h"
 #include "editor_drag.h"
+#include "midi_region_view.h"
+#include "patch_change.h"
 
 using namespace MIDI::Name;
 using namespace std;
+using Gtkmm2ext::Keyboard;
 
 /** @param x x position in pixels.
  */
-PatchChange::PatchChange(
-               MidiRegionView& region,
-               ArdourCanvas::Container* parent,
-               const string&   text,
-               double          height,
-               double          x,
-               double          y,
-               ARDOUR::InstrumentInfo& info,
-               ARDOUR::MidiModel::PatchChangePtr patch)
+PatchChange::PatchChange(MidiRegionView&                   region,
+                         ArdourCanvas::Container*          parent,
+                         const string&                     text,
+                         double                            height,
+                         double                            x,
+                         double                            y,
+                         ARDOUR::InstrumentInfo&           info,
+                         ARDOUR::MidiModel::PatchChangePtr patch)
        : _region (region)
        , _info (info)
        , _patch (patch)
@@ -58,10 +58,9 @@ PatchChange::PatchChange(
        _flag = new ArdourCanvas::Flag (
                parent,
                height,
-               ARDOUR_UI::config()->get_MidiPatchChangeOutline(),
-               ARDOUR_UI::config()->get_MidiPatchChangeFill(),
-               ArdourCanvas::Duple (x, y)
-               );
+               ARDOUR_UI::config()->color ("midi patch change outline"),
+               ARDOUR_UI::config()->color_mod ("midi patch change fill", "midi patch change fill"),
+               ArdourCanvas::Duple (x, y));
        
        CANVAS_DEBUG_NAME (_flag, text);
 
@@ -158,9 +157,8 @@ PatchChange::event_handler (GdkEvent* ev)
 {
        /* XXX: icky dcast */
        Editor* e = dynamic_cast<Editor*> (&_region.get_time_axis_view().editor());
-
+       
        if (!e->internal_editing()) {
-               // not in internal edit mode, so no patch change editing
                return false;
        }
 
@@ -199,13 +197,15 @@ PatchChange::event_handler (GdkEvent* ev)
                case GDK_Up:
                case GDK_KP_Up:
                case GDK_uparrow:
-                       _region.previous_patch (*this);
-                       break;
+                       _region.step_patch(
+                               *this, Keyboard::modifier_state_contains(ev->key.state, Keyboard::TertiaryModifier), 1);
+                       return true;
                case GDK_Down:
                case GDK_KP_Down:
                case GDK_downarrow:
-                       _region.next_patch (*this);
-                       break;
+                       _region.step_patch(
+                               *this, Keyboard::modifier_state_contains(ev->key.state, Keyboard::TertiaryModifier), -1);
+                       return true;
                default:
                        break;
                }
@@ -213,10 +213,12 @@ PatchChange::event_handler (GdkEvent* ev)
 
        case GDK_SCROLL:
                if (ev->scroll.direction == GDK_SCROLL_UP) {
-                       _region.previous_patch (*this);
+                       _region.step_patch(
+                               *this, Keyboard::modifier_state_contains(ev->scroll.state, Keyboard::TertiaryModifier), 1);
                        return true;
                } else if (ev->scroll.direction == GDK_SCROLL_DOWN) {
-                       _region.next_patch (*this);
+                       _region.step_patch(
+                               *this, Keyboard::modifier_state_contains(ev->scroll.state, Keyboard::TertiaryModifier), -1);
                        return true;
                }
                break;