diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index 4a92e79f00..24f4da34d4 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -353,6 +353,7 @@ + diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index c9a7892457..6702193754 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -585,6 +585,8 @@ public: void edit_tempo_section (ARDOUR::TempoSection*); void edit_meter_section (ARDOUR::MeterSection*); + void add_region_marker (); + protected: void map_transport_state (); void map_position_change (samplepos_t); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index e18fab93df..9ee3fc3736 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -1653,6 +1653,7 @@ Editor::register_region_actions () /* PART 3: actions that operate on the selection and also require the edit point location */ + register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "add-region-cue-marker", _("Add Region Cue Marker"), sigc::mem_fun (*this, &Editor::add_region_marker)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "set-region-sync-position", _("Set Sync Position"), sigc::mem_fun (*this, &Editor::set_region_sync_position)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "place-transient", _("Place Transient"), sigc::mem_fun (*this, &Editor::place_transient)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "trim-front", _("Trim Start at Edit Point"), sigc::mem_fun (*this, &Editor::trim_region_front)); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 75f24e48af..b8ff15a10d 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -8726,3 +8726,18 @@ Editor::midi_action (void (MidiRegionView::*method)()) } } } + +void +Editor::add_region_marker () +{ + if (!_session) { + return; + } + + RegionSelection rs = get_regions_from_selection_and_edit_point (); + samplepos_t position = get_preferred_edit_position (); + + for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) { + (*r)->region()->add_cue_marker ("foo", position); + } +} diff --git a/gtk2_ardour/marker.cc b/gtk2_ardour/marker.cc index c5bd57b9e4..486b21278c 100644 --- a/gtk2_ardour/marker.cc +++ b/gtk2_ardour/marker.cc @@ -95,6 +95,7 @@ ArdourMarker::ArdourMarker (PublicEditor& ed, ArdourCanvas::Container& parent, g /* Shapes we use: * * Mark: + * RegionCue: * * (0,0) -> (6,0) * ^ | @@ -165,6 +166,7 @@ ArdourMarker::ArdourMarker (PublicEditor& ed, ArdourCanvas::Container& parent, g switch (type) { case Mark: + case RegionCue: points = new ArdourCanvas::Points (); points->push_back (ArdourCanvas::Duple (0.0, 0.0)); diff --git a/gtk2_ardour/marker.h b/gtk2_ardour/marker.h index 8ffe569f2d..76cd2432cd 100644 --- a/gtk2_ardour/marker.h +++ b/gtk2_ardour/marker.h @@ -60,7 +60,8 @@ public: LoopStart, LoopEnd, PunchIn, - PunchOut + PunchOut, + RegionCue }; diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index c4232afb18..4519fa235e 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -33,6 +33,7 @@ #include "ardour/playlist.h" #include "ardour/profile.h" #include "ardour/session.h" +#include "ardour/source.h" #include "gtkmm2ext/colors.h" @@ -95,6 +96,10 @@ RegionView::RegionView (ArdourCanvas::Container* parent, , _cue_markers_visible (false) { UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &RegionView::parameter_changed)); + + for (SourceList::const_iterator s = _region->sources().begin(); s != _region->sources().end(); ++s) { + (*s)->CueMarkersChanged.connect (*this, invalidator (*this), boost::bind (&RegionView::update_cue_markers, this), gui_context()); + } } RegionView::RegionView (const RegionView& other) @@ -105,6 +110,11 @@ RegionView::RegionView (const RegionView& other) , _cue_markers_visible (false) { UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &RegionView::parameter_changed)); + + for (SourceList::const_iterator s = _region->sources().begin(); s != _region->sources().end(); ++s) { + (*s)->CueMarkersChanged.connect (*this, invalidator (*this), boost::bind (&RegionView::update_cue_markers, this), gui_context()); + } + /* derived concrete type will call init () */ _region = other._region; @@ -121,6 +131,11 @@ RegionView::RegionView (const RegionView& other, boost::shared_ptr other , _cue_markers_visible (false) { UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &RegionView::parameter_changed)); + + for (SourceList::const_iterator s = _region->sources().begin(); s != _region->sources().end(); ++s) { + (*s)->CueMarkersChanged.connect (*this, invalidator (*this), boost::bind (&RegionView::update_cue_markers, this), gui_context()); + } + /* derived concrete type will call init () */ /* this is a pseudo-copy constructor used when dragging regions around on the canvas. @@ -155,6 +170,10 @@ RegionView::RegionView (ArdourCanvas::Container* parent, , _silence_text (0) { UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &RegionView::parameter_changed)); + + for (SourceList::const_iterator s = _region->sources().begin(); s != _region->sources().end(); ++s) { + (*s)->CueMarkersChanged.connect (*this, invalidator (*this), boost::bind (&RegionView::update_cue_markers, this), gui_context()); + } } void @@ -213,23 +232,6 @@ RegionView::init (bool wfd) _xrun_markers_visible = false; update_xrun_markers (); - CueMarkers cues; - _region->get_cue_markers (cues, true); - arrow_size = (int)(7.0 * UIConfiguration::instance ().get_ui_scale ()) & ~1; - for (CueMarkers::const_iterator x = cues.begin (); x != cues.end (); ++x) { - ArdourCanvas::Arrow* canvas_item = new ArdourCanvas::Arrow(group); - canvas_item->set_color (UIConfiguration::instance().color ("theme:contrasting")); - canvas_item->set_show_head (1, true); - canvas_item->set_show_head (0, false); - canvas_item->set_head_width (1, arrow_size); - canvas_item->set_head_height (1, arrow_size); - canvas_item->set_y0 (arrow_size); - canvas_item->set_y1 (arrow_size); - canvas_item->raise_to_top (); - canvas_item->hide (); - _cue_markers.push_back (make_pair(*x, canvas_item)); - } - _cue_markers_visible = false; update_cue_markers (); @@ -265,6 +267,10 @@ RegionView::~RegionView () delete ((*i).second); } + for (list::iterator i = _cue_markers.begin(); i != _cue_markers.end(); ++i) { + delete *i; + } + drop_silent_frames (); delete editor; @@ -524,22 +530,41 @@ RegionView::update_xrun_markers () void RegionView::update_cue_markers () { + cerr << "Updating cue markers\n"; + const bool show_cue_markers = UIConfiguration::instance().get_show_region_cue_markers(); if (_cue_markers_visible == show_cue_markers && !_cue_markers_visible) { + cerr << " no show\n"; return; } - const samplepos_t start = _region->start(); - const samplepos_t length = _region->length(); - for (list >::iterator i = _cue_markers.begin(); i != _cue_markers.end(); ++i) { - float x_pos = trackview.editor().sample_to_pixel (i->first.position() - start); - i->second->set_x (x_pos); - if (show_cue_markers && (i->first.position() >= start && i->first.position() < start + length)) { - i->second->show (); - } else { - i->second->hide (); - } + for (list::iterator i = _cue_markers.begin(); i != _cue_markers.end(); ++i) { + delete (*i); } + _cue_markers.clear (); + + boost::shared_ptr source = region()->source (0); + + samplepos_t start = region()->start(); + samplepos_t end = region()->start() + region()->length(); + + for (CueMarkers::const_iterator c = source->cue_markers().begin(); c != source->cue_markers().end(); ++c) { + + if ((c->position() < start) || (c->position() >= end)) { + continue; + } + + ArdourMarker* mark = new ArdourMarker (trackview.editor(), *group, 0xff000000, c->text(), ArdourMarker::RegionCue, c->position(), false); + + if (show_cue_markers) { + mark->show (); + } else { + mark->hide (); + } + + _cue_markers.push_back (mark); + } + _cue_markers_visible = show_cue_markers; } diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h index a77103409f..7087615b7c 100644 --- a/gtk2_ardour/region_view.h +++ b/gtk2_ardour/region_view.h @@ -39,6 +39,7 @@ #include "time_axis_view_item.h" #include "automation_line.h" #include "enums.h" +#include "marker.h" class TimeAxisView; class RegionEditor; @@ -206,7 +207,7 @@ private: bool _xrun_markers_visible; void update_cue_markers (); - std::list > _cue_markers; + std::list _cue_markers; bool _cue_markers_visible; };