Unify gain and draw tools.
authorDavid Robillard <d@drobilla.net>
Mon, 8 Dec 2014 00:53:46 +0000 (19:53 -0500)
committerDavid Robillard <d@drobilla.net>
Mon, 8 Dec 2014 01:37:46 +0000 (20:37 -0500)
There might be a few special cases lingering around from attempts at magic tool
business, but this seems to work fine as far as I can tell.

gtk2_ardour/audio_region_view.cc
gtk2_ardour/editing_syms.h
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_canvas.cc
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_drag.h
gtk2_ardour/editor_mouse.cc
gtk2_ardour/enums.cc

index 0a6c57bd29d93e687e1b73204ea91ebfa8a6bb70..e657b1f5e0cd9d9dd1e14b5d41580e431af37b28 100644 (file)
@@ -1050,7 +1050,7 @@ AudioRegionView::update_envelope_visibility ()
                return;
        }
 
-       if (Config->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseGain || trackview.editor().current_mouse_mode() == Editing::MouseRange ) {
+       if (Config->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseDraw || trackview.editor().current_mouse_mode() == Editing::MouseRange ) {
                gain_line->add_visibility (AutomationLine::Line);
        } else {
                gain_line->hide ();
index 12c922bc60846dccd69895a6328cde6d9174f19f..610aff2a8628979ff187d6ba7ef77aba3bf4f3c3 100644 (file)
@@ -69,7 +69,6 @@ REGIONLISTSORTTYPE(ByTimestamp)
 MOUSEMODE(MouseObject)
 MOUSEMODE(MouseRange)
 MOUSEMODE(MouseCut)
-MOUSEMODE(MouseGain)
 MOUSEMODE(MouseTimeFX)
 MOUSEMODE(MouseAudition)
 MOUSEMODE(MouseDraw)
index ce6e6b15ae5ca0a32b5617fa46a983b4b69a8a6b..0b2f091fa496d66ae431c09a1cd86f8c1bdd99aa 100644 (file)
@@ -2852,7 +2852,6 @@ Editor::setup_toolbar ()
        mouse_mode_size_group->add_widget (mouse_move_button);
        mouse_mode_size_group->add_widget (mouse_cut_button);
        mouse_mode_size_group->add_widget (mouse_select_button);
-       mouse_mode_size_group->add_widget (mouse_gain_button);
        mouse_mode_size_group->add_widget (mouse_timefx_button);
        mouse_mode_size_group->add_widget (mouse_audition_button);
        mouse_mode_size_group->add_widget (mouse_draw_button);
@@ -2892,7 +2891,6 @@ Editor::setup_toolbar ()
        }
        
        if (!ARDOUR::Profile->get_trx()) {
-               mouse_mode_hbox->pack_start (mouse_gain_button, false, false);
                mouse_mode_hbox->pack_start (mouse_timefx_button, false, false);
                mouse_mode_hbox->pack_start (mouse_audition_button, false, false);
                mouse_mode_hbox->pack_start (mouse_draw_button, false, false);
@@ -3184,8 +3182,7 @@ Editor::setup_tooltips ()
        ARDOUR_UI::instance()->set_tip (mouse_move_button, _("Object Mode (select/move Objects)"));
        ARDOUR_UI::instance()->set_tip (mouse_cut_button, _("Cut Mode (split Regions)"));
        ARDOUR_UI::instance()->set_tip (mouse_select_button, _("Range Mode (select/move Ranges)"));
-       ARDOUR_UI::instance()->set_tip (mouse_draw_button, _("Draw/Edit MIDI Notes"));
-       ARDOUR_UI::instance()->set_tip (mouse_gain_button, _("Draw Region Gain"));
+       ARDOUR_UI::instance()->set_tip (mouse_draw_button, _("Draw/Edit Gain/Notes/Automation"));
        ARDOUR_UI::instance()->set_tip (mouse_timefx_button, _("Stretch/Shrink Regions and MIDI Notes"));
        ARDOUR_UI::instance()->set_tip (mouse_audition_button, _("Listen to Specific Regions"));
        ARDOUR_UI::instance()->set_tip (internal_edit_button, _("Note Level Editing"));
index 5bb44a1abcfea2cd7006b5d70f03366b495e8e4c..a79acddbe1cf808cff598926919b4cc8866597eb 100644 (file)
@@ -1630,7 +1630,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        ArdourButton mouse_select_button;
        ArdourButton mouse_draw_button;
        ArdourButton mouse_move_button;
-       ArdourButton mouse_gain_button;
        ArdourButton mouse_timefx_button;
        ArdourButton mouse_audition_button;
        ArdourButton mouse_cut_button;
index 244b0b00e18be305fdcdcb2d4b119433b266fa43..817d69be7b54b0409b6b176503a5ff06861a1781 100644 (file)
@@ -465,11 +465,6 @@ Editor::register_actions ()
        mouse_draw_button.set_image (::get_icon("midi_tool_pencil"));
        mouse_draw_button.set_name ("mouse mode button");
 
-       act = ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-gain", _("Gain Tool"), sigc::bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain)); 
-       mouse_gain_button.set_related_action (act);
-       mouse_gain_button.set_image (::get_icon("tool_gain"));
-       mouse_gain_button.set_name ("mouse mode button");
-
        act = ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-audition", _("Audition Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));       
        mouse_audition_button.set_related_action (act);
        mouse_audition_button.set_image (::get_icon("tool_audition"));
