13
0

Tidy up the ruler code slightly.

git-svn-id: svn://localhost/ardour2/branches/3.0@8528 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2011-01-18 01:16:05 +00:00
parent 64d82d9a8e
commit 756ffc26bf
5 changed files with 36 additions and 39 deletions

View File

@ -392,7 +392,7 @@
<menu action="RulerMenu">
<menuitem action="toggle-minsec-ruler"/>
<menuitem action="toggle-samples-ruler"/>
<menuitem action="toggle-frames-ruler"/>
<menuitem action="toggle-bbt-ruler"/>
<separator/>
<menuitem action="toggle-meter-ruler"/>
@ -492,7 +492,7 @@
<popup action="RulerMenuPopup">
<menuitem action="toggle-minsec-ruler"/>
<menuitem action="toggle-timecode-ruler"/>
<menuitem action="toggle-samples-ruler"/>
<menuitem action="toggle-frames-ruler"/>
<menuitem action="toggle-bbt-ruler"/>
<separator/>
<menuitem action="toggle-meter-ruler"/>

View File

@ -241,7 +241,7 @@ Editor::Editor ()
, minsec_label (_("Mins:Secs"))
, bbt_label (_("Bars:Beats"))
, timecode_label (_("Timecode"))
, frame_label (_("Samples"))
, frame_label (_("Frames"))
, tempo_label (_("Tempo"))
, meter_label (_("Meter"))
, mark_label (_("Location Markers"))

View File

@ -760,7 +760,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
static GtkCustomMetric ruler_metrics[4];
Glib::RefPtr<Gtk::ToggleAction> ruler_timecode_action;
Glib::RefPtr<Gtk::ToggleAction> ruler_bbt_action;
Glib::RefPtr<Gtk::ToggleAction> ruler_samples_action;
Glib::RefPtr<Gtk::ToggleAction> ruler_frames_action;
Glib::RefPtr<Gtk::ToggleAction> ruler_minsec_action;
Glib::RefPtr<Gtk::ToggleAction> ruler_tempo_action;
Glib::RefPtr<Gtk::ToggleAction> ruler_meter_action;
@ -808,7 +808,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
framecnt_t minsec_mark_interval;
gint minsec_mark_modulo;
gint minsec_nmarks;
void set_minsec_ruler_scale (gdouble lower, gdouble upper);
void set_minsec_ruler_scale (framepos_t, framepos_t);
enum TimecodeRulerScale {
timecode_show_bits,
@ -820,10 +820,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
TimecodeRulerScale timecode_ruler_scale;
framecnt_t timecode_mark_interval;
gint timecode_mark_modulo;
gint timecode_nmarks;
void set_timecode_ruler_scale (gdouble lower, gdouble upper);
void set_timecode_ruler_scale (framepos_t, framepos_t);
framecnt_t _frames_ruler_interval;
void set_frames_ruler_scale (framepos_t, framepos_t);

View File

@ -592,8 +592,8 @@ Editor::register_actions ()
ruler_marker_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-marker-ruler"), _("Markers"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_marker)));
ruler_cd_marker_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-cd-marker-ruler"), _("CD Markers"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_cd_marker)));
ruler_loop_punch_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-loop-punch-ruler"), _("Loop/Punch"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_transport_marker)));
ruler_bbt_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-bbt-ruler"), _("Bars & Beats"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_frames)));
ruler_samples_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-samples-ruler"), _("Samples"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_bbt)));
ruler_bbt_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-bbt-ruler"), _("Bars & Beats"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_bbt)));
ruler_frames_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-frames-ruler"), _("Frames"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_frames)));
ruler_timecode_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-timecode-ruler"), _("Timecode"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_timecode)));
ruler_minsec_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-minsec-ruler"), _("Min:Sec"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_minsec)));
@ -617,7 +617,7 @@ Editor::register_actions ()
ruler_timecode_action->set_active (true);
ruler_minsec_action->set_active (false);
}
ruler_samples_action->set_active (false);
ruler_frames_action->set_active (false);
no_ruler_shown_update = false;
/* REGION LIST */
@ -721,7 +721,7 @@ Editor::toggle_ruler_visibility (RulerType rt)
action = "toggle-bbt-ruler";
break;
case ruler_metric_frames:
action = "toggle-samples-ruler";
action = "toggle-frames-ruler";
break;
case ruler_metric_minsec:
action = "toggle-minsec-ruler";

View File

