mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
clean up GUIObjectState API, and use bools when setting "visible" property rather than string (not that it matters); don't unconditionally set visible to true unless a non-hidden track/bus has no visibility property already
git-svn-id: svn://localhost/ardour2/branches/3.0@9843 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
58a3d6c720
commit
6dc74f8c87
8 changed files with 72 additions and 72 deletions
|
|
@ -942,9 +942,9 @@ AutomationTimeAxisView::set_state_2X (const XMLNode& node, int /*version*/)
|
||||||
if (yn) {
|
if (yn) {
|
||||||
_canvas_display->show (); /* FIXME: necessary? show_at? */
|
_canvas_display->show (); /* FIXME: necessary? show_at? */
|
||||||
}
|
}
|
||||||
set_gui_property ("visible", (yn ? "yes" : "no"));
|
set_gui_property ("visible", yn);
|
||||||
} else {
|
} else {
|
||||||
set_gui_property ("visible", "no");
|
set_gui_property ("visible", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,22 +97,10 @@ AxisView::unique_random_color()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AxisView::set_gui_property (const string& property_name, const string& value)
|
|
||||||
{
|
|
||||||
ARDOUR_UI::instance()->gui_object_state->set (state_id(), property_name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AxisView::set_gui_property (const string& property_name, int value)
|
|
||||||
{
|
|
||||||
ARDOUR_UI::instance()->gui_object_state->set (state_id(), property_name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
string
|
string
|
||||||
AxisView::gui_property (const string& property_name) const
|
AxisView::gui_property (const string& property_name) const
|
||||||
{
|
{
|
||||||
return ARDOUR_UI::instance()->gui_object_state->get_string (state_id(), property_name);
|
return gui_object_state().get_string (state_id(), property_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -126,9 +114,9 @@ AxisView::set_marked_for_display (bool yn)
|
||||||
{
|
{
|
||||||
if (yn != marked_for_display()) {
|
if (yn != marked_for_display()) {
|
||||||
if (yn) {
|
if (yn) {
|
||||||
set_gui_property ("visible", "yes");
|
set_gui_property ("visible", true);
|
||||||
} else {
|
} else {
|
||||||
set_gui_property ("visible", "no");
|
set_gui_property ("visible", false);
|
||||||
}
|
}
|
||||||
return true; // things changed
|
return true; // things changed
|
||||||
}
|
}
|
||||||
|
|
@ -136,3 +124,8 @@ AxisView::set_marked_for_display (bool yn)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GUIObjectState&
|
||||||
|
AxisView::gui_object_state()
|
||||||
|
{
|
||||||
|
return *ARDOUR_UI::instance()->gui_object_state;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "ardour/session_handle.h"
|
#include "ardour/session_handle.h"
|
||||||
|
|
||||||
|
#include "gui_object.h"
|
||||||
#include "prompter.h"
|
#include "prompter.h"
|
||||||
#include "selectable.h"
|
#include "selectable.h"
|
||||||
|
|
||||||
|
|
@ -61,11 +62,13 @@ class AxisView : public virtual Selectable, public PBD::ScopedConnectionList, pu
|
||||||
uint32_t old_order_key() const { return _old_order_key; }
|
uint32_t old_order_key() const { return _old_order_key; }
|
||||||
|
|
||||||
virtual std::string state_id() const = 0;
|
virtual std::string state_id() const = 0;
|
||||||
|
/* for now, we always return properties in string form.
|
||||||
|
*/
|
||||||
std::string gui_property (const std::string& property_name) const;
|
std::string gui_property (const std::string& property_name) const;
|
||||||
|
|
||||||
void set_gui_property (const std::string& property_name, const std::string& value);
|
template<typename T> void set_gui_property (const std::string& property_name, const T& value) {
|
||||||
void set_gui_property (const std::string& property_name, int value);
|
gui_object_state().set<T> (state_id(), property_name, value);
|
||||||
void set_gui_property (const std::string& property_name, double value);
|
}
|
||||||
|
|
||||||
bool marked_for_display () const;
|
bool marked_for_display () const;
|
||||||
virtual bool set_marked_for_display (bool);
|
virtual bool set_marked_for_display (bool);
|
||||||
|
|
@ -92,6 +95,9 @@ class AxisView : public virtual Selectable, public PBD::ScopedConnectionList, pu
|
||||||
bool _marked_for_display;
|
bool _marked_for_display;
|
||||||
uint32_t _old_order_key;
|
uint32_t _old_order_key;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static GUIObjectState& gui_object_state();
|
||||||
|
|
||||||
}; /* class AxisView */
|
}; /* class AxisView */
|
||||||
|
|
||||||
#endif /* __ardour_gtk_axis_view_h__ */
|
#endif /* __ardour_gtk_axis_view_h__ */
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,6 @@ class gos_string_vistor : public boost::static_visitor<> {
|
||||||
void operator() (const int64_t& i) {
|
void operator() (const int64_t& i) {
|
||||||
stream << i;
|
stream << i;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
void operator() (const double& d) {
|
|
||||||
stream << std::setprecision (12) << d;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void operator() (const std::string& s) {
|
void operator() (const std::string& s) {
|
||||||
stream << s;
|
stream << s;
|
||||||
|
|
@ -63,6 +58,40 @@ class gos_string_vistor : public boost::static_visitor<> {
|
||||||
std::ostream& stream;
|
std::ostream& stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::string
|
||||||
|
GUIObjectState::get_string (const std::string& id, const std::string& prop_name, bool* empty)
|
||||||
|
{
|
||||||
|
StringPropertyMap::iterator i = _property_maps.find (id);
|
||||||
|
|
||||||
|
if (i == _property_maps.end()) {
|
||||||
|
if (empty) {
|
||||||
|
*empty = true;
|
||||||
|
}
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
|
||||||
|
const PropertyMap& pmap (i->second);
|
||||||
|
PropertyMap::const_iterator p = pmap.find (prop_name);
|
||||||
|
|
||||||
|
if (p == pmap.end()) {
|
||||||
|
if (empty) {
|
||||||
|
*empty = true;
|
||||||
|
}
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::stringstream ss;
|
||||||
|
gos_string_vistor gsv (ss);
|
||||||
|
|
||||||
|
boost::apply_visitor (gsv, p->second);
|
||||||
|
|
||||||
|
if (empty) {
|
||||||
|
*empty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ss.str ();
|
||||||
|
}
|
||||||
|
|
||||||
XMLNode&
|
XMLNode&
|
||||||
GUIObjectState::get_state () const
|
GUIObjectState::get_state () const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,11 @@
|
||||||
#include "pbd/id.h"
|
#include "pbd/id.h"
|
||||||
|
|
||||||
class GUIObjectState {
|
class GUIObjectState {
|
||||||
|
private:
|
||||||
|
typedef boost::variant<int64_t,std::string> Variant;
|
||||||
|
typedef std::map<std::string,Variant> PropertyMap;
|
||||||
|
typedef std::map<std::string,PropertyMap> StringPropertyMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GUIObjectState() {}
|
GUIObjectState() {}
|
||||||
~GUIObjectState();
|
~GUIObjectState();
|
||||||
|
|
@ -41,59 +46,22 @@ class GUIObjectState {
|
||||||
|
|
||||||
GUIObjectState& operator= (const GUIObjectState& other);
|
GUIObjectState& operator= (const GUIObjectState& other);
|
||||||
|
|
||||||
private:
|
std::string get_string (const std::string& id, const std::string& prop_name, bool* empty = 0);
|
||||||
typedef boost::variant<int64_t,std::string> Variant;
|
|
||||||
typedef std::map<std::string,Variant> PropertyMap;
|
|
||||||
typedef std::map<std::string,PropertyMap> StringPropertyMap;
|
|
||||||
|
|
||||||
StringPropertyMap _property_maps;
|
|
||||||
|
|
||||||
template<typename T> T get (const std::string& id, const std::string& prop_name, const T& type_determination_placeholder, bool* empty = 0) {
|
|
||||||
StringPropertyMap::iterator i = _property_maps.find (id);
|
|
||||||
|
|
||||||
if (i == _property_maps.end()) {
|
|
||||||
if (empty) {
|
|
||||||
*empty = true;
|
|
||||||
}
|
|
||||||
return T();
|
|
||||||
}
|
|
||||||
|
|
||||||
const PropertyMap& pmap (i->second);
|
|
||||||
PropertyMap::const_iterator p = pmap.find (prop_name);
|
|
||||||
|
|
||||||
if (p == pmap.end()) {
|
|
||||||
return T();
|
|
||||||
}
|
|
||||||
|
|
||||||
return boost::get<T> (p->second);
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_maps ();
|
|
||||||
|
|
||||||
public:
|
|
||||||
int get_int (const std::string& id, const std::string& prop_name) {
|
|
||||||
int i = 0;
|
|
||||||
return get (id, prop_name, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string get_string (const std::string& id, const std::string& prop_name) {
|
|
||||||
std::string s;
|
|
||||||
return get (id, prop_name, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> void set (const std::string& id, const std::string& prop_name, const T& val) {
|
template<typename T> void set (const std::string& id, const std::string& prop_name, const T& val) {
|
||||||
StringPropertyMap::iterator i = _property_maps.find (id);
|
StringPropertyMap::iterator i = _property_maps.find (id);
|
||||||
|
|
||||||
if (i != _property_maps.end()) {
|
if (i != _property_maps.end()) {
|
||||||
i->second[prop_name] = val;
|
i->second[prop_name] = val;
|
||||||
// std::cerr << id << " REset " << prop_name << " = [" << val << "]\n";
|
|
||||||
} else {
|
} else {
|
||||||
_property_maps[id] = PropertyMap();
|
_property_maps[id] = PropertyMap();
|
||||||
_property_maps[id][prop_name] = val;
|
_property_maps[id][prop_name] = val;
|
||||||
// std::cerr << id << " set " << prop_name << " = [" << val << "]\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
|
StringPropertyMap _property_maps;
|
||||||
|
|
||||||
|
void clear_maps ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -619,9 +619,9 @@ MixerStrip::set_packed (bool yn)
|
||||||
_packed = yn;
|
_packed = yn;
|
||||||
|
|
||||||
if (_packed) {
|
if (_packed) {
|
||||||
set_gui_property ("visible", "yes");
|
set_gui_property ("visible", true);
|
||||||
} else {
|
} else {
|
||||||
set_gui_property ("visible", "no");
|
set_gui_property ("visible", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -750,7 +750,7 @@ Mixer_UI::redisplay_track_list ()
|
||||||
bool visible = (*i)[track_columns.visible];
|
bool visible = (*i)[track_columns.visible];
|
||||||
|
|
||||||
if (visible) {
|
if (visible) {
|
||||||
strip->set_gui_property ("visible", "yes");
|
strip->set_gui_property ("visible", true);
|
||||||
strip->route()->set_order_key (N_("signal"), order);
|
strip->route()->set_order_key (N_("signal"), order);
|
||||||
|
|
||||||
if (!strip_redisplay_does_not_reset_order_keys) {
|
if (!strip_redisplay_does_not_reset_order_keys) {
|
||||||
|
|
@ -778,7 +778,7 @@ Mixer_UI::redisplay_track_list ()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
strip->set_gui_property ("visible", "no");
|
strip->set_gui_property ("visible", false);
|
||||||
|
|
||||||
if (strip->route()->is_master() || strip->route()->is_monitor()) {
|
if (strip->route()->is_master() || strip->route()->is_monitor()) {
|
||||||
/* do nothing, these cannot be hidden */
|
/* do nothing, these cannot be hidden */
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,11 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_route->is_hidden()) {
|
if (!_route->is_hidden()) {
|
||||||
set_gui_property ("visible", "yes");
|
if (gui_property ("visible").empty()) {
|
||||||
|
set_gui_property ("visible", true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
set_gui_property ("visible", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
mute_changed (0);
|
mute_changed (0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue