mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
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.
This commit is contained in:
parent
cf66f894bb
commit
8eff36913c
5 changed files with 69 additions and 10 deletions
|
|
@ -2552,6 +2552,7 @@ Editor::set_state (const XMLNode& node, int version)
|
||||||
for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
|
for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
|
||||||
selection->set_state (**i, Stateful::current_state_version);
|
selection->set_state (**i, Stateful::current_state_version);
|
||||||
_regions->set_state (**i);
|
_regions->set_state (**i);
|
||||||
|
_locations->set_state (**i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prop = node.property ("maximised"))) {
|
if ((prop = node.property ("maximised"))) {
|
||||||
|
|
@ -2693,6 +2694,7 @@ Editor::get_state ()
|
||||||
|
|
||||||
node->add_child_nocopy (LuaInstance::instance()->get_action_state());
|
node->add_child_nocopy (LuaInstance::instance()->get_action_state());
|
||||||
node->add_child_nocopy (LuaInstance::instance()->get_hook_state());
|
node->add_child_nocopy (LuaInstance::instance()->get_hook_state());
|
||||||
|
node->add_child_nocopy (_locations->get_state ());
|
||||||
|
|
||||||
return *node;
|
return *node;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ using namespace Gtk;
|
||||||
EditorLocations::EditorLocations (Editor* e)
|
EditorLocations::EditorLocations (Editor* e)
|
||||||
: EditorComponent (e)
|
: EditorComponent (e)
|
||||||
{
|
{
|
||||||
_locations = new LocationUI ();
|
_locations = new LocationUI (X_("EditorLocations"));
|
||||||
_scroller.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER);
|
_scroller.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER);
|
||||||
_scroller.add (*_locations);
|
_scroller.add (*_locations);
|
||||||
}
|
}
|
||||||
|
|
@ -45,3 +45,15 @@ EditorLocations::widget()
|
||||||
{
|
{
|
||||||
return _scroller;
|
return _scroller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XMLNode&
|
||||||
|
EditorLocations::get_state () const
|
||||||
|
{
|
||||||
|
return _locations->get_state();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
EditorLocations::set_state (const XMLNode& node)
|
||||||
|
{
|
||||||
|
return _locations->set_state(node);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
#ifndef __gtk_ardour_editor_locations_h__
|
#ifndef __gtk_ardour_editor_locations_h__
|
||||||
#define __gtk_ardour_editor_locations_h__
|
#define __gtk_ardour_editor_locations_h__
|
||||||
|
|
||||||
|
#include "pbd/xml++.h"
|
||||||
|
|
||||||
#include <gtkmm/scrolledwindow.h>
|
#include <gtkmm/scrolledwindow.h>
|
||||||
#include "ardour/session_handle.h"
|
#include "ardour/session_handle.h"
|
||||||
#include "editor_component.h"
|
#include "editor_component.h"
|
||||||
|
|
@ -38,6 +40,8 @@ class EditorLocations : public EditorComponent, public ARDOUR::SessionHandlePtr
|
||||||
void set_session (ARDOUR::Session *);
|
void set_session (ARDOUR::Session *);
|
||||||
|
|
||||||
Gtk::Widget& widget ();
|
Gtk::Widget& widget ();
|
||||||
|
XMLNode & get_state () const;
|
||||||
|
int set_state (const XMLNode&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Gtk::ScrolledWindow _scroller;
|
Gtk::ScrolledWindow _scroller;
|
||||||
|
|
|
||||||
|
|
@ -750,9 +750,12 @@ LocationEditRow::set_clock_editable_status ()
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
LocationUI::LocationUI ()
|
LocationUI::LocationUI (std::string state_node_name)
|
||||||
: add_location_button (_("New Marker"))
|
: add_location_button (_("New Marker"))
|
||||||
, add_range_button (_("New Range"))
|
, add_range_button (_("New Range"))
|
||||||
|
, _mode (AudioClock::Frames)
|
||||||
|
, _mode_set (false)
|
||||||
|
, _state_node_name (state_node_name)
|
||||||
{
|
{
|
||||||
i_am_the_modifier = 0;
|
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());
|
_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 ());
|
_clock_group->set_clock_mode (clock_mode_from_session_instant_xml ());
|
||||||
|
} else {
|
||||||
|
_mode_set = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
loop_edit_row.set_session (s);
|
loop_edit_row.set_session (s);
|
||||||
|
|
@ -1137,21 +1142,49 @@ LocationUI::session_going_away()
|
||||||
punch_edit_row.set_session (0);
|
punch_edit_row.set_session (0);
|
||||||
punch_edit_row.set_location (0);
|
punch_edit_row.set_location (0);
|
||||||
|
|
||||||
|
_mode_set = false;
|
||||||
|
|
||||||
SessionHandlePtr::session_going_away ();
|
SessionHandlePtr::session_going_away ();
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLNode &
|
XMLNode &
|
||||||
LocationUI::get_state () const
|
LocationUI::get_state () const
|
||||||
{
|
{
|
||||||
XMLNode* node = new XMLNode (X_("LocationUI"));
|
XMLNode* node = new XMLNode (_state_node_name);
|
||||||
node->add_property (X_("clock-mode"), enum_2_string (_clock_group->clock_mode ()));
|
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;
|
return *node;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioClock::Mode
|
int
|
||||||
LocationUI::clock_mode_from_session_instant_xml () const
|
LocationUI::set_state (const XMLNode& node)
|
||||||
{
|
{
|
||||||
XMLNode* node = _session->instant_xml (X_("LocationUI"));
|
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 ()
|
||||||
|
{
|
||||||
|
if (_mode_set) {
|
||||||
|
return _mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLNode* node = _session->instant_xml (_state_node_name);
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return AudioClock::Frames;
|
return AudioClock::Frames;
|
||||||
}
|
}
|
||||||
|
|
@ -1161,7 +1194,9 @@ LocationUI::clock_mode_from_session_instant_xml () const
|
||||||
return ARDOUR_UI::instance()->secondary_clock->mode();
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ protected:
|
||||||
class LocationUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
|
class LocationUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LocationUI ();
|
LocationUI (std::string state_node_name = "LocationUI");
|
||||||
~LocationUI ();
|
~LocationUI ();
|
||||||
|
|
||||||
void set_session (ARDOUR::Session *);
|
void set_session (ARDOUR::Session *);
|
||||||
|
|
@ -165,6 +165,7 @@ public:
|
||||||
void refresh_location_list ();
|
void refresh_location_list ();
|
||||||
|
|
||||||
XMLNode & get_state () const;
|
XMLNode & get_state () const;
|
||||||
|
int set_state (const XMLNode&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** set to the location that has just been created with the LocationUI `add' button
|
/** set to the location that has just been created with the LocationUI `add' button
|
||||||
|
|
@ -209,7 +210,12 @@ private:
|
||||||
void map_locations (const ARDOUR::Locations::LocationList&);
|
void map_locations (const ARDOUR::Locations::LocationList&);
|
||||||
|
|
||||||
ClockGroup* _clock_group;
|
ClockGroup* _clock_group;
|
||||||
AudioClock::Mode clock_mode_from_session_instant_xml () const;
|
AudioClock::Mode clock_mode_from_session_instant_xml ();
|
||||||
|
|
||||||
|
AudioClock::Mode _mode;
|
||||||
|
bool _mode_set;
|
||||||
|
|
||||||
|
std::string _state_node_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LocationUIWindow : public ArdourWindow
|
class LocationUIWindow : public ArdourWindow
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue