add back-pointer to TempoMap from points, and push dirty=true into map
[ardour.git] / gtk2_ardour / editor_mouse.cc
index 2348ef7ba57dd40318b5ebbdbfff2ab920d0f0fa..21ace734c2fe71d46fe2a3cd4aee9d724d7d80a5 100644 (file)
@@ -46,6 +46,8 @@
 #include "ardour/session.h"
 #include "ardour/types.h"
 
+#include "widgets/prompter.h"
+
 #include "actions.h"
 #include "ardour_ui.h"
 #include "editor.h"
@@ -58,7 +60,6 @@
 #include "region_gain_line.h"
 #include "automation_time_axis.h"
 #include "control_point.h"
-#include "prompter.h"
 #include "selection.h"
 #include "keyboard.h"
 #include "editing.h"
@@ -85,18 +86,18 @@ bool
 Editor::mouse_frame (framepos_t& where, bool& in_track_canvas) const
 {
         /* gdk_window_get_pointer() has X11's XQueryPointer semantics in that it only
-           pays attentions to subwindows. this means that menu windows are ignored, and
-           if the pointer is in a menu, the return window from the call will be the
-           the regular subwindow *under* the menu.
-
-           this matters quite a lot if the pointer is moving around in a menu that overlaps
-           the track canvas because we will believe that we are within the track canvas
-           when we are not. therefore, we track enter/leave events for the track canvas
-           and allow that to override the result of gdk_window_get_pointer().
+          pays attentions to subwindows. this means that menu windows are ignored, and
+          if the pointer is in a menu, the return window from the call will be the
+          the regular subwindow *under* the menu.
+
+          this matters quite a lot if the pointer is moving around in a menu that overlaps
+          the track canvas because we will believe that we are within the track canvas
+          when we are not. therefore, we track enter/leave events for the track canvas
+          and allow that to override the result of gdk_window_get_pointer().
         */
 
         if (!within_track_canvas) {
-                return false;
+               return false;
         }
 
        int x, y;
@@ -1300,7 +1301,7 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp
                break;
 
        default:
-                return button_press_dispatch (&event->button);
+               return button_press_dispatch (&event->button);
                break;
 
        }
@@ -1342,24 +1343,24 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                return true;
        }
 
-        bool were_dragging = false;
+       bool were_dragging = false;
 
        if (!Keyboard::is_context_menu_event (&event->button)) {
 
-                /* see if we're finishing a drag */
+               /* see if we're finishing a drag */
 
-                if (_drags->active ()) {
-                        bool const r = _drags->end_grab (event);
-                        if (r) {
-                                /* grab dragged, so do nothing else */
-                                return true;
-                        }
+               if (_drags->active ()) {
+                       bool const r = _drags->end_grab (event);
+                       if (r) {
+                               /* grab dragged, so do nothing else */
+                               return true;
+                       }
 
-                        were_dragging = true;
-                }
+                       were_dragging = true;
+               }
 
-                update_region_layering_order_editor ();
-        }
+               update_region_layering_order_editor ();
+       }
 
        /* edit events get handled here */
 
@@ -1584,14 +1585,14 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                        return true;
                case TempoBarItem:
                case TempoCurveItem:
-                       if (!_dragging_playhead) {
+                       if (!_dragging_playhead && Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
                                snap_to_with_modifier (where, event);
                                mouse_add_new_tempo_event (where.frame);
                        }
                        return true;
 
                case MeterBarItem:
-                       if (!_dragging_playhead) {
+                       if (!_dragging_playhead && Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
                                mouse_add_new_meter_event (pixel_to_sample (event->button.x));
                        }
                        return true;
@@ -1661,7 +1662,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
 
                }
 
-                /* do any (de)selection operations that should occur on button release */
+               /* do any (de)selection operations that should occur on button release */
                button_selection (item, event, item_type);
 
                return true;
@@ -1722,7 +1723,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
        MeterMarker* m_marker = 0;
        TempoMarker* t_marker = 0;
        double fraction;
-        bool ret = true;
+       bool ret = true;
 
        /* by the time we reach here, entered_regionview and entered trackview
         * will have already been set as appropriate. Things are done this
@@ -2159,12 +2160,8 @@ Editor::edit_notes (MidiRegionView* mrv)
 void
 Editor::note_edit_done (int r, EditNoteDialog* d)
 {
-       begin_reversible_command (_("edit note(s)"));
-
        d->done (r);
        delete d;
-
-       commit_reversible_command();
 }
 
 void
@@ -2210,10 +2207,6 @@ Editor::region_view_item_click (AudioRegionView& rv, GdkEventButton* event)
        if (Keyboard::modifier_state_contains (event->state, Keyboard::PrimaryModifier)) {
                TimeAxisView* tv = &rv.get_time_axis_view();
                RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(tv);
-               double speed = 1.0;
-               if (rtv && rtv->is_track()) {
-                       speed = rtv->track()->speed();
-               }
 
                framepos_t where = get_preferred_edit_position();
 
@@ -2221,15 +2214,15 @@ Editor::region_view_item_click (AudioRegionView& rv, GdkEventButton* event)
 
                        if (Keyboard::modifier_state_equals (event->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::SecondaryModifier))) {
 
-                               align_region (rv.region(), SyncPoint, (framepos_t) (where * speed));
+                               align_region (rv.region(), SyncPoint, where);
 
                        } else if (Keyboard::modifier_state_equals (event->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
 
-                               align_region (rv.region(), End, (framepos_t) (where * speed));
+                               align_region (rv.region(), End, where);
 
                        } else {
 
-                               align_region (rv.region(), Start, (framepos_t) (where * speed));
+                               align_region (rv.region(), Start, where);
                        }
                }
        }
@@ -2352,7 +2345,7 @@ Editor::mouse_rename_region (ArdourCanvas::Item* /*item*/, GdkEvent* /*event*/)
 {
        using namespace Gtkmm2ext;
 
-       ArdourPrompter prompter (false);
+       ArdourWidgets::Prompter prompter (false);
 
        prompter.set_prompt (_("Name for region:"));
        prompter.set_initial_text (clicked_regionview->region()->name());
@@ -2405,11 +2398,10 @@ Editor::mouse_brush_insert_region (RegionView* rv, framepos_t pos)
        }
 
        boost::shared_ptr<Playlist> playlist = rtv->playlist();
-       double speed = rtv->track()->speed();
 
        playlist->clear_changes ();
        boost::shared_ptr<Region> new_region (RegionFactory::create (rv->region(), true));
-       playlist->add_region (new_region, (framepos_t) (pos * speed));
+       playlist->add_region (new_region, pos);
        _session->add_command (new StatefulDiffCommand (playlist));
 
        // playlist is frozen, so we have to update manually XXX this is disgusting