do not set LV2_PATH for a bundled build
[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         
44         boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
45         boost::shared_ptr<ARDOUR::Region> get_single_selection ();
46         
47         Editing::RegionListSortType sort_type () const {
48                 return _sort_type;
49         }
50         
51         void redisplay ();
52
53         void suspend_redisplay () {
54                 _no_redisplay = true;
55         }
56         
57         void resume_redisplay () {
58                 _no_redisplay = false;
59                 redisplay ();
60         }
61
62         void block_change_connection (bool b) {
63                 _change_connection.block (b);
64         }
65
66         void unselect_all () {
67                 _display.get_selection()->unselect_all ();
68         }
69
70         XMLNode& get_state () const;
71         void set_state (const XMLNode &);
72
73 private:
74
75         struct Columns : public Gtk::TreeModel::ColumnRecord {
76                 Columns () {
77                         add (name);
78                         add (region);
79                         add (color_);
80                         add (position);
81                         add (end);
82                         add (length);
83                         add (sync);
84                         add (fadein);
85                         add (fadeout);
86                         add (locked);
87                         add (glued);
88                         add (muted);
89                         add (opaque);
90                         add (used);
91                         add (path);
92                         add (property_toggles_visible);
93                 }
94
95                 Gtk::TreeModelColumn<std::string> name;
96                 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
97                 Gtk::TreeModelColumn<Gdk::Color> color_;
98                 Gtk::TreeModelColumn<std::string> position;
99                 Gtk::TreeModelColumn<std::string> end;
100                 Gtk::TreeModelColumn<std::string> length;
101                 Gtk::TreeModelColumn<std::string> sync;
102                 Gtk::TreeModelColumn<std::string> fadein;
103                 Gtk::TreeModelColumn<std::string> fadeout;
104                 Gtk::TreeModelColumn<bool> locked;
105                 Gtk::TreeModelColumn<bool> glued;
106                 Gtk::TreeModelColumn<bool> muted;
107                 Gtk::TreeModelColumn<bool> opaque;
108                 Gtk::TreeModelColumn<std::string> used;
109                 Gtk::TreeModelColumn<std::string> path;
110                 /** used to indicate whether the locked/glued/muted/opaque should be visible or not */
111                 Gtk::TreeModelColumn<bool> property_toggles_visible;
112         };
113
114         Columns _columns;
115         
116         Gtk::TreeModel::RowReference last_row;
117
118         void region_changed (boost::shared_ptr<ARDOUR::Region>, PBD::PropertyChange const &);
119         void selection_changed ();
120         
121         sigc::connection _change_connection;
122         
123         bool set_selected_in_subrow (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
124         bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
125
126         Gtk::Widget* old_focus;
127         Gtk::CellEditable* name_editable;
128         void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
129         
130         void name_edit (const std::string&, const std::string&);
131         void locked_changed (std::string const &);
132         void glued_changed (std::string const &);
133         void muted_changed (std::string const &);
134         void opaque_changed (std::string const &);
135
136         bool key_press (GdkEventKey *);
137         bool button_press (GdkEventButton *);
138         bool focus_in (GdkEventFocus*);
139         bool focus_out (GdkEventFocus*);
140         bool enter_notify (GdkEventCrossing*);
141         bool leave_notify (GdkEventCrossing*);
142         void show_context_menu (int button, int time);
143
144         int sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
145
146         void format_position (ARDOUR::framepos_t pos, char* buf, size_t bufsize);
147
148         void add_region (boost::shared_ptr<ARDOUR::Region>);
149         void add_regions (std::vector<boost::shared_ptr<ARDOUR::Region> > & );
150         void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &);
151         void populate_row_used (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
152         void populate_row_position (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
153         void populate_row_end (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
154         void populate_row_sync (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
155         void populate_row_fade_in (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used, boost::shared_ptr<ARDOUR::AudioRegion>);
156         void populate_row_fade_out (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used, boost::shared_ptr<ARDOUR::AudioRegion>);
157         void populate_row_locked (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
158         void populate_row_muted (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
159         void populate_row_glued (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
160         void populate_row_opaque (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
161         void populate_row_length (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
162         void populate_row_name (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
163         void populate_row_source (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
164
165         void update_row (boost::shared_ptr<ARDOUR::Region>);
166         bool update_subrows (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
167         void update_all_rows ();
168         void update_all_subrows (Gtk::TreeModel::Row const &, int);
169         void insert_into_tmp_regionlist (boost::shared_ptr<ARDOUR::Region>);
170
171         void drag_data_received (
172                 Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
173                 );
174
175         Glib::RefPtr<Gtk::RadioAction> sort_type_action (Editing::RegionListSortType) const;
176         void set_full (bool);
177
178         Glib::RefPtr<Gtk::Action> hide_action () const;
179         Glib::RefPtr<Gtk::Action> show_action () const;
180         Glib::RefPtr<Gtk::ToggleAction> toggle_full_action () const;
181         Glib::RefPtr<Gtk::ToggleAction> toggle_show_auto_regions_action () const;
182         
183         Gtk::Menu* _menu;
184         Gtk::ScrolledWindow _scroller;
185         Gtk::Frame _frame;
186         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > _display;
187         Glib::RefPtr<Gtk::TreeStore> _model;
188         bool _show_automatic_regions;
189         Editing::RegionListSortType _sort_type;
190         bool _no_redisplay;
191         std::list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
192         PBD::ScopedConnection region_property_connection;
193         PBD::ScopedConnection check_new_region_connection;
194         bool ignore_region_list_selection_change;
195         bool ignore_selected_region_change;
196         bool expanded;
197 };
198
199 #endif /* __gtk_ardour_editor_regions_h__ */