From a14f216f3ecf2ed8d4adc029e0696833498f1033 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 29 Aug 2023 00:24:14 +0200 Subject: [PATCH] Highligh ranges in arrangement ruler --- gtk2_ardour/editor.cc | 6 +++ gtk2_ardour/editor.h | 1 + gtk2_ardour/editor_canvas.cc | 3 +- gtk2_ardour/editor_markers.cc | 45 +++++++++++++++++++ .../themes/blueberry_milk-ardour.colors | 2 + gtk2_ardour/themes/caineville-ardour.colors | 2 + gtk2_ardour/themes/clear_gray-ardour.colors | 2 + gtk2_ardour/themes/cubasish-ardour.colors | 2 + gtk2_ardour/themes/dark-ardour.colors | 2 + gtk2_ardour/themes/diehard3-ardour.colors | 2 + gtk2_ardour/themes/recbox-ardour.colors | 2 + gtk2_ardour/themes/unastudia-ardour.colors | 4 +- gtk2_ardour/themes/xcolors-ardour.colors | 2 + 13 files changed, 73 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index f0919ee80e..6123b8fc18 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -611,6 +611,8 @@ Editor::Editor () selection->TimeChanged.connect (sigc::mem_fun(*this, &Editor::time_selection_changed)); selection->TracksChanged.connect (sigc::mem_fun(*this, &Editor::track_selection_changed)); + ZoomChanged.connect (sigc::mem_fun (*this, &Editor::update_section_rects)); + editor_regions_selection_changed_connection = selection->RegionsChanged.connect (sigc::mem_fun(*this, &Editor::region_selection_changed)); selection->PointsChanged.connect (sigc::mem_fun(*this, &Editor::point_selection_changed)); @@ -1433,6 +1435,10 @@ Editor::set_session (Session *t) _session->auto_loop_location_changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::loop_location_changed, this, _1), gui_context ()); _session->history().Changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::history_changed, this), gui_context()); + Location::start_changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_section_rects, this), gui_context ()); + Location::end_changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_section_rects, this), gui_context ()); + Location::flags_changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_section_rects, this), gui_context ()); + _playhead_cursor->track_canvas_item().reparent ((ArdourCanvas::Item*) get_cursor_scroll_group()); _playhead_cursor->show (); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 3685d838b0..9e708215ac 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -718,6 +718,7 @@ private: void location_changed (ARDOUR::Location*); void location_flags_changed (ARDOUR::Location*); void refresh_location_display (); + void update_section_rects (); void refresh_location_display_internal (const ARDOUR::Locations::LocationList&); void add_new_location (ARDOUR::Location*); ArdourCanvas::Container* add_new_location_internal (ARDOUR::Location*); diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 48aed1c0b4..bd0e732b7f 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -171,7 +171,7 @@ Editor::initialize_canvas () tempo_meta_group = new ArdourCanvas::Container (_time_markers_group, ArdourCanvas::Duple (0.0, (timebar_height * 4.0) + 1.0)); CANVAS_DEBUG_NAME (tempo_meta_group, "tempo meta group"); section_marker_group = new ArdourCanvas::Container (_time_markers_group, ArdourCanvas::Duple (0.0, (timebar_height * 5.0) + 1.0)); - CANVAS_DEBUG_NAME (tempo_meta_group, "Arranger marker group"); + CANVAS_DEBUG_NAME (section_marker_group, "Arranger marker group"); tempo_group = new ArdourCanvas::Container (tempo_meta_group, ArdourCanvas::Duple (0.0, 0.0)); CANVAS_DEBUG_NAME (tempo_group, "tempo group"); mapping_group = new ArdourCanvas::Container (tempo_meta_group, ArdourCanvas::Duple (0.0, 0.0)); @@ -1123,6 +1123,7 @@ Editor::color_handler() rubberband_rect->set_fill_color (UIConfiguration::instance().color_mod ("rubber band rect", "selection rect")); refresh_location_display (); + update_section_rects (); NoteBase::set_colors (); diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index aef7730835..487dfc3aff 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -90,6 +90,10 @@ Editor::add_new_location (Location *location) if (location->is_auto_loop()) { update_loop_range_view (); } + + if (location->is_section ()) { + update_section_rects (); + } } /** Add a new location, without a time-consuming update of all marker labels; @@ -610,6 +614,43 @@ Editor::refresh_location_display () update_marker_labels (); } +void +Editor::update_section_rects () +{ + ENSURE_GUI_THREAD (*this, &Editor::update_section_rects); + if (!_session) { + return; + } + section_marker_bar->clear (true); + + timepos_t start; + timepos_t end; + + Locations* loc = _session->locations (); + Location* l = NULL; + bool bright = false; + + do { + l = loc->next_section (l, start, end); + if (l) { + double const left = sample_to_pixel (start.samples ()); + double const right = sample_to_pixel (end.samples ()); + + ArdourCanvas::Rectangle* rect = new ArdourCanvas::Rectangle (section_marker_bar, ArdourCanvas::Rect (left, 2, right, timebar_height - 3)); + rect->set_fill (true); + rect->set_outline_what(ArdourCanvas::Rectangle::What(0)); + rect->raise_to_top (); + if (bright) { + rect->set_fill_color (UIConfiguration::instance().color ("arrangement rect")); + } else { + rect->set_fill_color (UIConfiguration::instance().color ("arrangement rect alt")); + } + bright = !bright; + + } + } while (l); +} + void Editor::LocationMarkers::hide() { @@ -911,6 +952,10 @@ Editor::location_gone (Location *location) break; } } + + if (location->is_section ()) { + update_section_rects (); + } } void diff --git a/gtk2_ardour/themes/blueberry_milk-ardour.colors b/gtk2_ardour/themes/blueberry_milk-ardour.colors index fd9104c599..b394e6c536 100644 --- a/gtk2_ardour/themes/blueberry_milk-ardour.colors +++ b/gtk2_ardour/themes/blueberry_milk-ardour.colors @@ -51,6 +51,8 @@ + + diff --git a/gtk2_ardour/themes/caineville-ardour.colors b/gtk2_ardour/themes/caineville-ardour.colors index cdde95d03f..ffd7d39575 100644 --- a/gtk2_ardour/themes/caineville-ardour.colors +++ b/gtk2_ardour/themes/caineville-ardour.colors @@ -52,6 +52,8 @@ + + diff --git a/gtk2_ardour/themes/clear_gray-ardour.colors b/gtk2_ardour/themes/clear_gray-ardour.colors index 8f4ad4eb88..f29c95f195 100644 --- a/gtk2_ardour/themes/clear_gray-ardour.colors +++ b/gtk2_ardour/themes/clear_gray-ardour.colors @@ -52,6 +52,8 @@ + + diff --git a/gtk2_ardour/themes/cubasish-ardour.colors b/gtk2_ardour/themes/cubasish-ardour.colors index 4fecb87ef0..ea0af1cb7a 100644 --- a/gtk2_ardour/themes/cubasish-ardour.colors +++ b/gtk2_ardour/themes/cubasish-ardour.colors @@ -52,6 +52,8 @@ + + diff --git a/gtk2_ardour/themes/dark-ardour.colors b/gtk2_ardour/themes/dark-ardour.colors index e4288cfc25..477f739daf 100644 --- a/gtk2_ardour/themes/dark-ardour.colors +++ b/gtk2_ardour/themes/dark-ardour.colors @@ -53,6 +53,8 @@ + + diff --git a/gtk2_ardour/themes/diehard3-ardour.colors b/gtk2_ardour/themes/diehard3-ardour.colors index b537fe6fa3..85ef9a182d 100644 --- a/gtk2_ardour/themes/diehard3-ardour.colors +++ b/gtk2_ardour/themes/diehard3-ardour.colors @@ -53,6 +53,8 @@ + + diff --git a/gtk2_ardour/themes/recbox-ardour.colors b/gtk2_ardour/themes/recbox-ardour.colors index 8fe5f822ea..5b7473a5bb 100644 --- a/gtk2_ardour/themes/recbox-ardour.colors +++ b/gtk2_ardour/themes/recbox-ardour.colors @@ -53,6 +53,8 @@ + + diff --git a/gtk2_ardour/themes/unastudia-ardour.colors b/gtk2_ardour/themes/unastudia-ardour.colors index c0f47062f8..cbabe96b6a 100644 --- a/gtk2_ardour/themes/unastudia-ardour.colors +++ b/gtk2_ardour/themes/unastudia-ardour.colors @@ -50,7 +50,9 @@ - + + + diff --git a/gtk2_ardour/themes/xcolors-ardour.colors b/gtk2_ardour/themes/xcolors-ardour.colors index c4ba12fa99..490781ad22 100644 --- a/gtk2_ardour/themes/xcolors-ardour.colors +++ b/gtk2_ardour/themes/xcolors-ardour.colors @@ -52,6 +52,8 @@ + +