Draw beat sudivisions according to snap setting.
This commit is contained in:
parent
04bbe402b0
commit
84412e1367
|
@ -2094,6 +2094,8 @@ Editor::set_snap_to (SnapType st)
|
|||
break;
|
||||
}
|
||||
|
||||
redisplay_tempo (false);
|
||||
|
||||
SnapChanged (); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
|
|
|
@ -178,8 +178,9 @@ Editor::draw_measures (ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
|
|||
if (tempo_lines == 0) {
|
||||
tempo_lines = new TempoLines (time_line_group, ArdourCanvas::LineSet::Vertical);
|
||||
}
|
||||
|
||||
tempo_lines->draw (begin, end, leftmost_frame, _session->frame_rate());
|
||||
|
||||
const unsigned divisions = get_grid_beat_divisions(leftmost_frame);
|
||||
tempo_lines->draw (begin, end, divisions, leftmost_frame, _session->frame_rate());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -53,39 +53,14 @@ TempoLines::hide ()
|
|||
lines.hide ();
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
tick_alpha(uint8_t base_alpha, unsigned divisions)
|
||||
{
|
||||
if (divisions == 32) {
|
||||
return std::max(0, base_alpha / 5);
|
||||
} else if (divisions == 16) {
|
||||
return std::max(0, base_alpha / 4);
|
||||
} else if (divisions == 8) {
|
||||
return std::max(0, base_alpha / 3);
|
||||
} else if (divisions == 4) {
|
||||
return std::max(0, base_alpha / 2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
TempoLines::draw_ticks (const ARDOUR::TempoMap::BBTPointList::const_iterator& b,
|
||||
double beat_density,
|
||||
unsigned divisions,
|
||||
framecnt_t leftmost_frame,
|
||||
framecnt_t frame_rate)
|
||||
{
|
||||
const double fpb = b->tempo->frames_per_beat(frame_rate);
|
||||
const uint32_t base = ARDOUR_UI::config()->color_mod("measure line beat", "measure line beat");
|
||||
unsigned divisions = 4;
|
||||
if (beat_density < 0.01) {
|
||||
divisions = 32;
|
||||
} else if (beat_density < 0.025) {
|
||||
divisions = 16;
|
||||
} else if (beat_density < 0.05) {
|
||||
divisions = 8;
|
||||
} else if (beat_density < 0.1) {
|
||||
divisions = 4;
|
||||
}
|
||||
const double fpb = b->tempo->frames_per_beat(frame_rate);
|
||||
const uint32_t base = ARDOUR_UI::config()->color_mod("measure line beat", "measure line beat");
|
||||
|
||||
for (unsigned l = 1; l < divisions; ++l) {
|
||||
/* find the coarsest division level this tick falls on */
|
||||
|
@ -97,7 +72,8 @@ TempoLines::draw_ticks (const ARDOUR::TempoMap::BBTPointList::const_iterator& b,
|
|||
}
|
||||
|
||||
/* draw line with alpha corresponding to coarsest level */
|
||||
const uint32_t c = UINT_RGBA_CHANGE_A(base, tick_alpha(UINT_RGBA_A(base), level));
|
||||
const uint8_t a = max(0, (int)rint(UINT_RGBA_A(base) / log2(level)));
|
||||
const uint32_t c = UINT_RGBA_CHANGE_A(base, a);
|
||||
const framepos_t f = b->frame + (l * (fpb / (double)divisions));
|
||||
if (f > leftmost_frame) {
|
||||
lines.add (PublicEditor::instance().sample_to_pixel_unrounded (f), 1.0, c);
|
||||
|
@ -108,6 +84,7 @@ TempoLines::draw_ticks (const ARDOUR::TempoMap::BBTPointList::const_iterator& b,
|
|||
void
|
||||
TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
|
||||
const ARDOUR::TempoMap::BBTPointList::const_iterator& end,
|
||||
unsigned divisions,
|
||||
framecnt_t leftmost_frame,
|
||||
framecnt_t frame_rate)
|
||||
{
|
||||
|
@ -133,13 +110,18 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
|
|||
return;
|
||||
}
|
||||
|
||||
/* constrain divisions to a log2 factor to cap line density */
|
||||
while (divisions > 3 && beat_density * divisions > 0.4) {
|
||||
divisions /= 2;
|
||||
}
|
||||
|
||||
lines.clear ();
|
||||
|
||||
if (beat_density < 0.1 && begin != end && begin->frame > 0) {
|
||||
/* draw subdivisions of the beat before the first visible beat line */
|
||||
ARDOUR::TempoMap::BBTPointList::const_iterator prev = begin;
|
||||
--prev;
|
||||
draw_ticks(prev, beat_density, leftmost_frame, frame_rate);
|
||||
draw_ticks(prev, divisions, leftmost_frame, frame_rate);
|
||||
}
|
||||
|
||||
for (i = begin; i != end; ++i) {
|
||||
|
@ -159,7 +141,7 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
|
|||
|
||||
if (beat_density < 0.1) {
|
||||
/* draw subdivisions of this beat */
|
||||
draw_ticks(i, beat_density, leftmost_frame, frame_rate);
|
||||
draw_ticks(i, divisions, leftmost_frame, frame_rate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
|
||||
void draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
|
||||
const ARDOUR::TempoMap::BBTPointList::const_iterator& end,
|
||||
unsigned divisions,
|
||||
framecnt_t leftmost_frame,
|
||||
framecnt_t frame_rate);
|
||||
|
||||
|
@ -39,7 +40,7 @@ public:
|
|||
|
||||
private:
|
||||
void draw_ticks (const ARDOUR::TempoMap::BBTPointList::const_iterator& b,
|
||||
double beat_density,
|
||||
unsigned divisions,
|
||||
framecnt_t leftmost_frame,
|
||||
framecnt_t frame_rate);
|
||||
|
||||
|
|
Loading…
Reference in New Issue