index b1e733529eaf180f3adbc1e0590239e05b03671e..c27c0d833a33e6adda7ad77382f60915fd743a00 100644 (file)
@@ -1113,10 +1113,6 @@ Editor::which_mode_cursor () const
                mode_cursor = _cursors->midi_pencil;
                break;
 
-       case MouseGain:
-               mode_cursor = _cursors->cross_hair;
-               break;
-
        case MouseTimeFX:
                mode_cursor = _cursors->time_fx; // just use playhead
                break;
@@ -1300,12 +1296,12 @@ Editor::choose_canvas_cursor_on_entry (GdkEventCrossing* /*event*/, ItemType typ
                        break;
                }
 
-       } else if (mouse_mode == MouseGain) {
+       } else if (mouse_mode == MouseDraw) {
                
                /* ControlPointItem is not really specific to region gain mode
                   but it is the same cursor so don't worry about this for now.
                   The result is that we'll see the fader cursor if we enter
-                  non-region-gain-line control points while in MouseGain
+                  non-region-gain-line control points while in MouseDraw
                   mode, even though we can't edit them in this mode.
                */
 
index ea36be25adb61daf0f9e997ec8f07210b54c892c..3b459534f271bccdfa224efb5186ae5de6625b23 100644 (file)
@@ -3644,8 +3644,8 @@ ControlPointDrag::aborted (bool)
 bool
 ControlPointDrag::active (Editing::MouseMode m)
 {
-       if (m == Editing::MouseGain) {
-               /* always active in mouse gain */
+       if (m == Editing::MouseDraw) {
+               /* always active in mouse draw */
                return true;
        }
 
index 2f4c2f2e0d3009481c37bafaaac54cccfce18d04..78b541d4f54097ed5fadda1d5124157e3ad4fcf0 100644 (file)
@@ -154,7 +154,7 @@ public:
         *  @return true if this drag should happen in this mouse mode.
         */
        virtual bool active (Editing::MouseMode m) {
-               return (m != Editing::MouseGain);
+               return true;
        }
 
        /** @return minimum number of frames (in x) and pixels (in y) that should be considered a movement */
@@ -523,6 +523,14 @@ public:
        void finished (GdkEvent *, bool);
        void aborted (bool);
 
+       bool active (Editing::MouseMode mode) {
+               return mode == Editing::MouseDraw;
+       }
+
+       bool y_movement_matters () const {
+               return false;
+       }
+
 private:
        double y_to_region (double) const;
        framecnt_t grid_frames (framepos_t) const;
@@ -689,10 +697,6 @@ public:
        void finished (GdkEvent *, bool);
        void aborted (bool);
 
-       bool active (Editing::MouseMode) {
-               return true;
-       }
-
        bool allow_vertical_autoscroll () const {
                return false;
        }
@@ -820,10 +824,6 @@ public:
        void finished (GdkEvent *, bool);
        void aborted (bool);
 
-       bool active (Editing::MouseMode) {
-               return true;
-       }
-
 private:
 
        AutomationLine* _line;
@@ -843,10 +843,6 @@ public:
        void finished (GdkEvent *, bool);
        void aborted (bool);
 
-       bool active (Editing::MouseMode) {
-               return true;
-       }
-
 private:
 
        ArdourCanvas::Line* _line;
@@ -1054,10 +1050,6 @@ public:
                return false;
        }
 
-       bool active (Editing::MouseMode) {
-               return true;
-       }
-
 private:
        void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
         double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
index 58d9b8a874b7ce995c0c32c7f2e4600dd5bd13e8..96b2f9c6e24741a4bf168c6d2ce51221b7534938 100644 (file)
@@ -255,10 +255,6 @@ Editor::set_mouse_mode (MouseMode m, bool force)
                act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-draw"));
                break;
 
-       case MouseGain:
-               act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-gain"));
-               break;
-
        case MouseTimeFX:
                act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-timefx"));
                break;
@@ -307,10 +303,6 @@ Editor::mouse_mode_toggled (MouseMode m)
                act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-draw"));
                break;
 
-       case MouseGain:
-               act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-gain"));
-               break;
-
        case MouseTimeFX:
                act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-timefx"));
                break;
@@ -463,7 +455,6 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp
        if (((mouse_mode != MouseObject) &&
             (mouse_mode != MouseAudition || item_type != RegionItem) &&
             (mouse_mode != MouseTimeFX || item_type != RegionItem) &&
-            (mouse_mode != MouseGain) &&
             (mouse_mode != MouseDraw)) ||
            ((event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE) || event->button.button > 3) ||
            (internal_editing() && mouse_mode != MouseTimeFX)) {
@@ -750,36 +741,6 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                return true;
                break;
 
-       case MouseDraw:
-               switch (item_type) {
-               case NoteItem:
-                       /* Existing note: allow trimming/motion */
-                       if (internal_editing()) {
-                               /* trim notes if we're in internal edit mode and near the ends of the note */
-                               NoteBase* cn = reinterpret_cast<NoteBase*>(item->get_data ("notebase"));
-                               assert (cn);
-                               if (cn->big_enough_to_trim() && cn->mouse_near_ends()) {
-                                       _drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor);
-                               } else {
-                                       _drags->set (new NoteDrag (this, item), event);
-                               }
-                               return true;
-                       } 
-                       break;
-               case StreamItem:
-                       if (internal_editing()) {
-                               if (dynamic_cast<MidiTimeAxisView*> (clicked_axisview)) {
-                                       _drags->set (new RegionCreateDrag (this, item, clicked_axisview), event);
-                               }
-                               return true;
-                       }
-                       break;
-
-               default:
-                       break;
-               }
-               break;
-
        case MouseCut:
                switch (item_type) {
                case RegionItem:
@@ -985,7 +946,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                return true;
                break;
 
-       case MouseGain:
+       case MouseDraw:
                switch (item_type) {
                case GainLineItem:
                        _drags->set (new LineDrag (this, item), event);
@@ -1019,7 +980,31 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                case AutomationLineItem:
                        _drags->set (new LineDrag (this, item), event);
                        break;
-                       
+
+               case NoteItem:
+                       /* Existing note: allow trimming/motion */
+                       if (internal_editing()) {
+                               /* trim notes if we're in internal edit mode and near the ends of the note */
+                               NoteBase* cn = reinterpret_cast<NoteBase*>(item->get_data ("notebase"));
+                               assert (cn);
+                               if (cn->big_enough_to_trim() && cn->mouse_near_ends()) {
+                                       _drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor);
+                               } else {
+                                       _drags->set (new NoteDrag (this, item), event);
+                               }
+                               return true;
+                       }
+                       break;
+
+               case StreamItem:
+                       if (internal_editing()) {
+                               if (dynamic_cast<MidiTimeAxisView*> (clicked_axisview)) {
+                                       _drags->set (new RegionCreateDrag (this, item, clicked_axisview), event);
+                               }
+                               return true;
+                       }
+                       break;
+
                default:
                        break;
                }
@@ -1525,23 +1510,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                }
 
                switch (eff) {
-               case MouseObject:
                case MouseDraw:
-                       switch (item_type) {
-                       case AutomationTrackItem:
-                               atv = dynamic_cast<AutomationTimeAxisView*>(clicked_axisview);
-                               if (atv) {
-                                       bool with_guard_points = Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier);
-                                       atv->add_automation_event (event, where, event->button.y, with_guard_points);
-                               }
-                               return true;
-                               break;
-                       default:
-                               break;
-                       }
-                       break;
-
-               case MouseGain:
                        switch (item_type) {
                        case RegionItem:
                        {
@@ -1560,8 +1529,10 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
 
                        case AutomationTrackItem: {
                                bool with_guard_points = Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier);
-                               dynamic_cast<AutomationTimeAxisView*>(clicked_axisview)->
-                                       add_automation_event (event, where, event->button.y, with_guard_points);
+                               atv = dynamic_cast<AutomationTimeAxisView*>(clicked_axisview);
+                               if (atv) {
+                                       atv->add_automation_event (event, where, event->button.y, with_guard_points);
+                               }
                                return true;
                                break;
                        }
@@ -1663,7 +1634,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
 
        switch (item_type) {
        case ControlPointItem:
-               if (mouse_mode == MouseGain || mouse_mode == MouseObject) {
+               if (mouse_mode == MouseDraw || mouse_mode == MouseObject) {
                        cp = static_cast<ControlPoint*>(item->get_data ("control_point"));
                        cp->show ();
 
@@ -1675,7 +1646,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
                break;
 
        case GainLineItem:
-               if (mouse_mode == MouseGain) {
+               if (mouse_mode == MouseDraw) {
                        ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
                        if (line) {
                                line->set_outline_color (ARDOUR_UI::config()->get_EnteredGainLine());
@@ -1684,7 +1655,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
                break;
 
        case AutomationLineItem:
-               if (mouse_mode == MouseGain || mouse_mode == MouseObject) {
+               if (mouse_mode == MouseDraw || mouse_mode == MouseObject) {
                        ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
                        if (line) {
                                line->set_outline_color (ARDOUR_UI::config()->get_EnteredAutomationLine());
@@ -2453,11 +2424,6 @@ Editor::set_internal_edit (bool yn)
                        (*i)->leave_internal_edit_mode ();
                }
 
-               if (mouse_mode == MouseDraw && pre_internal_mouse_mode != MouseDraw) {
-                       /* we were drawing .. flip back to something sensible */
-                       set_mouse_mode (pre_internal_mouse_mode);
-               }
-
                set_snap_to (pre_internal_snap_type);
                set_snap_mode (pre_internal_snap_mode);
        }
index a213493d78a2ae2fe4d7c514129c4bec28f42708..f109050515df78eb04c723da9cff024b204d783d 100644 (file)
@@ -175,7 +175,6 @@ setup_gtk_ardour_enums ()
        REGISTER_ENUM (SamplesRulerItem);
        REGISTER (item_type);
 
-       REGISTER_ENUM(MouseGain);
        REGISTER_ENUM(MouseObject);
        REGISTER_ENUM(MouseRange);
        REGISTER_ENUM(MouseDraw);