Heuraka! Nightmarish rework of DnD code.
[ardour.git] / gtk2_ardour / patch_change.cc
index 530f903bad520c6266101ee143f06f087ec828d2..601011d01773da41c0dacecb5506a41f750b2eea 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)
@@ -59,9 +59,9 @@ PatchChange::PatchChange(
                parent,
                height,
                ARDOUR_UI::config()->color ("midi patch change outline"),
-               ARDOUR_UI::config()->color ("midi patch change fill"),
-               ArdourCanvas::Duple (x, y)
-               );
+               ARDOUR_UI::config()->color_mod ("midi patch change fill", "midi patch change fill"),
+               ArdourCanvas::Duple (x, y),
+               true);
        
        CANVAS_DEBUG_NAME (_flag, text);
 
@@ -158,15 +158,14 @@ 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;
        }
 
        switch (ev->type) {
        case GDK_BUTTON_PRESS:
-               if (e->current_mouse_mode() == Editing::MouseObject) {
+               if (e->current_mouse_mode() == Editing::MouseContent) {
 
                        if (Gtkmm2ext::Keyboard::is_delete_event (&ev->button)) {
 
@@ -199,13 +198,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 +214,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;