Tempo Marks : set point colour by discontinuity, display non-quarter pulse if we are non-quarter.

- a jump in tempo by more than 1 ntpm results in a red
	 tempo mark pointer.

	- ignore UIConfiguration::get_allow_non_quarter_pulse()
	  when displaying note type in the marker text (only display
	  note type if we are non-quarter).
This commit is contained in:
nick_m 2017-02-27 11:10:47 +11:00
parent adffdc02bd
commit ad84332661
3 changed files with 41 additions and 10 deletions

View File

@ -84,6 +84,7 @@ void
Editor::draw_metric_marks (const Metrics& metrics)
{
char buf[64];
TempoSection* prev_ts = 0;
double max_tempo = 0.0;
double min_tempo = DBL_MAX;
@ -91,7 +92,7 @@ Editor::draw_metric_marks (const Metrics& metrics)
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
const MeterSection *ms;
const TempoSection *ts;
TempoSection *ts;
if ((ms = dynamic_cast<const MeterSection*>(*i)) != 0) {
snprintf (buf, sizeof(buf), "%g/%g", ms->divisions_per_bar(), ms->note_divisor ());
@ -102,8 +103,9 @@ Editor::draw_metric_marks (const Metrics& metrics)
metric_marks.push_back (new MeterMarker (*this, *meter_group, UIConfiguration::instance().color ("meter marker"), buf,
*(const_cast<MeterSection*>(ms))));
}
} else if ((ts = dynamic_cast<const TempoSection*>(*i)) != 0) {
if (UIConfiguration::instance().get_allow_non_quarter_pulse()) {
} else if ((ts = dynamic_cast<TempoSection*>(*i)) != 0) {
if (ts->note_type() != 4.0) {
snprintf (buf, sizeof (buf), "%.3f/%.0f", ts->note_types_per_minute(), ts->note_type());
} else {
snprintf (buf, sizeof (buf), "%.3f", ts->note_types_per_minute());
@ -125,6 +127,12 @@ Editor::draw_metric_marks (const Metrics& metrics)
metric_marks.push_back (new TempoMarker (*this, *tempo_group, UIConfiguration::instance().color ("tempo marker"), buf,
*(const_cast<TempoSection*>(ts))));
}
if (prev_ts && abs (prev_ts->end_note_types_per_minute() - ts->note_types_per_minute()) < 1.0) {
metric_marks.back()->set_points_color (UIConfiguration::instance().color ("tempo marker music"));
} else {
metric_marks.back()->set_points_color (UIConfiguration::instance().color ("tempo marker"));
}
prev_ts = ts;
}
}
@ -204,21 +212,29 @@ Editor::tempometric_position_changed (const PropertyChange& /*ignored*/)
tempo_lines->tempo_map_changed();
}
TempoSection* prev_ts = 0;
double max_tempo = 0.0;
double min_tempo = DBL_MAX;
for (Marks::iterator x = metric_marks.begin(); x != metric_marks.end(); ++x) {
TempoMarker* tempo_marker;
MeterMarker* meter_marker;
const TempoSection *ts;
TempoSection *ts;
const MeterSection *ms;
if ((tempo_marker = dynamic_cast<TempoMarker*> (*x)) != 0) {
if ((ts = &tempo_marker->tempo()) != 0) {
tempo_marker->set_position (ts->frame ());
char buf[64];
if (UIConfiguration::instance().get_allow_non_quarter_pulse()) {
if (prev_ts && abs (prev_ts->end_note_types_per_minute() - ts->note_types_per_minute()) < 1.0) {
tempo_marker->set_points_color (UIConfiguration::instance().color ("tempo marker music"));
} else {
tempo_marker->set_points_color (UIConfiguration::instance().color ("tempo marker"));
}
if (ts->note_type() != 4.0) {
snprintf (buf, sizeof (buf), "%.3f/%.0f", ts->note_types_per_minute(), ts->note_type());
} else {
snprintf (buf, sizeof (buf), "%.3f", ts->note_types_per_minute());
@ -230,6 +246,8 @@ Editor::tempometric_position_changed (const PropertyChange& /*ignored*/)
max_tempo = max (max_tempo, ts->end_note_types_per_minute());
min_tempo = min (min_tempo, ts->note_types_per_minute());
min_tempo = min (min_tempo, ts->end_note_types_per_minute());
prev_ts = ts;
}
}
if ((meter_marker = dynamic_cast<MeterMarker*> (*x)) != 0) {
@ -313,11 +331,13 @@ void
Editor::tempo_curve_selected (TempoSection* ts, bool yn)
{
for (Curves::iterator x = tempo_curves.begin(); x != tempo_curves.end(); ++x) {
if (&(*x)->tempo() == ts && yn) {
(*x)->set_color_rgba (UIConfiguration::instance().color ("location marker"));
break;
} else if (&(*x)->tempo() == ts) {
(*x)->set_color_rgba (UIConfiguration::instance().color ("tempo curve"));
if (&(*x)->tempo() == ts) {
(*x)->set_selected (yn);
if (yn) {
(*x)->set_color_rgba (UIConfiguration::instance().color ("location marker"));
} else {
(*x)->set_color_rgba (UIConfiguration::instance().color ("tempo curve"));
}
break;
}
}

View File

@ -74,6 +74,7 @@ ArdourMarker::ArdourMarker (PublicEditor& ed, ArdourCanvas::Container& parent, g
, _shown (false)
, _line_shown (false)
, _color (rgba)
, _points_color (rgba)
, _left_label_limit (DBL_MAX)
, _right_label_limit (DBL_MAX)
, _label_offset (0)
@ -485,6 +486,14 @@ ArdourMarker::hide ()
setup_line ();
}
void
ArdourMarker::set_points_color (uint32_t c)
{
_points_color = c;
mark->set_fill_color (_points_color);
mark->set_outline_color (_points_color);
}
void
ArdourMarker::set_color_rgba (uint32_t c)
{

View File

@ -77,6 +77,7 @@ class ArdourMarker : public sigc::trackable
void set_position (framepos_t);
void set_name (const std::string&);
void set_points_color (uint32_t rgba);
void set_color_rgba (uint32_t rgba);
void setup_line ();
@ -123,6 +124,7 @@ class ArdourMarker : public sigc::trackable
bool _line_shown;
double _canvas_height;
uint32_t _color;
uint32_t _points_color;
double _left_label_limit; ///< the number of pixels available to the left of this marker for a label
double _right_label_limit; ///< the number of pixels available to the right of this marker for a label
double _label_offset;