replace ::cast_dynamic() with relevant ActionManager::get_*_action() calls
[ardour.git] / gtk2_ardour / stripable_treemodel.h
1 /* Copyright (C) 2017 Paul Davis
2  *    based on gtkmm example Copyright (C) 2002 gtkmm development team
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 version 2
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */
17
18 #ifndef __gtk2_ardour_stripable_treemodel_h__
19 #define __gtk2_ardour_stripable_treemodel_h__
20
21 #include <set>
22
23 #include <boost/shared_ptr.hpp>
24 #include <boost/weak_ptr.hpp>
25 #include <stdint.h>
26
27 #include <gtkmm/treemodel.h>
28
29 namespace ARDOUR {
30         class Session;
31         class Stripable;
32 }
33
34 class AxisView;
35 class AxisViewProvider;
36 class StripableSorter;
37
38 class StripableTreeModel : public Gtk::TreeModel, public Glib::Object
39 {
40 protected:
41         StripableTreeModel (AxisViewProvider&);
42         virtual ~StripableTreeModel();
43
44 public:
45         static Glib::RefPtr<StripableTreeModel> create (AxisViewProvider&);
46         void set_session (ARDOUR::Session&);
47
48 protected:
49         Gtk::TreeModelFlags get_flags_vfunc() const;
50         int   get_n_columns_vfunc() const;
51         GType get_column_type_vfunc(int index) const;
52         void  get_value_vfunc(const TreeModel::iterator& iter, int column, Glib::ValueBase& value) const;
53         bool  iter_next_vfunc(const iterator& iter, iterator& iter_next) const;
54         bool  iter_children_vfunc(const iterator& parent, iterator& iter) const;
55         bool  iter_has_child_vfunc(const iterator& iter) const;
56         int   iter_n_children_vfunc(const iterator& iter) const;
57         int   iter_n_root_children_vfunc() const;
58         bool  iter_nth_child_vfunc(const iterator& parent, int n, iterator& iter) const;
59         bool  iter_nth_root_child_vfunc(int n, iterator& iter) const;
60         bool  iter_parent_vfunc(const iterator& child, iterator& iter) const;
61         Path  get_path_vfunc(const iterator& iter) const;
62         bool  get_iter_vfunc(const Path& path, iterator& iter) const;
63         bool  iter_is_valid(const iterator& iter) const;
64
65 public:
66         typedef Gtk::TreeModelColumn<std::string> StringColumn;
67         typedef Gtk::TreeModelColumn<bool>        BoolColumn;
68         typedef Gtk::TreeModelColumn<uint32_t>    UnsignedColumn;
69         typedef Gtk::TreeModelColumn<AxisView*> AVColumn;
70         typedef Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Stripable> > StripableColumn;
71
72         struct Columns : public Gtk::TreeModel::ColumnRecord
73         {
74                 Columns () {
75                         add (text);
76                         add (visible);
77                         add (rec_state);
78                         add (rec_safe);
79                         add (mute_state);
80                         add (solo_state);
81                         add (solo_visible);
82                         add (solo_isolate_state);
83                         add (solo_safe_state);
84                         add (is_track);
85                         add (av);
86                         add (stripable);
87                         add (name_editable);
88                         add (is_input_active);
89                         add (is_midi);
90                         add (active);
91                 }
92
93                 StringColumn text;
94                 BoolColumn visible;
95                 UnsignedColumn rec_state;
96                 UnsignedColumn rec_safe;
97                 UnsignedColumn mute_state;
98                 UnsignedColumn solo_state;
99                 /** true if the solo buttons are visible for this route, otherwise false */
100                 BoolColumn solo_visible;
101                 UnsignedColumn solo_isolate_state;
102                 UnsignedColumn solo_safe_state;
103                 BoolColumn is_track;
104                 AVColumn av;
105                 StripableColumn stripable;
106                 BoolColumn name_editable;
107                 BoolColumn is_input_active;
108                 BoolColumn is_midi;
109                 BoolColumn active;
110         };
111
112         Columns columns;
113
114 private:
115         ARDOUR::Session* _session;
116         AxisViewProvider& axis_view_provider;
117
118         int n_columns;
119
120         void text_value (boost::shared_ptr<ARDOUR::Stripable> stripable, Glib::ValueBase& value) const;
121
122         struct Glue
123         {
124                 Glue (boost::shared_ptr<ARDOUR::Stripable>);
125
126                 boost::weak_ptr<ARDOUR::Stripable> stripable;
127         };
128
129         typedef std::set<Glue*> GlueList;
130         mutable GlueList glue_list;
131         void remember_glue_item (Glue*) const;
132 };
133
134 #endif /* __gtk2_ardour_stripable_treemodel_h__ */