@ -387,7 +387,7 @@ Editor::popup_ruler_menu (framepos_t where, ItemType t)
ruler_items.push_back (MenuElem (*action->create_menu_item()));
}
}
action = ActionManager::get_action ("Rulers", "toggle-samples-ruler");
action = ActionManager::get_action ("Rulers", "toggle-frames-ruler");
if (action) {
ruler_items.push_back (MenuElem (*action->create_menu_item()));
}
@ -434,7 +434,7 @@ Editor::store_ruler_visibility ()
node->add_property (X_("timecode"), ruler_timecode_action->get_active() ? "yes": "no");
node->add_property (X_("bbt"), ruler_bbt_action->get_active() ? "yes": "no");
node->add_property (X_("frames"), ruler_samples_action->get_active() ? "yes": "no");
node->add_property (X_("frames"), ruler_frames_action->get_active() ? "yes": "no");
node->add_property (X_("minsec"), ruler_minsec_action->get_active() ? "yes": "no");
node->add_property (X_("tempo"), ruler_tempo_action->get_active() ? "yes": "no");
node->add_property (X_("meter"), ruler_meter_action->get_active() ? "yes": "no");
@ -472,9 +472,9 @@ Editor::restore_ruler_visibility ()
}
if ((prop = node->property ("frames")) != 0) {
if (string_is_affirmative (prop->value())) {
ruler_samples_action->set_active (true);
ruler_frames_action->set_active (true);
} else {
ruler_samples_action->set_active (false);
ruler_frames_action->set_active (false);
}
}
if ((prop = node->property ("minsec")) != 0) {
@ -577,7 +577,7 @@ Editor::update_ruler_visibility ()
timecode_ruler->hide ();
}
if (ruler_samples_action->get_active()) {
if (ruler_frames_action->get_active()) {
visible_rulers++;
frame_label.show ();
frames_ruler->show ();
@ -800,14 +800,14 @@ Editor::compute_fixed_ruler_scale ()
}
if (ruler_timecode_action->get_active()) {
set_timecode_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames() );
set_timecode_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames());
}
if (ruler_minsec_action->get_active()) {
set_minsec_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames() );
set_minsec_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames());
}
if (ruler_samples_action->get_active()) {
if (ruler_frames_action->get_active()) {
set_frames_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames());
}
}
@ -836,7 +836,7 @@ Editor::update_fixed_rulers ()
leftmost_frame, _session->current_end_frame());
}
if (ruler_samples_action->get_active()) {
if (ruler_frames_action->get_active()) {
gtk_custom_ruler_set_range (GTK_CUSTOM_RULER(_frames_ruler), leftmost_frame, rightmost_frame,
leftmost_frame, _session->current_end_frame());
}
@ -889,9 +889,8 @@ Editor::_metric_get_minsec (GtkCustomRulerMark **marks, gdouble lower, gdouble u
}
void
Editor::set_timecode_ruler_scale (gdouble lower, gdouble upper)
Editor::set_timecode_ruler_scale (framepos_t lower, framepos_t upper)
{
framepos_t range;
framepos_t spacer;
framepos_t fr;
@ -901,13 +900,13 @@ Editor::set_timecode_ruler_scale (gdouble lower, gdouble upper)
fr = _session->frame_rate();
if (lower > (spacer = (framepos_t)(128 * Editor::get_current_zoom ()))) {
if (lower > (spacer = (framepos_t) (128 * Editor::get_current_zoom ()))) {
lower = lower - spacer;
} else {
lower = 0;
}
upper = upper + spacer;
range = (framepos_t) floor (upper - lower);
framecnt_t const range = upper - lower;
if (range < (2 * _session->frames_per_timecode_frame())) { /* 0 - 2 frames */
timecode_ruler_scale = timecode_show_bits;
@ -1236,33 +1235,33 @@ Editor::compute_bbt_ruler_scale (framepos_t lower, framepos_t upper)
i = current_bbt_points->end();
i--;
if ((*i).beat >= (*current_bbt_points->begin()).beat) {
bbt_bars = (*i).bar - (*current_bbt_points->begin()).bar;
bbt_bars = (*i).bar - (*current_bbt_points->begin()).bar;
} else {
bbt_bars = (*i).bar - (*current_bbt_points->begin()).bar - 1;
bbt_bars = (*i).bar - (*current_bbt_points->begin()).bar - 1;
}
beats = current_bbt_points->size() - bbt_bars;
/*Only show the bar helper if there aren't many bars on the screen */
/* Only show the bar helper if there aren't many bars on the screen */
if ((bbt_bars < 2) || (beats < 5)) {
bbt_bar_helper_on = true;
}
if (bbt_bars > 8192) {
bbt_ruler_scale = bbt_over;
bbt_ruler_scale = bbt_over;
} else if (bbt_bars > 1024) {
bbt_ruler_scale = bbt_show_64;
bbt_ruler_scale = bbt_show_64;
} else if (bbt_bars > 256) {
bbt_ruler_scale = bbt_show_16;
bbt_ruler_scale = bbt_show_16;
} else if (bbt_bars > 64) {
bbt_ruler_scale = bbt_show_4;
bbt_ruler_scale = bbt_show_4;
} else if (bbt_bars > 10) {
bbt_ruler_scale = bbt_show_1;
bbt_ruler_scale = bbt_show_1;
} else if (bbt_bars > 2) {
bbt_ruler_scale = bbt_show_beats;
bbt_ruler_scale = bbt_show_beats;
} else if (bbt_bars > 0) {
bbt_ruler_scale = bbt_show_ticks;
bbt_ruler_scale = bbt_show_ticks;
} else {
bbt_ruler_scale = bbt_show_ticks_detail;
bbt_ruler_scale = bbt_show_ticks_detail;
}
if ((bbt_ruler_scale == bbt_show_ticks_detail) && (lower_beat.beats == upper_beat.beats) && (upper_beat.ticks - lower_beat.ticks <= Timecode::BBT_Time::ticks_per_beat / 4)) {
@ -1806,9 +1805,8 @@ sample_to_clock_parts ( framepos_t sample,
}
void
Editor::set_minsec_ruler_scale (gdouble lower, gdouble upper)
Editor::set_minsec_ruler_scale (framepos_t lower, framepos_t upper)
{
framepos_t range;
framepos_t fr;
framepos_t spacer;
@ -1825,7 +1823,7 @@ Editor::set_minsec_ruler_scale (gdouble lower, gdouble upper)
lower = 0;
}
upper += spacer;
range = (framepos_t) (upper - lower);
framecnt_t const range = upper - lower;
if (range < (fr / 50)) {
minsec_mark_interval = fr / 1000; /* show 1/1000 seconds */
@ -1918,7 +1916,7 @@ Editor::metric_get_minsec (GtkCustomRulerMark **marks, gdouble lower, gdouble /*
}
/* to prevent 'flashing' */
if (lower > (spacer = (framepos_t)(128 * Editor::get_current_zoom ()))) {
if (lower > (spacer = (framepos_t) (128 * Editor::get_current_zoom ()))) {
lower = lower - spacer;
} else {
lower = 0;