fix some issues with delta clocks, while introducing a couple more since the clock can now show +ve and -ve offsets, but -ve ones computed incorrectly for timecode and BBT

git-svn-id: svn://localhost/ardour2/branches/3.0@10681 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-11-18 18:06:16 +00:00
parent 8b5d64ce9f
commit 792df333a2
7 changed files with 45 additions and 40 deletions

View file

@ -3596,13 +3596,13 @@ void
ARDOUR_UI::update_transport_clocks (framepos_t pos) ARDOUR_UI::update_transport_clocks (framepos_t pos)
{ {
if (Config->get_primary_clock_delta_edit_cursor()) { 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 { } else {
primary_clock->set (pos, 0, true); primary_clock->set (pos);
} }
if (Config->get_secondary_clock_delta_edit_cursor()) { 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 { } else {
secondary_clock->set (pos); secondary_clock->set (pos);
} }

View file

@ -297,8 +297,8 @@ ARDOUR_UI::setup_transport ()
/* clocks, etc. */ /* clocks, etc. */
ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (primary_clock, &AudioClock::set), 'p')); ARDOUR_UI::Clock.connect (sigc::mem_fun (primary_clock, &AudioClock::set));
ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (secondary_clock, &AudioClock::set), 's')); ARDOUR_UI::Clock.connect (sigc::mem_fun (secondary_clock, &AudioClock::set));
primary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed)); primary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
secondary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed)); secondary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));

View file

@ -633,7 +633,7 @@ ARDOUR_UI::use_menubar_as_top_menubar ()
void void
ARDOUR_UI::setup_clock () ARDOUR_UI::setup_clock ()
{ {
ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (big_clock, &AudioClock::set), false)); ARDOUR_UI::Clock.connect (sigc::mem_fun (big_clock, &AudioClock::set));
big_clock_window->set (new Window (WINDOW_TOPLEVEL), false); big_clock_window->set (new Window (WINDOW_TOPLEVEL), false);

View file

@ -114,6 +114,10 @@ AudioClock::set_widget_name (const string& str)
} else { } else {
set_name (str + " clock"); set_name (str + " clock");
} }
if (is_realized()) {
set_colors ();
}
} }
@ -660,39 +664,20 @@ AudioClock::session_configuration_changed (std::string p)
} }
void 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) { if ((!force && !is_visible()) || _session == 0) {
return; return;
} }
bool const pdelta = Config->get_primary_clock_delta_edit_cursor (); if (is_duration) {
bool const sdelta = Config->get_secondary_clock_delta_edit_cursor (); when = when - offset;
}
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 (when == last_when && !force) { if (when == last_when && !force) {
return; 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) { if (!editing) {
switch (_mode) { switch (_mode) {
@ -1160,7 +1145,7 @@ AudioClock::on_button_press_event (GdkEventButton *ev)
{ {
switch (ev->button) { switch (ev->button) {
case 1: case 1:
if (editable) { if (editable && !_off) {
dragging = true; dragging = true;
/* make absolutely sure that the pointer is grabbed */ /* make absolutely sure that the pointer is grabbed */
gdk_pointer_grab(ev->window,false , gdk_pointer_grab(ev->window,false ,
@ -1172,8 +1157,17 @@ AudioClock::on_button_press_event (GdkEventButton *ev)
int index; int index;
int trailing; 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); drag_field = index_to_field (index);
} else { } else {
drag_field = Field (0); drag_field = Field (0);
@ -1192,7 +1186,7 @@ AudioClock::on_button_press_event (GdkEventButton *ev)
bool bool
AudioClock::on_button_release_event (GdkEventButton *ev) AudioClock::on_button_release_event (GdkEventButton *ev)
{ {
if (editable) { if (editable && !_off) {
if (dragging) { if (dragging) {
gdk_pointer_ungrab (GDK_CURRENT_TIME); gdk_pointer_ungrab (GDK_CURRENT_TIME);
dragging = false; dragging = false;
@ -1238,11 +1232,21 @@ AudioClock::on_scroll_event (GdkEventScroll *ev)
int index; int index;
int trailing; int trailing;
if (_session == 0 || !editable) { if (_session == 0 || !editable || _off) {
return false; 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 */ /* not in the main layout */
return false; return false;
} }
@ -1572,7 +1576,7 @@ AudioClock::build_ops_menu ()
ops_items.push_back (MenuElem (_("Minutes:Seconds"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), MinSec))); 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))); 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 (SeparatorElem());
ops_items.push_back (MenuElem (_("Set From Playhead"), sigc::mem_fun(*this, &AudioClock::set_from_playhead))); 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))); ops_items.push_back (MenuElem (_("Locate to This Time"), sigc::mem_fun(*this, &AudioClock::locate)));
@ -1668,7 +1672,7 @@ AudioClock::set_is_duration (bool yn)
} }
is_duration = yn; is_duration = yn;
set (last_when, true, 0, 's'); set (last_when, true);
} }
void void

View file

@ -62,7 +62,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
void focus (); void focus ();
void set (framepos_t, bool force = false, ARDOUR::framecnt_t offset = 0, char which = 0); void set (framepos_t, bool force = false, ARDOUR::framecnt_t offset = 0);
void set_from_playhead (); void set_from_playhead ();
void locate (); void locate ();
void set_mode (Mode); void set_mode (Mode);

View file

@ -1213,10 +1213,11 @@ Editor::set_session (Session *t)
bbt.ticks = 120; bbt.ticks = 120;
framepos_t pos = _session->tempo_map().bbt_duration_at (0, bbt, 1); framepos_t pos = _session->tempo_map().bbt_duration_at (0, bbt, 1);
nudge_clock->set_mode(AudioClock::BBT); nudge_clock->set_mode(AudioClock::BBT);
nudge_clock->set (pos, true, 0, AudioClock::BBT); nudge_clock->set (pos, true);
} else { } 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 (); playhead_cursor->canvas_item.show ();

View file

@ -159,7 +159,7 @@ RegionLayeringOrderEditor::set_context (const string& a_name, Session* s, const
track_name_label.set_text (a_name); track_name_label.set_text (a_name);
clock.set_session (s); clock.set_session (s);
clock.set (pos, true, 0, 0); clock.set (pos, true);
playlist_modified_connection.disconnect (); playlist_modified_connection.disconnect ();
playlist = pl; playlist = pl;