summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-05-08 12:37:17 +0200
committerRobin Gareus <robin@gareus.org>2017-05-08 12:37:17 +0200
commit2c7cb9065f6303c64baf4eb5dbb64db56a587d40 (patch)
tree5397517e8f8daeeb2277bfd122fcb06ded22c67f /gtk2_ardour
parent2ed08f07718171e49e10618b4bb41e4cce0de5d9 (diff)
Limit clock displays to 30days (720hours) by default.
This prevents various edge-cases of selection-clocks (eg. unbound range selection after start-range; and makes it near impossible to roll-over 2^63 using GUI operations)
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/audio_clock.cc53
-rw-r--r--gtk2_ardour/audio_clock.h3
-rw-r--r--gtk2_ardour/ui_config_vars.h1
3 files changed, 51 insertions, 6 deletions
diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc
index 3053dd9a87..4027890133 100644
--- a/gtk2_ardour/audio_clock.cc
+++ b/gtk2_ardour/audio_clock.cc
@@ -77,6 +77,7 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string&
, _edit_by_click_field (false)
, _negative_allowed (false)
, edit_is_negative (false)
+ , _limit_pos (INT64_MAX - 1)
, _with_info (with_info)
, editing_attr (0)
, foreground_attr (0)
@@ -819,6 +820,12 @@ AudioClock::set (framepos_t when, bool force, framecnt_t offset)
when = when - offset;
}
+ if (when > _limit_pos) {
+ when = _limit_pos;
+ } else if (when < -_limit_pos) {
+ when = -_limit_pos;
+ }
+
if (when == last_when && !force) {
#if 0 // XXX return if no change and no change forced. verify Aug/2014
if (_mode != Timecode && _mode != MinSec) {
@@ -944,6 +951,24 @@ AudioClock::set_slave_info ()
}
void
+AudioClock::set_out_of_bounds (bool negative)
+{
+ if (is_duration) {
+ if (negative) {
+ _layout->set_text (" >>> -- <<< ");
+ } else {
+ _layout->set_text (" >>> ++ <<< ");
+ }
+ } else {
+ if (negative) {
+ _layout->set_text (" <<<<<<<<<< ");
+ } else {
+ _layout->set_text (" >>>>>>>>>> ");
+ }
+ }
+}
+
+void
AudioClock::set_frames (framepos_t when, bool /*force*/)
{
char buf[32];
@@ -961,14 +986,16 @@ AudioClock::set_frames (framepos_t when, bool /*force*/)
negative = true;
}
- if (negative) {
+ if (when >= _limit_pos) {
+ set_out_of_bounds (negative);
+ } else if (negative) {
snprintf (buf, sizeof (buf), "-%10" PRId64, when);
+ _layout->set_text (buf);
} else {
snprintf (buf, sizeof (buf), " %10" PRId64, when);
+ _layout->set_text (buf);
}
- _layout->set_text (buf);
-
if (_with_info) {
framecnt_t rate = _session->frame_rate();
@@ -1038,9 +1065,13 @@ AudioClock::set_minsec (framepos_t when, bool /*force*/)
return;
}
- print_minsec (when, buf, sizeof (buf), _session->frame_rate());
+ if (when >= _limit_pos || when <= -_limit_pos) {
+ set_out_of_bounds (when < 0);
+ } else {
+ print_minsec (when, buf, sizeof (buf), _session->frame_rate());
+ _layout->set_text (buf);
+ }
- _layout->set_text (buf);
set_slave_info();
}
@@ -1061,6 +1092,11 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
when = -when;
negative = true;
}
+ if (when >= _limit_pos) {
+ set_out_of_bounds (negative);
+ set_slave_info();
+ return;
+ }
if (is_duration) {
_session->timecode_duration (when, TC);
@@ -1082,7 +1118,7 @@ AudioClock::set_bbt (framepos_t when, framecnt_t offset, bool /*force*/)
Timecode::BBT_Time BBT;
bool negative = false;
- if (_off) {
+ if (_off || when >= _limit_pos || when < -_limit_pos) {
_layout->set_text (" ---|--|----");
_left_btn.set_text ("", true);
_right_btn.set_text ("", true);
@@ -1187,6 +1223,11 @@ AudioClock::set_session (Session *s)
if (_session) {
+ int64_t limit_sec = UIConfiguration::instance().get_clock_display_limit ();
+ if (limit_sec > 0) {
+ _limit_pos = (framecnt_t) floor (limit_sec * _session->frame_rate());
+ }
+
Config->ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
_session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
_session->tempo_map().PropertyChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_property_changed, this, _1), gui_context());
diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h
index f76e9db02d..82b12b0eca 100644
--- a/gtk2_ardour/audio_clock.h
+++ b/gtk2_ardour/audio_clock.h
@@ -130,6 +130,8 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
bool _negative_allowed;
bool edit_is_negative;
+ framepos_t _limit_pos;
+
Glib::RefPtr<Pango::Layout> _layout;
bool _with_info;
@@ -207,6 +209,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
void set_bbt (framepos_t, ARDOUR::framecnt_t, bool);
void set_minsec (framepos_t, bool);
void set_frames (framepos_t, bool);
+ void set_out_of_bounds (bool negative);
void set_clock_dimensions (Gtk::Requisition&);
diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.h
index ae94452c96..1d2e5a1bb0 100644
--- a/gtk2_ardour/ui_config_vars.h
+++ b/gtk2_ardour/ui_config_vars.h
@@ -60,6 +60,7 @@ UI_CONFIG_VARIABLE (bool, show_region_gain, "show-region-gain", false)
UI_CONFIG_VARIABLE (bool, show_name_highlight, "show-name-highlight", false)
UI_CONFIG_VARIABLE (bool, primary_clock_delta_edit_cursor, "primary-clock-delta-edit-cursor", false)
UI_CONFIG_VARIABLE (bool, secondary_clock_delta_edit_cursor, "secondary-clock-delta-edit-cursor", false)
+UI_CONFIG_VARIABLE (uint64_t, clock_display_limit, "clock-display-limit", 2592000) /* seconds; default 30days (720h), 0 = unlimited */
UI_CONFIG_VARIABLE (bool, show_track_meters, "show-track-meters", true)
UI_CONFIG_VARIABLE (bool, editor_stereo_only_meters, "editor-stereo-only-meters", false)
UI_CONFIG_VARIABLE (bool, follow_edits, "follow-edits", false)