fix 1024px width layout (remove nudge clock special case)
[ardour.git] / gtk2_ardour / editor.cc
index 8ea9dd2f9aea389ae215d8ceff19e1f92331194d..534dd26ddbbce551b7638db58fabdf9b51a13a65 100644 (file)
@@ -410,7 +410,7 @@ Editor::Editor ()
 
        samples_per_pixel = 2048; /* too early to use reset_zoom () */
 
-       timebar_height = std::max(12., ceil (15. * ARDOUR_UI::config()->get_font_scale() / 102400.));
+       timebar_height = std::max(12., ceil (15. * ARDOUR_UI::ui_scale));
        TimeAxisView::setup_sizes ();
        Marker::setup_sizes (timebar_height);
 
@@ -695,10 +695,10 @@ Editor::Editor ()
        /* nudge stuff */
 
        nudge_forward_button.set_name ("nudge button");
-       nudge_forward_button.set_image(::get_icon("nudge_right"));
+       nudge_forward_button.set_icon(ArdourIcon::NudgeRight);
 
        nudge_backward_button.set_name ("nudge button");
-       nudge_backward_button.set_image(::get_icon("nudge_left"));
+       nudge_backward_button.set_icon(ArdourIcon::NudgeLeft);
 
        fade_context_menu.set_name ("ArdourContextMenu");
 
@@ -1796,10 +1796,18 @@ Editor::add_region_context_items (Menu_Helpers::MenuList& edit_items, boost::sha
                _popup_region_menu_item->set_label (menu_item_name);
        }
 
-       const framepos_t position = get_preferred_edit_position (false, true);
+       /* No latering allowed in later is higher layering model */
+       RefPtr<Action> act = ActionManager::get_action (X_("EditorMenu"), X_("RegionMenuLayering"));
+       if (act && Config->get_layer_model() == LaterHigher) {
+               act->set_sensitive (false);
+       } else if (act) {
+               act->set_sensitive (true);
+       }
+
+       const framepos_t position = get_preferred_edit_position (EDIT_IGNORE_NONE, true);
 
        edit_items.push_back (*_popup_region_menu_item);
