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
|
@ -942,9 +942,9 @@ AutomationTimeAxisView::set_state_2X (const XMLNode& node, int /*version*/)
|
|||
if (yn) {
|
||||
_canvas_display->show (); /* FIXME: necessary? show_at? */
|
||||
}
|
||||
set_gui_property ("visible", (yn ? "yes" : "no"));
|
||||
set_gui_property ("visible", yn);
|
||||
} 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
|
||||
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
|
||||
|
@ -126,9 +114,9 @@ AxisView::set_marked_for_display (bool yn)
|
|||
{
|
||||
if (yn != marked_for_display()) {
|
||||
if (yn) {
|
||||
set_gui_property ("visible", "yes");
|
||||
set_gui_property ("visible", true);
|
||||
} else {
|
||||
set_gui_property ("visible", "no");
|
||||
set_gui_property ("visible", false);
|
||||
}
|
||||
return true; // things changed
|
||||
}
|
||||
|
@ -136,3 +124,8 @@ AxisView::set_marked_for_display (bool yn)
|
|||
return false;
|
||||
}
|
||||
|
||||
GUIObjectState&
|
||||
AxisView::gui_object_state()
|
||||
{
|
||||
return *ARDOUR_UI::instance()->gui_object_state;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "ardour/session_handle.h"
|
||||
|
||||
#include "gui_object.h"
|
||||
#include "prompter.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; }
|
||||
|
||||
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;
|
||||
|
||||
void set_gui_property (const std::string& property_name, const std::string& value);
|
||||
void set_gui_property (const std::string& property_name, int value);
|
||||
void set_gui_property (const std::string& property_name, double value);
|
||||
|
||||
template<typename T> void set_gui_property (const std::string& property_name, const T& value) {
|
||||
gui_object_state().set<T> (state_id(), property_name, value);
|
||||
}
|
||||
|
||||
bool marked_for_display () const;
|
||||
virtual bool set_marked_for_display (bool);
|
||||
|
@ -92,6 +95,9 @@ class AxisView : public virtual Selectable, public PBD::ScopedConnectionList, pu
|
|||
bool _marked_for_display;
|
||||
uint32_t _old_order_key;
|
||||
|
||||
private:
|
||||
static GUIObjectState& gui_object_state();
|
||||
|
||||
}; /* class AxisView */
|
||||
|
||||
#endif /* __ardour_gtk_axis_view_h__ */
|
||||
|
|
|
@ -49,11 +49,6 @@ class gos_string_vistor : public boost::static_visitor<> {
|
|||
void operator() (const int64_t& i) {
|
||||
stream << i;
|
||||
}
|
||||
#if 0
|
||||
void operator() (const double& d) {
|
||||
stream << std::setprecision (12) << d;
|
||||
}
|
||||
#endif
|
||||
|
||||
void operator() (const std::string& s) {
|
||||
stream << s;
|
||||
|
@ -63,6 +58,40 @@ class gos_string_vistor : public boost::static_visitor<> {
|
|||
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&
|
||||
GUIObjectState::get_state () const
|
||||
{
|
||||
|
|
|
@ -29,6 +29,11 @@
|
|||
#include "pbd/id.h"
|
||||
|
||||
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:
|
||||
GUIObjectState() {}
|
||||
~GUIObjectState();
|
||||
|
@ -41,59 +46,22 @@ class GUIObjectState {
|
|||
|
||||
GUIObjectState& operator= (const GUIObjectState& other);
|
||||
|
||||
private:
|
||||
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);
|
||||
}
|
||||
std::string get_string (const std::string& id, const std::string& prop_name, bool* empty = 0);
|
||||
|
||||
template<typename T> void set (const std::string& id, const std::string& prop_name, const T& val) {
|
||||
StringPropertyMap::iterator i = _property_maps.find (id);
|
||||
|
||||
if (i != _property_maps.end()) {
|
||||
i->second[prop_name] = val;
|
||||
// std::cerr << id << " REset " << prop_name << " = [" << val << "]\n";
|
||||
} else {
|
||||
_property_maps[id] = PropertyMap();
|
||||
_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;
|
||||
|
||||
if (_packed) {
|
||||
set_gui_property ("visible", "yes");
|
||||
set_gui_property ("visible", true);
|
||||
} 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];
|
||||
|
||||
if (visible) {
|
||||
strip->set_gui_property ("visible", "yes");
|
||||
strip->set_gui_property ("visible", true);
|
||||
strip->route()->set_order_key (N_("signal"), order);
|
||||
|
||||
if (!strip_redisplay_does_not_reset_order_keys) {
|
||||
|
@ -778,7 +778,7 @@ Mixer_UI::redisplay_track_list ()
|
|||
|
||||
} else {
|
||||
|
||||
strip->set_gui_property ("visible", "no");
|
||||
strip->set_gui_property ("visible", false);
|
||||
|
||||
if (strip->route()->is_master() || strip->route()->is_monitor()) {
|
||||
/* do nothing, these cannot be hidden */
|
||||
|
|
|
@ -141,7 +141,11 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user