ARDOUR_UI::update_transport_clocks (framepos_t pos)
{
if (Config->get_primary_clock_delta_edit_cursor()) {
- primary_clock->set (pos, false, editor->get_preferred_edit_position(), 1);
+ primary_clock->set (pos, false, editor->get_preferred_edit_position());
} else {
- primary_clock->set (pos, 0, true);
+ primary_clock->set (pos);
}
if (Config->get_secondary_clock_delta_edit_cursor()) {
- secondary_clock->set (pos, false, editor->get_preferred_edit_position(), 2);
+ secondary_clock->set (pos, false, editor->get_preferred_edit_position());
} else {
secondary_clock->set (pos);
}
} else {
set_name (str + " clock");
}
+
+ if (is_realized()) {
+ set_colors ();
+ }
}
}
void
-AudioClock::set (framepos_t when, bool force, framecnt_t offset, char which)
+AudioClock::set (framepos_t when, bool force, framecnt_t offset)
{
if ((!force && !is_visible()) || _session == 0) {
return;
}
- bool const pdelta = Config->get_primary_clock_delta_edit_cursor ();
- bool const sdelta = Config->get_secondary_clock_delta_edit_cursor ();
-
- if (offset && which == 'p' && pdelta) {
- when = (when > offset) ? when - offset : offset - when;
- } else if (offset && which == 's' && sdelta) {
- when = (when > offset) ? when - offset : offset - when;
- }
+ if (is_duration) {
+ when = when - offset;
+ }
if (when == last_when && !force) {
return;
}
- if (which == 'p' && pdelta && !last_pdelta) {
- set_name("TransportClockDisplayDelta");
- last_pdelta = true;
- } else if (which == 'p' && !pdelta && last_pdelta) {
- set_name("TransportClockDisplay");
- last_pdelta = false;
- } else if (which == 's' && sdelta && !last_sdelta) {
- set_name("SecondaryClockDisplayDelta");
- last_sdelta = true;
- } else if (which == 's' && !sdelta && last_sdelta) {
- set_name("SecondaryClockDisplay");
- last_sdelta = false;
- }
-
if (!editing) {
switch (_mode) {
{
switch (ev->button) {
case 1:
- if (editable) {
+ if (editable && !_off) {
dragging = true;
/* make absolutely sure that the pointer is grabbed */
gdk_pointer_grab(ev->window,false ,
int index;
int trailing;
+ int y;
+ int x;
- if (_layout->xy_to_index (ev->x * PANGO_SCALE, ev->y * PANGO_SCALE, index, trailing)) {
+ /* the text has been centered vertically, so adjust
+ * x and y.
+ */
+
+ y = ev->y - ((get_height() - layout_height)/2);
+ x = ev->x - x_leading_padding;
+
+ if (_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
drag_field = index_to_field (index);
} else {
drag_field = Field (0);
bool
AudioClock::on_button_release_event (GdkEventButton *ev)
{
- if (editable) {
+ if (editable && !_off) {
if (dragging) {
gdk_pointer_ungrab (GDK_CURRENT_TIME);
dragging = false;
int index;
int trailing;
- if (_session == 0 || !editable) {
+ if (_session == 0 || !editable || _off) {
return false;
}
- if (!_layout->xy_to_index (ev->x * PANGO_SCALE, ev->y * PANGO_SCALE, index, trailing)) {
+ int y;
+ int x;
+
+ /* the text has been centered vertically, so adjust
+ * x and y.
+ */
+
+ y = ev->y - ((get_height() - layout_height)/2);
+ x = ev->x - x_leading_padding;
+
+ if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
/* not in the main layout */
return false;
}
ops_items.push_back (MenuElem (_("Minutes:Seconds"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), MinSec)));
ops_items.push_back (MenuElem (_("Samples"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Frames)));
- if (editable && !is_duration && !_follows_playhead) {
+ if (editable && !_off && !is_duration && !_follows_playhead) {
ops_items.push_back (SeparatorElem());
ops_items.push_back (MenuElem (_("Set From Playhead"), sigc::mem_fun(*this, &AudioClock::set_from_playhead)));
ops_items.push_back (MenuElem (_("Locate to This Time"), sigc::mem_fun(*this, &AudioClock::locate)));
}
is_duration = yn;
- set (last_when, true, 0, 's');
+ set (last_when, true);
}
void
bbt.ticks = 120;
framepos_t pos = _session->tempo_map().bbt_duration_at (0, bbt, 1);
nudge_clock->set_mode(AudioClock::BBT);
- nudge_clock->set (pos, true, 0, AudioClock::BBT);
+ nudge_clock->set (pos, true);
} else {
- nudge_clock->set (_session->frame_rate() * 5, true, 0, AudioClock::Timecode); // default of 5 seconds
+ nudge_clock->set_mode (AudioClock::Timecode);
+ nudge_clock->set (_session->frame_rate() * 5, true);
}
playhead_cursor->canvas_item.show ();