-       if (track->playlist()->count_regions_at (position) > 1 && (layering_order_editor == 0 || !layering_order_editor->is_visible ())) {
+       if (Config->get_layer_model() == Manual && track->playlist()->count_regions_at (position) > 1 && (layering_order_editor == 0 || !layering_order_editor->is_visible ())) {
                edit_items.push_back (*manage (_region_actions->get_action ("choose-top-region-context-menu")->create_menu_item ()));
        }
        edit_items.push_back (SeparatorElem());
@@ -1916,6 +1924,7 @@ Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
        select_items.push_back (SeparatorElem());
        select_items.push_back (MenuElem (_("Set Range to Loop Range"), sigc::mem_fun(*this, &Editor::set_selection_from_loop)));
        select_items.push_back (MenuElem (_("Set Range to Punch Range"), sigc::mem_fun(*this, &Editor::set_selection_from_punch)));
+       select_items.push_back (MenuElem (_("Set Range to Selected Regions"), sigc::mem_fun(*this, &Editor::set_selection_from_region)));
        select_items.push_back (SeparatorElem());
        select_items.push_back (MenuElem (_("Select All After Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
        select_items.push_back (MenuElem (_("Select All Before Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
@@ -2124,6 +2133,7 @@ Editor::set_snap_mode (SnapMode mode)
 
        instant_save ();
 }
+
 void
 Editor::set_edit_point_preference (EditPoint ep, bool force)
 {
@@ -2587,25 +2597,28 @@ Editor::snap_to_with_modifier (framepos_t& start, GdkEvent const * event, RoundM
                return;
        }
 
-       if (Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
+       if (ArdourKeyboard::indicates_snap (event->button.state)) {
                if (_snap_mode == SnapOff) {
                        snap_to_internal (start, direction, for_mark);
                }
        } else {
                if (_snap_mode != SnapOff) {
                        snap_to_internal (start, direction, for_mark);
+               } else if (ArdourKeyboard::indicates_snap_delta (event->button.state)) {
+                       /* SnapOff, but we pressed the snap_delta modifier */
+                       snap_to_internal (start, direction, for_mark);
                }
        }
 }
 
 void
-Editor::snap_to (framepos_t& start, RoundMode direction, bool for_mark)
+Editor::snap_to (framepos_t& start, RoundMode direction, bool for_mark, bool ensure_snap)
 {
-       if (!_session || _snap_mode == SnapOff) {
+       if (!_session || (_snap_mode == SnapOff && !ensure_snap)) {
                return;
        }
 
-       snap_to_internal (start, direction, for_mark);
+       snap_to_internal (start, direction, for_mark, ensure_snap);
 }
 
 void
@@ -2675,7 +2688,7 @@ Editor::timecode_snap_to_internal (framepos_t& start, RoundMode direction, bool
 }
 
 void
-Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark)
+Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark, bool ensure_snap)
 {
        const framepos_t one_second = _session->frame_rate();
        const framepos_t one_minute = _session->frame_rate() * 60;
@@ -2845,6 +2858,10 @@ Editor::snap_to_internal (framepos_t& start, RoundMode direction, bool for_mark)
 
        case SnapMagnetic:
 
+               if (ensure_snap) {
+                       return;
+               }
+
                if (presnap > start) {
                        if (presnap > (start + pixel_to_sample(snap_threshold))) {
                                start = presnap;
@@ -2969,17 +2986,17 @@ Editor::setup_toolbar ()
        zoom_preset_selector.set_size_request (42, -1);
 
        zoom_in_button.set_name ("zoom button");
-       zoom_in_button.set_image(::get_icon ("zoom_in"));
+       zoom_in_button.set_icon (ArdourIcon::ZoomIn);
        act = ActionManager::get_action (X_("Editor"), X_("temporal-zoom-in"));
        zoom_in_button.set_related_action (act);
 
        zoom_out_button.set_name ("zoom button");
-       zoom_out_button.set_image(::get_icon ("zoom_out"));
+       zoom_out_button.set_icon (ArdourIcon::ZoomOut);
        act = ActionManager::get_action (X_("Editor"), X_("temporal-zoom-out"));
        zoom_out_button.set_related_action (act);
 
        zoom_out_full_button.set_name ("zoom button");
-       zoom_out_full_button.set_image(::get_icon ("zoom_full"));
+       zoom_out_full_button.set_icon (ArdourIcon::ZoomFull);
        act = ActionManager::get_action (X_("Editor"), X_("zoom-to-session"));
        zoom_out_full_button.set_related_action (act);
 
@@ -3007,12 +3024,12 @@ Editor::setup_toolbar ()
        }
 
        tav_expand_button.set_name ("zoom button");
-       tav_expand_button.set_image(::get_icon ("tav_exp"));
+       tav_expand_button.set_icon (ArdourIcon::TimeAxisExpand);
        act = ActionManager::get_action (X_("Editor"), X_("expand-tracks"));
        tav_expand_button.set_related_action (act);
 
        tav_shrink_button.set_name ("zoom button");
-       tav_shrink_button.set_image(::get_icon ("tav_shrink"));
+       tav_shrink_button.set_icon (ArdourIcon::TimeAxisShrink);
        act = ActionManager::get_action (X_("Editor"), X_("shrink-tracks"));
        tav_shrink_button.set_related_action (act);
 
@@ -3104,11 +3121,7 @@ Editor::setup_toolbar ()
 
        if (!ARDOUR::Profile->get_trx()) {
                hbox->pack_start (snap_box, false, false);
-               if ( !Profile->get_small_screen() || Profile->get_mixbus() ) {
-                       hbox->pack_start (*nudge_box, false, false);
-               } else {
-                       ARDOUR_UI::instance()->editor_transport_box().pack_start (*nudge_box, false, false);
-               }
+               hbox->pack_start (*nudge_box, false, false);
        }
        hbox->pack_start (panic_box, false, false);
 
@@ -3214,7 +3227,7 @@ Editor::setup_tooltips ()
        ARDOUR_UI::instance()->set_tip (mouse_draw_button, _("Draw Mode (draw and edit gain/notes/automation)"));
        ARDOUR_UI::instance()->set_tip (mouse_timefx_button, _("Stretch Mode (time-stretch audio and midi regions, preserving pitch)"));
        ARDOUR_UI::instance()->set_tip (mouse_audition_button, _("Audition Mode (listen to regions)"));
-       ARDOUR_UI::instance()->set_tip (mouse_content_button, _("Internal Edit Mode (edit notes and gain curves inside regions)"));
+       ARDOUR_UI::instance()->set_tip (mouse_content_button, _("Internal Edit Mode (edit notes and automation points)"));
        ARDOUR_UI::instance()->set_tip (*_group_tabs, _("Groups: click to (de)activate\nContext-click for other operations"));
        ARDOUR_UI::instance()->set_tip (nudge_forward_button, _("Nudge Region/Selection Later"));
        ARDOUR_UI::instance()->set_tip (nudge_backward_button, _("Nudge Region/Selection Earlier"));
@@ -4655,15 +4668,15 @@ Editor::sort_track_selection (TrackViewList& sel)
 }
 
 framepos_t
-Editor::get_preferred_edit_position (bool ignore_playhead, bool from_context_menu, bool from_outside_canvas)
+Editor::get_preferred_edit_position (EditIgnoreOption ignore, bool from_context_menu, bool from_outside_canvas)
 {
        bool ignored;
        framepos_t where = 0;
        EditPoint ep = _edit_point;
 
-       if(Profile->get_mixbus())
+       if (Profile->get_mixbus())
                if (ep == EditAtSelectedMarker)
-                       ep=EditAtPlayhead;
+                       ep = EditAtPlayhead;
 
        if (from_outside_canvas && (ep == EditAtMouse)) {
                ep = EditAtPlayhead;
@@ -4676,10 +4689,14 @@ Editor::get_preferred_edit_position (bool ignore_playhead, bool from_context_men
                return entered_marker->position();
        }
 
-       if (ignore_playhead && ep == EditAtPlayhead) {
+       if ( (ignore==EDIT_IGNORE_PHEAD) && ep == EditAtPlayhead) {
                ep = EditAtSelectedMarker;
        }
 
+       if ( (ignore==EDIT_IGNORE_MOUSE) && ep == EditAtMouse) {
+               ep = EditAtPlayhead;
+       }
+
        switch (ep) {
        case EditAtPlayhead:
                if (_dragging_playhead) {
@@ -4687,8 +4704,9 @@ Editor::get_preferred_edit_position (bool ignore_playhead, bool from_context_men
                                /* XXX not right but what can we do ? */
                                return 0;
                        }
-               } else
+               } else {
                        where = _session->audible_frame();
+               }
                 DEBUG_TRACE (DEBUG::CutNPaste, string_compose ("GPEP: use playhead @ %1\n", where));
                break;
 
@@ -5226,6 +5244,7 @@ void
 Editor::resume_route_redisplay ()
 {
        if (_routes) {
+               _routes->redisplay(); // queue redisplay
                _routes->resume_redisplay();
        }
 }
@@ -5665,24 +5684,15 @@ Editor::super_rapid_screen_update ()
 
                } else {
 
-                       /* don't do continuous scroll till the new position is in the rightmost quarter of the
-                          editor canvas
-                       */
-#if 0
-                       // FIXME DO SOMETHING THAT WORKS HERE - this is 2.X code
-                       double target = ((double)frame - (double)current_page_samples()/2.0) / samples_per_pixel;
-                       if (target <= 0.0) {
-                               target = 0.0;
-                       }
-                       if (fabs(target - current) < current_page_samples() / samples_per_pixel) {
-                               target = (target * 0.15) + (current * 0.85);
-                       } else {
-                               /* relax */
+                       if (!_dragging_playhead && _follow_playhead && _session->requested_return_frame() < 0 && !pending_visual_change.being_handled) {
+                               framepos_t const frame = playhead_cursor->current_frame ();
+                               double target = ((double)frame - (double)current_page_samples()/3.0);
+                               if (target <= 0.0) {
+                                       target = 0.0;
+                               }
+                               reset_x_origin (target);
                        }
 
-                       current = target;
-                       set_horizontal_position (current);
-#endif
                }
 
        }
@@ -5772,7 +5782,7 @@ Editor::show_editor_list (bool yn)
 void
 Editor::change_region_layering_order (bool from_context_menu)
 {
-       const framepos_t position = get_preferred_edit_position (false, from_context_menu);
+       const framepos_t position = get_preferred_edit_position (EDIT_IGNORE_NONE, from_context_menu);
 
        if (!clicked_routeview) {
                if (layering_order_editor) {