13
0

Make clock mode settings session independent

Much like the edit-tool and grid-types, clock-modes are UI state.

Saving the UI state separately allows them to be used
consistently for new sessions. Previously clock-modes were set
initially (at application start) and when loading sessions.

The clock modes of newly created sessions was different
depending on loading another session prior to creating the
session. This is now no longer the case.
This commit is contained in:
Robin Gareus 2022-10-10 21:03:07 +02:00
parent 6ad3dc1e43
commit 0bf8e7d8cf
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
7 changed files with 156 additions and 42 deletions

View File

@ -126,7 +126,6 @@
#include "temporal/time.h"
#include "about.h"
#include "enums_convert.h"
#include "actions.h"
#include "add_route_dialog.h"
#include "ardour_message.h"
@ -2995,30 +2994,6 @@ what you would like to do.\n"), PROGRAM_NAME));
}
}
void
ARDOUR_UI::store_clock_modes ()
{
if (session_load_in_progress) {
/* Do not overwrite clock modes while loading them (with a session) */
return;
}
XMLNode* node = new XMLNode(X_("ClockModes"));
for (vector<AudioClock*>::iterator x = AudioClock::clocks.begin(); x != AudioClock::clocks.end(); ++x) {
XMLNode* child = new XMLNode (X_("Clock"));
child->set_property (X_("name"), (*x)->name());
child->set_property (X_("mode"), (*x)->mode());
child->set_property (X_("on"), (*x)->on());
node->add_child_nocopy (*child);
}
_session->add_extra_xml (*node);
_session->set_dirty ();
}
/** Allocate our thread-local buffers */
void
ARDOUR_UI::get_process_buffers ()

View File

@ -290,6 +290,7 @@ public:
XMLNode* trigger_page_settings () const;
XMLNode* recorder_settings () const;
XMLNode* keyboard_settings () const;
XMLNode* clock_mode_settings () const;
XMLNode* tearoff_settings (const char*) const;
void save_ardour_state ();
@ -308,8 +309,6 @@ public:
VideoTimeLine *video_timeline;
void store_clock_modes ();
void restore_clock_modes ();
void reset_main_clocks ();
void synchronize_sync_source_and_video_pullup ();

View File

@ -221,8 +221,6 @@ ARDOUR_UI::set_session (Session *s)
back to the session XML ("Extra") state.
*/
AudioClock::ModeChanged.connect (sigc::mem_fun (*this, &ARDOUR_UI::store_clock_modes));
Glib::signal_idle().connect (sigc::mem_fun (*this, &ARDOUR_UI::first_idle));
start_clocking ();

View File

@ -45,6 +45,7 @@
#include "pbd/fpu.h"
#include "pbd/convert.h"
#include "pbd/openuri.h"
#include "pbd/types_convert.h"
#include "gtkmm2ext/cairo_packer.h"
#include "gtkmm2ext/utils.h"
@ -61,6 +62,7 @@
#include "engine_dialog.h"
#include "editor.h"
#include "editing.h"
#include "enums_convert.h"
#include "actions.h"
#include "meterbridge.h"
#include "luawindow.h"
@ -945,6 +947,16 @@ ARDOUR_UI::save_ardour_state ()
XMLNode& rnode (recorder->get_state());
XMLNode& tnode (trigger_page->get_state());
/* store clock modes */
XMLNode* cnode = new XMLNode(X_("ClockModes"));
for (auto const& i: AudioClock::clocks) {
XMLNode* child = new XMLNode (X_("Clock"));
child->set_property (X_("name"), i->name());
child->set_property (X_("mode"), i->mode());
child->set_property (X_("on"), i->on());
cnode->add_child_nocopy (*child);
}
Config->add_extra_xml (*window_node);
Config->add_extra_xml (audio_midi_setup->get_state());
@ -962,6 +974,7 @@ ARDOUR_UI::save_ardour_state ()
_session->add_instant_xml (bnode);
_session->add_instant_xml (rnode);
_session->add_instant_xml (tnode);
_session->add_instant_xml (*cnode);
if (location_ui) {
_session->add_instant_xml (location_ui->ui().get_state ());
}
@ -981,6 +994,7 @@ ARDOUR_UI::save_ardour_state ()
Config->add_instant_xml (bnode);
Config->add_instant_xml (rnode);
Config->add_instant_xml (tnode);
Config->add_instant_xml (*cnode);
if (location_ui) {
Config->add_instant_xml (location_ui->ui().get_state ());
}
@ -997,6 +1011,7 @@ ARDOUR_UI::save_ardour_state ()
delete &pnode;
delete &rnode;
delete &tnode;
delete cnode;
Keyboard::save_keybindings ();
}

