diff options
author | Robin Gareus <robin@gareus.org> | 2017-02-14 17:15:16 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-02-14 17:15:16 +0100 |
commit | 8eff36913c91bfd5731b6d1cdaa7f0250de7b6e6 (patch) | |
tree | 29beb51d602646ae9bed19563174aa2570d3292a /gtk2_ardour/location_ui.cc | |
parent | cf66f894bb5f776b78d1a8b2301d72598f37999f (diff) |
Save/restore location clock mode
- save mode separately for Editor-sidebar and Location Window
- cache mode (multiple calls to set_session())
- fix restore: after creating the editor, instant_save() is called,
potentially overwriting the previous value.
Diffstat (limited to 'gtk2_ardour/location_ui.cc')
-rw-r--r-- | gtk2_ardour/location_ui.cc | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/gtk2_ardour/location_ui.cc b/gtk2_ardour/location_ui.cc index 4bdc9798c5..7aeced896e 100644 --- a/gtk2_ardour/location_ui.cc +++ b/gtk2_ardour/location_ui.cc @@ -750,9 +750,12 @@ LocationEditRow::set_clock_editable_status () /*------------------------------------------------------------------------*/ -LocationUI::LocationUI () +LocationUI::LocationUI (std::string state_node_name) : add_location_button (_("New Marker")) , add_range_button (_("New Range")) + , _mode (AudioClock::Frames) + , _mode_set (false) + , _state_node_name (state_node_name) { i_am_the_modifier = 0; @@ -1111,6 +1114,8 @@ LocationUI::set_session(ARDOUR::Session* s) _session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::refresh_location_list, this), gui_context()); _clock_group->set_clock_mode (clock_mode_from_session_instant_xml ()); + } else { + _mode_set = false; } loop_edit_row.set_session (s); @@ -1137,21 +1142,49 @@ LocationUI::session_going_away() punch_edit_row.set_session (0); punch_edit_row.set_location (0); + _mode_set = false; + SessionHandlePtr::session_going_away (); } XMLNode & LocationUI::get_state () const { - XMLNode* node = new XMLNode (X_("LocationUI")); - node->add_property (X_("clock-mode"), enum_2_string (_clock_group->clock_mode ())); + XMLNode* node = new XMLNode (_state_node_name); + if (_mode_set) { + node->add_property (X_("clock-mode"), enum_2_string (_mode)); + } else { + node->add_property (X_("clock-mode"), enum_2_string (_clock_group->clock_mode ())); + } return *node; } +int +LocationUI::set_state (const XMLNode& node) +{ + if (node.name() != _state_node_name) { + return -1; + } + XMLProperty const* p = node.property (X_("clock-mode")); + if (!p) { + return -1; + } + _mode = (AudioClock::Mode) string_2_enum (p->value (), AudioClock::Mode); + _mode_set = true; + if (_clock_group) { + _clock_group->set_clock_mode (_mode); + } + return 0; +} + AudioClock::Mode -LocationUI::clock_mode_from_session_instant_xml () const +LocationUI::clock_mode_from_session_instant_xml () { - XMLNode* node = _session->instant_xml (X_("LocationUI")); + if (_mode_set) { + return _mode; + } + + XMLNode* node = _session->instant_xml (_state_node_name); if (!node) { return AudioClock::Frames; } @@ -1161,7 +1194,9 @@ LocationUI::clock_mode_from_session_instant_xml () const return ARDOUR_UI::instance()->secondary_clock->mode(); } - return (AudioClock::Mode) string_2_enum (p->value (), AudioClock::Mode); + _mode = (AudioClock::Mode) string_2_enum (p->value (), AudioClock::Mode); + _mode_set = true; + return _mode; } |