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