remove Glib::ustring from gtk2_ardour
[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, public ARDOUR::SessionHandlePtr
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 selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
43         boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
44         boost::shared_ptr<ARDOUR::Region> get_single_selection ();
45         Editing::RegionListSortType sort_type () const {
46                 return _sort_type;
47         }
48         void redisplay ();
49
50         void suspend_redisplay () {
51                 _no_redisplay = true;
52         }
53         void resume_redisplay () {
54                 _no_redisplay = false;
55                 redisplay ();
56         }
57
58         void block_change_connection (bool b) {
59                 _change_connection.block (b);
60         }
61
62         void unselect_all () {
63                 _display.get_selection()->unselect_all ();
64         }
65
66 private:
67
68         struct Columns : public Gtk::TreeModel::ColumnRecord {
69                 Columns () {
70                         add (name);
71                         add (region);
72                         add (color_);
73                         add (start);
74                         add (end);
75                         add (length);
76                         add (sync);
77                         add (fadein);
78                         add (fadeout);
79                         add (locked);
80                         add (glued);
81                         add (muted);
82                         add (opaque);
83                         add (used);
84                         add (path);
85                         add (property_toggles_visible);
86                 }
87
88                 Gtk::TreeModelColumn<std::string> name;
89                 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
90                 Gtk::TreeModelColumn<Gdk::Color> color_;
91                 Gtk::TreeModelColumn<std::string> start;
92                 Gtk::TreeModelColumn<std::string> end;
93                 Gtk::TreeModelColumn<std::string> length;
94                 Gtk::TreeModelColumn<std::string> sync;
95                 Gtk::TreeModelColumn<std::string> fadein;
96                 Gtk::TreeModelColumn<std::string> fadeout;
97                 Gtk::TreeModelColumn<bool> locked;
98                 Gtk::TreeModelColumn<bool> glued;
99                 Gtk::TreeModelColumn<bool> muted;
100                 Gtk::TreeModelColumn<bool> opaque;
101                 Gtk::TreeModelColumn<std::string> used;
102                 Gtk::TreeModelColumn<std::string> path;
103                 /** used to indicate whether the locked/glued/muted/opaque should be visible or not */
104                 Gtk::TreeModelColumn<bool> property_toggles_visible;
105         };
106
107         Columns _columns;
108
109         void region_changed (boost::shared_ptr<ARDOUR::Region>, PBD::PropertyChange const &);
110         void selection_changed ();
111         sigc::connection _change_connection;
112         bool set_selected_in_subrow (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
113         bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
114         void name_edit (const std::string&, const std::string&);
115         void locked_changed (std::string const &);
116         void glued_changed (std::string const &);
117         void muted_changed (std::string const &);
118         void opaque_changed (std::string const &);
119
120         bool key_press (GdkEventKey *);
121         bool button_press (GdkEventButton *);
122         void build_menu ();
123         void show_context_menu (int button, int time);
124
125         int sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
126
127         void add_region (boost::shared_ptr<ARDOUR::Region>);
128         void add_regions (std::vector<boost::shared_ptr<ARDOUR::Region> > & );
129         void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &);
130         void update_row (boost::shared_ptr<ARDOUR::Region>);
131         bool update_subrows (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
132         void update_all_rows ();
133         void update_all_subrows (Gtk::TreeModel::Row const &, int);
134         void insert_into_tmp_regionlist (boost::shared_ptr<ARDOUR::Region>);
135
136         void drag_data_received (
137                 Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
138                 );
139
140         Gtk::Menu* _menu;
141         Gtk::ScrolledWindow _scroller;
142         Gtk::Frame _frame;
143         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > _display;
144         Glib::RefPtr<Gtk::TreeStore> _model;
145         Glib::RefPtr<Gtk::Action> _hide_action; ///< the action for our Hide menu option
146         Glib::RefPtr<Gtk::Action> _show_action; ///< the action for our Show menu option
147         Glib::RefPtr<Gtk::ToggleAction> _toggle_full_action;
148         Glib::RefPtr<Gtk::ToggleAction> _toggle_show_auto_regions_action;
149         bool _show_automatic_regions;
150         Editing::RegionListSortType _sort_type;
151         bool _no_redisplay;
152         std::list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
153         PBD::ScopedConnection region_property_connection;
154         PBD::ScopedConnection check_new_region_connection;
155         bool ignore_region_list_selection_change;
156         bool ignore_selected_region_change;
157 };
158
159 #endif /* __gtk_ardour_editor_regions_h__ */