From be026c88cf748f505e9ef3cce863d6efc09d5122 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 10 Jan 2007 21:21:07 +0000 Subject: [PATCH] save playhead + edit cursor, restore on session load; fix big clock editing (removed) and thread issues there git-svn-id: svn://localhost/ardour2/trunk@1300 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 5 +++- gtk2_ardour/editor.cc | 51 ++++++++++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 426e8e7014..b6142bbd59 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -109,7 +110,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile) /* big clock */ - big_clock (X_("bigclock"), false, "BigClockNonRecording", true, false, true), + big_clock (X_("bigclock"), false, "BigClockNonRecording", false, false, true), /* transport */ @@ -2400,6 +2401,8 @@ ARDOUR_UI::update_transport_clocks (nframes_t pos) void ARDOUR_UI::record_state_changed () { + ENSURE_GUI_THREAD (mem_fun (*this, &ARDOUR_UI::record_state_changed)); + if (!session || !big_clock_window) { /* why bother - the clock isn't visible */ return; diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index ebcf4ecad3..2e50a778df 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -900,6 +900,8 @@ Editor::instant_save () void Editor::reposition_x_origin (nframes_t frame) { + cerr << "repsosition to " << frame << endl; + if (frame != leftmost_frame) { leftmost_frame = frame; @@ -1140,6 +1142,13 @@ Editor::connect_to_session (Session *t) { session = t; + XMLNode* node = ARDOUR_UI::instance()->editor_settings(); + set_state (*node); + + /* catch up with the playhead */ + + session->request_locate (playhead_cursor->current_frame); + if (first_action_message) { first_action_message->hide(); } @@ -1236,27 +1245,12 @@ Editor::connect_to_session (Session *t) (static_cast(*i))->set_samples_per_unit (frames_per_unit); } - /* ::reposition_x_origin() doesn't work right here, since the old - position may be zero already, and it does nothing in such - circumstances. - */ - - leftmost_frame = 0; - - horizontal_adjustment.set_value (0); - restore_ruler_visibility (); //tempo_map_changed (Change (0)); session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks); - edit_cursor->set_position (0); - playhead_cursor->set_position (0); - start_scrolling (); - XMLNode* node = ARDOUR_UI::instance()->editor_settings(); - set_state (*node); - /* don't show master bus in a new session */ if (ARDOUR_UI::instance()->session_is_new ()) { @@ -2114,6 +2108,28 @@ Editor::set_state (const XMLNode& node) set_default_size (g.base_width, g.base_height); move (x, y); + if (session && (prop = node.property ("playhead"))) { + nframes_t pos = atol (prop->value().c_str()); + playhead_cursor->set_position (pos); + } else { + playhead_cursor->set_position (0); + + /* ::reposition_x_origin() doesn't work right here, since the old + position may be zero already, and it does nothing in such + circumstances. + */ + + leftmost_frame = 0; + horizontal_adjustment.set_value (0); + } + + if (session && (prop = node.property ("edit-cursor"))) { + nframes_t pos = atol (prop->value().c_str()); + edit_cursor->set_position (pos); + } else { + edit_cursor->set_position (0); + } + if ((prop = node.property ("zoom-focus"))) { set_zoom_focus ((ZoomFocus) atoi (prop->value())); } @@ -2263,6 +2279,11 @@ Editor::get_state () snprintf (buf, sizeof(buf), "%d", (int) snap_mode); node->add_property ("snap-mode", buf); + snprintf (buf, sizeof (buf), "%" PRIu32, playhead_cursor->current_frame); + node->add_property ("playhead", buf); + snprintf (buf, sizeof (buf), "%" PRIu32, edit_cursor->current_frame); + node->add_property ("edit-cursor", buf); + node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no"); node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no"); node->add_property ("show-measures", _show_measures ? "yes" : "no");