Remove attempt to retrieve invalid Meterbridge properties
[ardour.git] / gtk2_ardour / axis_view.h
1 /*
2     Copyright (C) 2003 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_gtk_axis_view_h__
21 #define __ardour_gtk_axis_view_h__
22
23 #include <list>
24 #include <boost/unordered_map.hpp>
25
26 #include <gtkmm/label.h>
27 #include <gdkmm/color.h>
28
29 #include "pbd/xml++.h"
30 #include "pbd/signals.h"
31
32 #include "ardour/session_handle.h"
33
34 #include "gui_object.h"
35 #include "prompter.h"
36 #include "selectable.h"
37
38 namespace PBD {
39         class Controllable;
40 }
41
42 namespace ARDOUR {
43         class Session;
44         class Stripable;
45         class PresentationInfo;
46 }
47
48 /**
49  * AxisView defines the abstract base class for horizontal and vertical
50  * presentations of Stripables.
51  *
52  */
53 class AxisView : public virtual PBD::ScopedConnectionList, public virtual ARDOUR::SessionHandlePtr, public virtual Selectable
54 {
55   public:
56         virtual std::string name() const = 0;
57         virtual Gdk::Color color() const = 0;
58
59         sigc::signal<void> Hiding;
60
61         virtual boost::shared_ptr<ARDOUR::Stripable> stripable() const = 0;
62         virtual boost::shared_ptr<ARDOUR::AutomationControl> control() const { return boost::shared_ptr<ARDOUR::AutomationControl>(); }
63
64         virtual std::string state_id() const = 0;
65         /* for now, we always return properties in string form.
66          */
67         std::string gui_property (const std::string& property_name) const;
68
69         bool get_gui_property (const std::string& property_name, std::string& value) const;
70
71         template <typename T>
72         bool get_gui_property (const std::string& property_name, T& value) const
73         {
74                 std::string str = gui_property (property_name);
75
76                 if (!str.empty ()) {
77                         return PBD::string_to<T>(str, value);
78                 }
79                 return false;
80         }
81
82         void set_gui_property (const std::string& property_name, const std::string& value);
83
84         void set_gui_property (const std::string& property_name, const char* value) {
85                 set_gui_property (property_name, std::string(value));
86         }
87
88         template <typename T>
89         void set_gui_property (const std::string& property_name, const T& value)
90         {
91                 set_gui_property (property_name, PBD::to_string(value));
92         }
93
94         void cleanup_gui_properties () {
95                 /* remove related property node from the GUI state */
96                 gui_object_state().remove_node (state_id());
97                 property_hashtable.clear ();
98         }
99
100         void set_selected (bool yn);
101
102         virtual bool marked_for_display () const;
103         virtual bool set_marked_for_display (bool);
104
105         static GUIObjectState& gui_object_state();
106         void clear_property_cache() { property_hashtable.clear(); }
107
108         /**
109          * Generate a new random TrackView color, unique from those colors already used.
110          *
111          * @return the unique random color.
112          */
113         static Gdk::Color unique_random_color();
114
115   protected:
116         AxisView ();
117         virtual ~AxisView();
118
119         static std::list<Gdk::Color> used_colors;
120
121         Gtk::Label name_label;
122
123         mutable boost::unordered_map<std::string, std::string> property_hashtable;
124 }; /* class AxisView */
125
126 #endif /* __ardour_gtk_axis_view_h__ */