diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 9d806edae4..5569ea2612 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -294,6 +294,7 @@ Editor::Editor () , transport_marker_group (0) , cd_marker_group (0) , _time_markers_group (0) + , _selection_marker_group (0) , hv_scroll_group (0) , h_scroll_group (0) , cursor_scroll_group (0) @@ -6774,6 +6775,8 @@ Editor::ui_parameter_changed (string parameter) /* handled individually by each MidiRegionView */ } else if (parameter == "tempo-edit-behavior") { set_tempo_edit_behavior (UIConfiguration::instance().get_tempo_edit_behavior()); + } else if (parameter == "show-selection-marker") { + update_ruler_visibility (); } } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 06ab772133..23697498cd 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -729,6 +729,7 @@ private: void trigger_script_by_name (const std::string script_name, const std::string args = ""); void toggle_marker_lines (); void set_marker_line_visibility (bool); + void update_selection_markers (); void jump_forward_to_mark (); void jump_backward_to_mark (); @@ -930,6 +931,10 @@ private: /* parent for groups which themselves contain time markers */ ArdourCanvas::Container* _time_markers_group; + /* parent for group for selection marker (above ruler) */ + ArdourCanvas::Container* _selection_marker_group; + LocationMarkers _selection_marker; + /* The group containing all other groups that are scrolled vertically and horizontally. */ diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index a109166e31..c1c25fe91c 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -143,6 +143,12 @@ Editor::initialize_canvas () _time_markers_group = new ArdourCanvas::Container (h_scroll_group); CANVAS_DEBUG_NAME (_time_markers_group, "time bars"); + /* group above rulers, to show selection triangles */ + _selection_marker_group = new ArdourCanvas::Container (h_scroll_group); + CANVAS_DEBUG_NAME (_selection_marker_group, "Canvas Selection Ruler"); + _selection_marker.start = new SelectionMarker (*this, *_selection_marker_group, 0xff0000ff, ArdourMarker::SelectionStart); + _selection_marker.end = new SelectionMarker (*this, *_selection_marker_group, 0xff0000ff, ArdourMarker::SelectionEnd); + _selection_marker_group->raise_to_top (); /* Note that because of ascending-y-axis coordinates, this order is * bottom-to-top. But further note that the actual order is set in diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 647087154a..3282074621 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -2014,6 +2014,18 @@ Editor::find_marker_from_location_id (PBD::ID const & id, bool is_start) const return 0; } +void +Editor::update_selection_markers () +{ + timepos_t start, end; + if (get_selection_extents (start, end)) { + _selection_marker.set_position (start, end); + _selection_marker.show (); + } else { + _selection_marker.hide (); + } +} + void Editor::toggle_cue_behavior () { diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc index 5d6e74cc72..7a633d7a8e 100644 --- a/gtk2_ardour/editor_rulers.cc +++ b/gtk2_ardour/editor_rulers.cc @@ -428,6 +428,7 @@ void Editor::update_ruler_visibility () { int visible_timebars = 0; + bool have_timebar = false; if (no_ruler_shown_update) { return; @@ -466,6 +467,7 @@ Editor::update_ruler_visibility () tbpos += timebar_height; tbgpos += timebar_height; visible_timebars++; + have_timebar = true; } else { minsec_ruler->hide(); minsec_label.hide(); @@ -481,6 +483,7 @@ Editor::update_ruler_visibility () tbpos += timebar_height; tbgpos += timebar_height; visible_timebars++; + have_timebar = true; } else { timecode_ruler->hide(); timecode_label.hide(); @@ -496,6 +499,7 @@ Editor::update_ruler_visibility () tbpos += timebar_height; tbgpos += timebar_height; visible_timebars++; + have_timebar = true; } else { samples_ruler->hide(); samples_label.hide(); @@ -511,6 +515,7 @@ Editor::update_ruler_visibility () tbpos += timebar_height; tbgpos += timebar_height; visible_timebars++; + have_timebar = true; } else { bbt_ruler->hide(); bbt_label.hide(); @@ -661,6 +666,12 @@ Editor::update_ruler_visibility () update_video_timeline(true); } + if (have_timebar && UIConfiguration::instance().get_show_selection_marker ()) { + _selection_marker_group->show (); + } else { + _selection_marker_group->hide (); + } + ruler_separator->set_y_position ((int)(timebar_height * visible_timebars)); time_bars_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars) + 1); diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 424c79932e..a30203baad 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -1300,6 +1300,8 @@ Editor::time_selection_changed () _session->clear_range_selection (); } } + + update_selection_markers (); } /** Set all region actions to have a given sensitivity */ @@ -1737,6 +1739,7 @@ Editor::region_selection_changed () set_mouse_mode (MouseObject, false); } } + update_selection_markers (); } void diff --git a/gtk2_ardour/preference-metadata b/gtk2_ardour/preference-metadata index 6f5dc38b09..69faa1a327 100644 --- a/gtk2_ardour/preference-metadata +++ b/gtk2_ardour/preference-metadata @@ -170,6 +170,8 @@ regions gain envelope volume modes [show-region-name] regions name appearance editor +[show-selection-marker] + selection ruler marker range [show-region-xrun-markers] regions xruns markers dropouts [show-secondary-clock] diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 013d292ef0..1eda32dce7 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -2642,6 +2642,14 @@ RCOptionEditor::RCOptionEditor () sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_show_region_name) )); + add_option (_("Appearance/Editor"), + new BoolOption ( + "show-selection-marker", + _("Show Selection Marker"), + sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::get_show_selection_marker), + sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_show_selection_marker) + )); + HSliderOption *gui_hs; diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.h index afa7322363..8013bdccc5 100644 --- a/gtk2_ardour/ui_config_vars.h +++ b/gtk2_ardour/ui_config_vars.h @@ -138,6 +138,7 @@ UI_CONFIG_VARIABLE (bool, snap_to_region_sync, "snap-to-region-sync", true) UI_CONFIG_VARIABLE (bool, snap_to_region_start, "snap-to-region-start", true) UI_CONFIG_VARIABLE (bool, snap_to_region_end, "snap-to-region-end", true) UI_CONFIG_VARIABLE (bool, snap_to_grid, "snap-to-grid", true) +UI_CONFIG_VARIABLE (bool, show_selection_marker, "show-selection-marker", true) UI_CONFIG_VARIABLE (bool, show_grids_ruler, "show-grids-ruler", true) UI_CONFIG_VARIABLE (bool, rulers_follow_grid, "rulers-follow-grid", false) UI_CONFIG_VARIABLE (bool, grid_follows_internal, "grid-follows-internal", false) //this feature is deprecated, default it FALSE for now; remove it in v6