View File

@ -356,6 +356,23 @@ ARDOUR_UI::trigger_page_settings () const
return node;
}
XMLNode*
ARDOUR_UI::clock_mode_settings () const
{
XMLNode* node = 0;
if (_session) {
node = _session->instant_xml(X_("ClockModes"));
}
if (!node) {
node = Config->instant_xml(X_("ClockModes"));
}
if (!node) {
node = new XMLNode (X_("ClockModes"));
}
return node;
}
XMLNode*
ARDOUR_UI::keyboard_settings () const
{

View File

@ -1373,23 +1373,26 @@ AudioClock::set_session (Session *s)
Config->ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
_session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
/* try load v6 style settings (session file) */
XMLNode* node = _session->extra_xml (X_("ClockModes"));
if (!node) {
/* get new v7+ settings from instant_xml */
node = ARDOUR_UI::instance ()->clock_mode_settings ();
}
if (node) {
for (XMLNodeList::const_iterator i = node->children().begin(); i != node->children().end(); ++i) {
std::string name;
if ((*i)->get_property (X_("name"), name) && name == _name) {
for (XMLNodeList::const_iterator i = node->children().begin(); i != node->children().end(); ++i) {
std::string name;
if ((*i)->get_property (X_("name"), name) && name == _name) {
AudioClock::Mode amode;
if ((*i)->get_property (X_("mode"), amode)) {
set_mode (amode, true);
}
bool on;
if ((*i)->get_property (X_("on"), on)) {
set_off (!on);
}
break;
AudioClock::Mode amode;
if ((*i)->get_property (X_("mode"), amode)) {
set_mode (amode, true);
}
bool on;
if ((*i)->get_property (X_("on"), on)) {
set_off (!on);
}
break;
}
}

View File

@ -0,0 +1,107 @@
/*
Copyright (C) 2016 Robin Gareus <robin@gareus.org>
Copyright (C) 2006 Paul Davis
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __ardour_pluginwrap_h__
#define __ardour_pluginwrap_h__
#include "ardour/types.h"
#include "ardour/plugin.h"
namespace ARDOUR {
class LIBARDOUR_API PluginWrap : public ARDOUR::Plugin {
public:
LuaProc (AudioEngine&, Session&, const std::string&);
LuaProc (const LuaProc &);
std::string state_node_name() const { return "plugwrap"; }
void add_state (XMLNode *) const;
int set_state (const XMLNode&, int version);
std::string unique_id() const { return get_info()->unique_id; }
const char* name() const { return get_info()->name.c_str(); }
const char* label() const { return get_info()->name.c_str(); }
const char* maker() const { return get_info()->creator.c_str(); }
uint32_t parameter_count() const;
float default_value (uint32_t port);
void set_parameter (uint32_t port, float val, sampleoffset_t);
float get_parameter (uint32_t port) const;
int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
uint32_t nth_parameter (uint32_t port, bool& ok) const;
std::string get_docs () const { return _docs; }
std::string get_parameter_docs (uint32_t) const;
void activate () { }
void deactivate () { }
void cleanup () { }
int set_block_size (pframes_t /*nframes*/) { return 0; }
samplecnt_t signal_latency() const { return _signal_latency; }
int connect_and_run (BufferSet& bufs,
samplepos_t start, samplepos_t end, double speed,
ChanMapping in, ChanMapping out,
pframes_t nframes, samplecnt_t offset);
std::set<Evoral::Parameter> automatable() const;
std::string describe_parameter (Evoral::Parameter);
boost::shared_ptr<ScalePoints> get_scale_points(uint32_t port_index) const;
bool parameter_is_audio (uint32_t) const { return false; }
bool parameter_is_control (uint32_t) const { return true; }
bool parameter_is_input (uint32_t) const;
bool parameter_is_output (uint32_t) const;
uint32_t designated_bypass_port ();
bool load_preset (PresetRecord);
std::string do_save_preset (std::string);
void do_remove_preset (std::string);
bool has_editor() const { return false; }
bool can_support_io_configuration (const ChanCount& in, ChanCount& out, ChanCount* imprecise);
bool configure_io (ChanCount in, ChanCount out);
ChanCount output_streams() const { return _configured_out; }
ChanCount input_streams() const { return _configured_in; }
private:
void find_presets ();
};
class LIBARDOUR_API PluginWrapInfo : public PluginInfo
{
public:
PluginWrapInfo (LuaScriptInfoPtr lsi);
PluginPtr load (Session& session);
std::vector<Plugin::PresetRecord> get_presets (bool user_only) const;
};
typedef boost::shared_ptr<PluginWrapInfo> PluginWrapInfoPtr;
} // namespace ARDOUR
#endif