Strip trailing whitespace and fix other whitespace errors (e.g. space/tab mixing...
[ardour.git] / gtk2_ardour / editor_regions.h
1 /*
2     Copyright (C) 2000-2009 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 #include "editor_component.h"
21
22 class EditorRegions : public EditorComponent
23 {
24 public:
25         EditorRegions (Editor *);
26
27         void connect_to_session (ARDOUR::Session *);
28
29         Gtk::Widget& widget () {
30                 return _scroller;
31         }
32
33         void clear ();
34
35         void toggle_full ();
36         void toggle_show_auto_regions ();
37         void reset_sort_direction (bool);
38         void reset_sort_type (Editing::RegionListSortType, bool);
39         void set_selected (RegionSelection &);
40         void remove_region ();
41         void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
42         boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
43         boost::shared_ptr<ARDOUR::Region> get_single_selection ();
44         Editing::RegionListSortType sort_type () const {
45                 return _sort_type;
46         }
47         void redisplay ();
48
49         void suspend_redisplay () {
50                 _no_redisplay = true;
51         }
52         void resume_redisplay () {
53                 _no_redisplay = false;
54                 redisplay ();
55         }
56
57         void block_change_connection (bool b) {
58                 _change_connection.block (b);
59         }
60
61         void unselect_all () {
62                 _display.get_selection()->unselect_all ();
63         }
64
65 private:
66
67         struct Columns : public Gtk::TreeModel::ColumnRecord {
68                 Columns () {
69                         add (name);
70                         add (region);
71                         add (color_);
72                         add (start);
73                         add (end);
74                         add (length);
75                         add (sync);
76                         add (fadein);
77                         add (fadeout);
78                         add (locked);
79                         add (glued);
80                         add (muted);
81                         add (opaque);
82                         add (used);
83                         add (path);
84                 }
85
86                 Gtk::TreeModelColumn<Glib::ustring> name;
87                 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
88                 Gtk::TreeModelColumn<Gdk::Color> color_;
89                 Gtk::TreeModelColumn<Glib::ustring> start;
90                 Gtk::TreeModelColumn<Glib::ustring> end;
91                 Gtk::TreeModelColumn<Glib::ustring> length;
92                 Gtk::TreeModelColumn<Glib::ustring> sync;
93                 Gtk::TreeModelColumn<Glib::ustring> fadein;
94                 Gtk::TreeModelColumn<Glib::ustring> fadeout;
95                 Gtk::TreeModelColumn<bool> locked;
96                 Gtk::TreeModelColumn<bool> glued;
97                 Gtk::TreeModelColumn<bool> muted;
98                 Gtk::TreeModelColumn<bool> opaque;
99                 Gtk::TreeModelColumn<Glib::ustring> used;
100                 Gtk::TreeModelColumn<Glib::ustring> path;
101         };
102
103         Columns _columns;
104
105         void region_changed (ARDOUR::Change, boost::weak_ptr<ARDOUR::Region>);
106         void selection_changed ();
107         sigc::connection _change_connection;
108         bool set_selected_in_subrow (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
109         bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
110         void name_edit (const Glib::ustring&, const Glib::ustring&);
111
112         bool key_press (GdkEventKey *);
113         bool key_release (GdkEventKey *);
114         bool button_press (GdkEventButton *);
115         bool button_release (GdkEventButton *);
116         void build_menu ();
117         void show_context_menu (int button, int time);
118
119         int sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
120
121         void handle_new_region (boost::weak_ptr<ARDOUR::Region>);
122         void handle_new_regions (std::vector<boost::weak_ptr<ARDOUR::Region> >& );
123         void handle_region_removed (boost::weak_ptr<ARDOUR::Region>);
124         void add_region (boost::shared_ptr<ARDOUR::Region>);
125         void add_regions (std::vector<boost::weak_ptr<ARDOUR::Region> > & );
126         void region_hidden (boost::shared_ptr<ARDOUR::Region>);
127         void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &);
128         void update_row (boost::shared_ptr<ARDOUR::Region>);
129         bool update_subrows (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
130         void update_all_rows ();
131         void update_all_subrows (Gtk::TreeModel::Row const &, int);
132         void insert_into_tmp_regionlist (boost::shared_ptr<ARDOUR::Region>);
133
134         void drag_data_received (
135                 Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
136                 );
137
138         Gtk::Menu* _menu;
139         Gtk::ScrolledWindow _scroller;
140         Gtk::Frame _frame;
141         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > _display;
142         Glib::RefPtr<Gtk::TreeStore> _model;
143         Glib::RefPtr<Gtk::ToggleAction> _toggle_full_action;
144         Glib::RefPtr<Gtk::ToggleAction> _toggle_show_auto_regions_action;
145         bool _show_automatic_regions;
146         Editing::RegionListSortType _sort_type;
147         bool _no_redisplay;
148         std::list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
149 };
150
151