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)
{
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);
}

View File

@ -297,8 +297,8 @@ ARDOUR_UI::setup_transport ()
/* clocks, etc. */
ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (primary_clock, &AudioClock::set), 'p'));
ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (secondary_clock, &AudioClock::set), 's'));
ARDOUR_UI::Clock.connect (sigc::mem_fun (primary_clock, &AudioClock::set));
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));
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
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);

View File

@ -114,6 +114,10 @@ AudioClock::set_widget_name (const string& str)
} else {
set_name (str + " clock");
}
if (is_realized()) {
set_colors ();
}
}
@ -660,39 +664,20 @@ AudioClock::session_configuration_changed (std::string p)
}
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) {
@ -1160,7 +1145,7 @@ AudioClock::on_button_press_event (GdkEventButton *ev)
{
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 ,
@ -1172,8 +1157,17 @@ AudioClock::on_button_press_event (GdkEventButton *ev)
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);
@ -1192,7 +1186,7 @@ AudioClock::on_button_press_event (GdkEventButton *ev)
bool
AudioClock::on_button_release_event (GdkEventButton *ev)
{
if (editable) {
if (editable && !_off) {
if (dragging) {
gdk_pointer_ungrab (GDK_CURRENT_TIME);
dragging = false;
@ -1238,11 +1232,21 @@ AudioClock::on_scroll_event (GdkEventScroll *ev)
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;
}
@ -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 (_("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)));
@ -1668,7 +1672,7 @@ AudioClock::set_is_duration (bool yn)
}
is_duration = yn;
set (last_when, true, 0, 's');
set (last_when, true);
}
void

View File

@ -62,7 +62,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
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 locate ();
void set_mode (Mode);

View File

@ -1213,10 +1213,11 @@ Editor::set_session (Session *t)
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 ();

View File

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