13
0

change display and interaction for BBT Markers

Draw regular tempo/meter markers for BBT markers, and move them when BBT marker is dragged

This will (does) allow regular editing workflow for the tempo/meter at at BBT marker
This commit is contained in:
Paul Davis 2023-07-25 11:58:51 -06:00
parent 206f7d3c40
commit e36dfa1f09
5 changed files with 43 additions and 58 deletions

View File

@ -760,6 +760,8 @@ private:
LocationMarkers* find_location_markers (ARDOUR::Location*) const;
ARDOUR::Location* find_location_from_marker (ArdourMarker*, bool& is_start) const;
ArdourMarker* find_marker_from_location_id (PBD::ID const&, bool) const;
TempoMarker* find_marker_for_tempo (Temporal::TempoPoint const &);
MeterMarker* find_marker_for_meter (Temporal::MeterPoint const &);
ArdourMarker* entered_marker;
bool _show_marker_lines;

View File

@ -112,16 +112,7 @@ Editor::reassociate_metric_markers (TempoMap::SharedPtr const& tmap)
void
Editor::reassociate_tempo_marker (TempoMap::SharedPtr const & tmap, Tempos const & tempos, TempoMarker& marker)
{
Temporal::MusicTimePoint const * mtp;
for (auto const & tempo : tempos) {
if ((mtp = dynamic_cast<Temporal::MusicTimePoint const *>(&tempo)) != 0) {
/* do nothing .. but we had to catch
this first because MusicTimePoint
IS-A TempoPoint
*/
continue;
}
if (marker.point().sclock() == tempo.sclock()) {
marker.reset_tempo (tempo);
marker.curve().reset_point (tempo);
@ -133,16 +124,7 @@ Editor::reassociate_tempo_marker (TempoMap::SharedPtr const & tmap, Tempos const
void
Editor::reassociate_meter_marker (TempoMap::SharedPtr const & tmap, Meters const & meters, MeterMarker& marker)
{
Temporal::MusicTimePoint const * mtp;
for (auto const & meter : meters) {
if ((mtp = dynamic_cast<Temporal::MusicTimePoint const *>(&meter)) != 0) {
/* do nothing .. but we had to catch
this first because MusicTimePoint
IS-A MeterPoint
*/
continue;
}
if (marker.point().sclock() == meter.sclock()) {
marker.reset_meter (meter);
break;
@ -164,7 +146,7 @@ Editor::reassociate_bartime_marker (TempoMap::SharedPtr const & tmap, MusicTimes
void
Editor::make_bbt_marker (MusicTimePoint const * mtp, Marks::iterator before)
{
bbt_marks.insert (before, new BBTMarker (*this, *bbt_ruler, "meter marker", *mtp, *tempo_group, *mapping_group, *meter_group));
bbt_marks.insert (before, new BBTMarker (*this, *bbt_ruler, "meter marker", *mtp));
}
void
@ -207,6 +189,7 @@ Editor::reset_metric_marks ()
{
reset_tempo_marks ();
reset_meter_marks ();
/* Must come last, after temp and meter marks are created and are discoverable */
reset_bbt_marks ();
}
@ -232,13 +215,8 @@ Editor::reset_tempo_marks ()
tempo_marks.clear ();
for (auto const & t : tempi) {
/* do not draw BBT position elements that are both tempo & meter points */
if (!dynamic_cast<Temporal::MusicTimePoint const *> (&t)) {
make_tempo_marker (&t, min_tempo, max_tempo, prev_ts, tc_color, sr, tempo_marks.end());
prev_ts = &t;
}
make_tempo_marker (&t, min_tempo, max_tempo, prev_ts, tc_color, sr, tempo_marks.end());
prev_ts = &t;
}
update_tempo_curves (min_tempo, max_tempo, sr);
@ -260,12 +238,7 @@ Editor::reset_meter_marks ()
meter_marks.clear ();
for (auto const & m : meters) {
/* do not draw BBT position elements that are both tempo & meter points */
if (!dynamic_cast<Temporal::MusicTimePoint const *> (&m)) {
make_meter_marker (&m, meter_marks.end());
}
make_meter_marker (&m, meter_marks.end());
}
}
@ -1063,3 +1036,27 @@ Editor::clear_tempo_markers_after (timepos_t where, bool stop_at_music_times)
_session->add_command (new Temporal::TempoCommand (_("clear later tempos"), before_state, &after));
commit_reversible_command ();
}
TempoMarker*
Editor::find_marker_for_tempo (Temporal::TempoPoint const & tp)
{
for (auto const & tm : tempo_marks) {
TempoMarker* t;
if ((t = dynamic_cast<TempoMarker*>(tm))->tempo() == tp) {
return t;
}
}
return nullptr;
}
MeterMarker*
Editor::find_marker_for_meter (Temporal::MeterPoint const & mp)
{
for (auto const & mm : meter_marks) {
MeterMarker* m;
if ((m = dynamic_cast<MeterMarker*>(mm))->meter() == mp) {
return m;
}
}
return nullptr;
}

View File

@ -857,37 +857,19 @@ MeterMarker::point() const
/***********************************************************************/
BBTMarker::BBTMarker (PublicEditor& editor, ArdourCanvas::Item& parent, std::string const& color_name, Temporal::MusicTimePoint const & p,
ArdourCanvas::Item& tempo_parent,
ArdourCanvas::Item& mapping_parent,
ArdourCanvas::Item& meter_parent)
BBTMarker::BBTMarker (PublicEditor& editor, ArdourCanvas::Item& parent, std::string const& color_name, Temporal::MusicTimePoint const & p)
: MetricMarker (editor, parent, color_name, p.name(), BBTPosition, p.time(), false)
, _point (&p)
, tempo_marker (new TempoMarker (editor, tempo_parent, mapping_parent, X_("tempo marker"), "", p, p.sample (TEMPORAL_SAMPLE_RATE), UIConfiguration::instance().color (X_("tempo curve"))))
{
std::stringstream full_tooltip;
full_tooltip << name();
full_tooltip << " (";
full_tooltip << p.bbt();
full_tooltip << ')';
set_name (name(), full_tooltip.str());
set_name (name(), string());
group->Event.connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_bbt_marker_event), group, this));
char buf[64];
snprintf (buf, sizeof(buf), "%d/%d", p.divisions_per_bar(), p.note_value ());
meter_marker = new MeterMarker (editor, meter_parent, "meter marker", buf, p);
tempo_marker->the_item().set_ignore_events (true);
meter_marker->the_item().set_ignore_events (true);
tempo_marker = editor.find_marker_for_tempo (p);
meter_marker = editor.find_marker_for_meter (p);
}
BBTMarker::~BBTMarker ()
{
delete tempo_marker;
delete meter_marker;
}
void

View File

@ -231,10 +231,7 @@ class MeterMarker : public MetricMarker
class BBTMarker : public MetricMarker
{
public:
BBTMarker (PublicEditor& editor, ArdourCanvas::Item &, std::string const& color_name, Temporal::MusicTimePoint const &,
ArdourCanvas::Item & tempo_parent,
ArdourCanvas::Item & mapping_parent,
ArdourCanvas::Item & meter_parent);
BBTMarker (PublicEditor& editor, ArdourCanvas::Item &, std::string const& color_name, Temporal::MusicTimePoint const &);
~BBTMarker ();
void reset_point (Temporal::MusicTimePoint const &);

View File

@ -64,6 +64,11 @@
#include "editing.h"
#include "selection.h"
namespace Temporal {
class TempoPoint;
class MeterPoint;
}
namespace ARDOUR {
class Session;
class Region;
@ -544,6 +549,8 @@ public:
virtual ARDOUR::Location* find_location_from_marker (ArdourMarker*, bool&) const = 0;
virtual ArdourMarker* find_marker_from_location_id (PBD::ID const&, bool) const = 0;
virtual TempoMarker* find_marker_for_tempo (Temporal::TempoPoint const &) = 0;
virtual MeterMarker* find_marker_for_meter (Temporal::MeterPoint const &) = 0;
virtual void snap_to_with_modifier (Temporal::timepos_t & first,
GdkEvent const* ev,