tracks has only 1 ruler, and the metric it uses depends on the primary clock mode

This commit is contained in:
Paul Davis 2014-09-05 15:24:41 -04:00
parent 2c92680788
commit a128e64e6e
4 changed files with 26 additions and 68 deletions

View file

@ -882,10 +882,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_begin, ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_begin,
ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_end); ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_end);
ArdourCanvas::Ruler* timecode_ruler; ArdourCanvas::Ruler* clock_ruler;
ArdourCanvas::Ruler* bbt_ruler;
ArdourCanvas::Ruler* samples_ruler;
ArdourCanvas::Ruler* minsec_ruler;
static const double timebar_height; static const double timebar_height;
Gtk::Menu *editor_ruler_menu; Gtk::Menu *editor_ruler_menu;

View file

@ -880,14 +880,9 @@ Editor::color_handler()
{ {
ArdourCanvas::Color base = ARDOUR_UI::config()->get_canvasvar_RulerBase(); ArdourCanvas::Color base = ARDOUR_UI::config()->get_canvasvar_RulerBase();
ArdourCanvas::Color text = ARDOUR_UI::config()->get_canvasvar_RulerText(); ArdourCanvas::Color text = ARDOUR_UI::config()->get_canvasvar_RulerText();
timecode_ruler->set_fill_color (base);
timecode_ruler->set_outline_color (text); clock_ruler->set_fill_color (base);
minsec_ruler->set_fill_color (base); clock_ruler->set_outline_color (text);
minsec_ruler->set_outline_color (text);
samples_ruler->set_fill_color (base);
samples_ruler->set_outline_color (text);
bbt_ruler->set_fill_color (base);
bbt_ruler->set_outline_color (text);
playhead_cursor->set_color (ARDOUR_UI::config()->get_canvasvar_PlayHead()); playhead_cursor->set_color (ARDOUR_UI::config()->get_canvasvar_PlayHead());

View file

@ -166,7 +166,7 @@ Editor::canvas_scroll_event (GdkEventScroll *event, bool from_canvas)
if (from_canvas) { if (from_canvas) {
boost::optional<ArdourCanvas::Rect> rulers = _time_markers_group->bounding_box(); boost::optional<ArdourCanvas::Rect> rulers = _time_markers_group->bounding_box();
if (rulers && rulers->contains (Duple (event->x, event->y))) { if (rulers && rulers->contains (Duple (event->x, event->y))) {
return canvas_ruler_event ((GdkEvent*) event, timecode_ruler, TimecodeRulerItem); return canvas_ruler_event ((GdkEvent*) event, clock_ruler, TimecodeRulerItem);
} }
} }

View file

@ -136,35 +136,19 @@ Editor::initialize_rulers ()
_minsec_metric = new MinsecMetric (this); _minsec_metric = new MinsecMetric (this);
_samples_metric = new SamplesMetric (this); _samples_metric = new SamplesMetric (this);
timecode_ruler = new ArdourCanvas::Ruler (_time_markers_group, *_timecode_metric, /* initial metric isn't important */
clock_ruler = new ArdourCanvas::Ruler (_time_markers_group, *_minsec_metric,
ArdourCanvas::Rect (0, 0, ArdourCanvas::COORD_MAX, timebar_height)); ArdourCanvas::Rect (0, 0, ArdourCanvas::COORD_MAX, timebar_height));
timecode_ruler->set_font_description (font); clock_ruler->set_font_description (font);
CANVAS_DEBUG_NAME (timecode_ruler, "timecode ruler"); CANVAS_DEBUG_NAME (clock_ruler, "clock ruler");
timecode_nmarks = 0;
samples_ruler = new ArdourCanvas::Ruler (_time_markers_group, *_samples_metric, ARDOUR_UI::instance()->primary_clock->mode_changed.connect (sigc::mem_fun (*this, &Editor::update_ruler_visibility));
ArdourCanvas::Rect (0, 0, ArdourCanvas::COORD_MAX, timebar_height));
samples_ruler->set_font_description (font);
CANVAS_DEBUG_NAME (samples_ruler, "samples ruler");
minsec_ruler = new ArdourCanvas::Ruler (_time_markers_group, *_minsec_metric,
ArdourCanvas::Rect (0, 0, ArdourCanvas::COORD_MAX, timebar_height));
minsec_ruler->set_font_description (font);
CANVAS_DEBUG_NAME (minsec_ruler, "minsec ruler");
minsec_nmarks = 0; minsec_nmarks = 0;
bbt_ruler = new ArdourCanvas::Ruler (_time_markers_group, *_bbt_metric,
ArdourCanvas::Rect (0, 0, ArdourCanvas::COORD_MAX, timebar_height));
bbt_ruler->set_font_description (font);
CANVAS_DEBUG_NAME (bbt_ruler, "bbt ruler");
timecode_nmarks = 0; timecode_nmarks = 0;
bbt_nmarks = 0;
/* 1 event handler to bind them all ... */ clock_ruler->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_ruler_event), clock_ruler, TimecodeRulerItem));
timecode_ruler->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_ruler_event), timecode_ruler, TimecodeRulerItem));
minsec_ruler->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_ruler_event), minsec_ruler, MinsecRulerItem));
bbt_ruler->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_ruler_event), bbt_ruler, BBTRulerItem));
samples_ruler->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_ruler_event), samples_ruler, SamplesRulerItem));
} }
bool bool
@ -433,26 +417,15 @@ Editor::update_ruler_visibility ()
tempo_group->hide (); tempo_group->hide ();
meter_group->hide (); meter_group->hide ();
/* which ruler we show depends on the clock mode */
/* first hide them all */
timecode_ruler->hide ();
samples_ruler->hide ();
minsec_ruler->hide ();
bbt_ruler->hide ();
ArdourCanvas::Ruler *clock_ruler = 0;
switch (ARDOUR_UI::instance()->primary_clock->mode()) { switch (ARDOUR_UI::instance()->primary_clock->mode()) {
case AudioClock::Timecode: case AudioClock::Timecode:
clock_ruler = timecode_ruler; clock_ruler->set_metric (*_timecode_metric);
break; break;
case AudioClock::Frames: case AudioClock::Frames:
clock_ruler = samples_ruler; clock_ruler->set_metric (*_samples_metric);
break; break;
default: default:
clock_ruler = minsec_ruler; clock_ruler->set_metric (*_minsec_metric);
break; break;
} }
@ -493,8 +466,8 @@ Editor::update_just_timecode ()
framepos_t rightmost_frame = leftmost_frame + current_page_samples(); framepos_t rightmost_frame = leftmost_frame + current_page_samples();
if (ruler_timecode_action->get_active()) { if (ARDOUR_UI::instance()->primary_clock->mode() == AudioClock::Timecode) {
timecode_ruler->set_range (leftmost_frame, rightmost_frame); clock_ruler->set_range (leftmost_frame, rightmost_frame);
} }
} }
@ -505,23 +478,18 @@ Editor::compute_fixed_ruler_scale ()
return; return;
} }
ArdourCanvas::Ruler *clock_ruler = 0;
switch (ARDOUR_UI::instance()->primary_clock->mode()) { switch (ARDOUR_UI::instance()->primary_clock->mode()) {
case AudioClock::Timecode: case AudioClock::Timecode:
clock_ruler = timecode_ruler; set_timecode_ruler_scale (leftmost_frame, leftmost_frame + current_page_samples());
break; break;
case AudioClock::Frames: case AudioClock::Frames:
clock_ruler = samples_ruler; set_samples_ruler_scale (leftmost_frame, leftmost_frame + current_page_samples());
break; break;
default: default:
clock_ruler = minsec_ruler; set_minsec_ruler_scale (leftmost_frame, leftmost_frame + current_page_samples());
break; break;
} }
set_timecode_ruler_scale (leftmost_frame, leftmost_frame + current_page_samples());
set_minsec_ruler_scale (leftmost_frame, leftmost_frame + current_page_samples());
set_samples_ruler_scale (leftmost_frame, leftmost_frame + current_page_samples());
} }
void void
@ -541,13 +509,11 @@ Editor::update_fixed_rulers ()
rightmost_frame = leftmost_frame + current_page_samples(); rightmost_frame = leftmost_frame + current_page_samples();
/* these force a redraw, which in turn will force execution of the metric callbacks /* force a redraw, which in turn will force execution of the metric callbacks
to compute the relevant ticks to display. to compute the relevant ticks to display.
*/ */
timecode_ruler->set_range (leftmost_frame, rightmost_frame); clock_ruler->set_range (leftmost_frame, rightmost_frame);
samples_ruler->set_range (leftmost_frame, rightmost_frame);
minsec_ruler->set_range (leftmost_frame, rightmost_frame);
} }
void void
@ -563,8 +529,8 @@ Editor::update_tempo_based_rulers (ARDOUR::TempoMap::BBTPointList::const_iterato
_bbt_metric->units_per_pixel = samples_per_pixel; _bbt_metric->units_per_pixel = samples_per_pixel;
if (ruler_bbt_action->get_active()) { if (ARDOUR_UI::instance()->primary_clock->mode() == AudioClock::BBT) {
bbt_ruler->set_range (leftmost_frame, leftmost_frame+current_page_samples()); clock_ruler->set_range (leftmost_frame, leftmost_frame+current_page_samples());
} }
} }