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