13
0

add basic/initial code for action to add a region marker

This commit is contained in:
Paul Davis 2021-05-14 07:48:53 -06:00
parent 2791be7f2a
commit a1c68460be
8 changed files with 77 additions and 29 deletions

View File

@ -353,6 +353,7 @@
<menuitem action='toggle-region-lock-style'/>
<menuitem action='toggle-region-video-lock'/>
<menuitem action='set-region-sync-position'/>
<menuitem action='add-region-cue-marker'/>
<menuitem action='remove-region-sync'/>
<menuitem action='nudge-forward'/>
<menuitem action='nudge-backward'/>

View File

@ -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);

View File

@ -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));

View File

@ -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);
}
}

View File

@ -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));

View File

@ -60,7 +60,8 @@ public:
LoopStart,
LoopEnd,
PunchIn,
PunchOut
PunchOut,
RegionCue
};

View File

@ -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<Region> 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<ArdourMarker*>::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<std::pair<CueMarker, ArdourCanvas::Arrow*> >::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<ArdourMarker*>::iterator i = _cue_markers.begin(); i != _cue_markers.end(); ++i) {
delete (*i);
}
_cue_markers.clear ();
boost::shared_ptr<Source> 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;
}

View File

@ -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<std::pair<ARDOUR::CueMarker, ArdourCanvas::Arrow*> > _cue_markers;
std::list<ArdourMarker*> _cue_markers;
bool _cue_markers_visible;
};