VKeybd: Pass on primary (Ctrl/Cmd) shortcuts
[ardour.git] / gtk2_ardour / stripable_treemodel.h
1 /*
2  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19 #ifndef __gtk2_ardour_stripable_treemodel_h__
20 #define __gtk2_ardour_stripable_treemodel_h__
21
22 #include <set>
23
24 #include <boost/shared_ptr.hpp>
25 #include <boost/weak_ptr.hpp>
26 #include <stdint.h>
27
28 #include <gtkmm/treemodel.h>
29
30 namespace ARDOUR {
31         class Session;
32         class Stripable;
33 }
34
35 class AxisView;
36 class AxisViewProvider;
37 class StripableSorter;
38
39 class StripableTreeModel : public Gtk::TreeModel, public Glib::Object
40 {
41 protected:
42         StripableTreeModel (AxisViewProvider&);
43         virtual ~StripableTreeModel();
44
45 public:
46         static Glib::RefPtr<StripableTreeModel> create (AxisViewProvider&);
47         void set_session (ARDOUR::Session&);
48
49 protected:
50         Gtk::TreeModelFlags get_flags_vfunc() const;
51         int   get_n_columns_vfunc() const;
52         GType get_column_type_vfunc(int index) const;
53         void  get_value_vfunc(const TreeModel::iterator& iter, int column, Glib::ValueBase& value) const;
54         bool  iter_next_vfunc(const iterator& iter, iterator& iter_next) const;
55         bool  iter_children_vfunc(const iterator& parent, iterator& iter) const;
56         bool  iter_has_child_vfunc(const iterator& iter) const;
57         int   iter_n_children_vfunc(const iterator& iter) const;
58         int   iter_n_root_children_vfunc() const;
59         bool  iter_nth_child_vfunc(const iterator& parent, int n, iterator& iter) const;
60         bool  iter_nth_root_child_vfunc(int n, iterator& iter) const;
61         bool  iter_parent_vfunc(const iterator& child, iterator& iter) const;
62         Path  get_path_vfunc(const iterator& iter) const;
63         bool  get_iter_vfunc(const Path& path, iterator& iter) const;
64         bool  iter_is_valid(const iterator& iter) const;
65
66 public:
67         typedef Gtk::TreeModelColumn<std::string> StringColumn;
68         typedef Gtk::TreeModelColumn<bool>        BoolColumn;
69         typedef Gtk::TreeModelColumn<uint32_t>    UnsignedColumn;
70         typedef Gtk::TreeModelColumn<AxisView*> AVColumn;
71         typedef Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Stripable> > StripableColumn;
72
73         struct Columns : public Gtk::TreeModel::ColumnRecord
74         {
75                 Columns () {
76                         add (text);
77                         add (visible);
78                         add (rec_state);
79                         add (rec_safe);
80                         add (mute_state);
81                         add (solo_state);
82                         add (solo_visible);
83                         add (solo_isolate_state);
84                         add (solo_safe_state);
85                         add (is_track);
86                         add (av);
87                         add (stripable);
88                         add (name_editable);
89                         add (is_input_active);
90                         add (is_midi);
91                         add (active);
92                 }
93
94                 StringColumn text;
95                 BoolColumn visible;
96                 UnsignedColumn rec_state;
97                 UnsignedColumn rec_safe;
98                 UnsignedColumn mute_state;
99                 UnsignedColumn solo_state;
100                 /** true if the solo buttons are visible for this route, otherwise false */
101                 BoolColumn solo_visible;
102                 UnsignedColumn solo_isolate_state;
103                 UnsignedColumn solo_safe_state;
104                 BoolColumn is_track;
105                 AVColumn av;
106                 StripableColumn stripable;
107                 BoolColumn name_editable;
108                 BoolColumn is_input_active;
109                 BoolColumn is_midi;
110                 BoolColumn active;
111         };
112
113         Columns columns;
114
115 private:
116         ARDOUR::Session* _session;
117         AxisViewProvider& axis_view_provider;
118
119         int n_columns;
120
121         void text_value (boost::shared_ptr<ARDOUR::Stripable> stripable, Glib::ValueBase& value) const;
122
123         struct Glue
124         {
125                 Glue (boost::shared_ptr<ARDOUR::Stripable>);
126
127                 boost::weak_ptr<ARDOUR::Stripable> stripable;
128         };
129
130         typedef std::set<Glue*> GlueList;
131         mutable GlueList glue_list;
132         void remember_glue_item (Glue*) const;
133 };
134
135 #endif /* __gtk2_ardour_stripable_treemodel_h__ */