2 Copyright (C) 2000-2009 Paul Davis
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.
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.
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.
19 #ifndef __gtk_ardour_editor_regions_h__
20 #define __gtk_ardour_editor_regions_h__
22 #include <boost/unordered_map.hpp>
24 #include <gtkmm/scrolledwindow.h>
25 #include <gtkmm/treemodel.h>
26 #include <gtkmm/treerowreference.h>
27 #include <gtkmm/treestore.h>
29 #include "editor_component.h"
31 class EditorRegions : public EditorComponent, public ARDOUR::SessionHandlePtr
34 EditorRegions (Editor *);
36 void set_session (ARDOUR::Session *);
38 Gtk::Widget& widget () {
45 void toggle_show_auto_regions ();
46 void reset_sort_direction (bool);
47 void reset_sort_type (Editing::RegionListSortType, bool);
48 void set_selected (RegionSelection &);
49 void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
51 boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
52 boost::shared_ptr<ARDOUR::Region> get_single_selection ();
54 Editing::RegionListSortType sort_type () const {
60 void suspend_redisplay () {
64 void resume_redisplay () {
65 _no_redisplay = false;
69 void block_change_connection (bool b) {
70 _change_connection.block (b);
73 void unselect_all () {
74 _display.get_selection()->unselect_all ();
77 void remove_unused_regions ();
79 XMLNode& get_state () const;
80 void set_state (const XMLNode &);
84 struct Columns : public Gtk::TreeModel::ColumnRecord {
101 add (property_toggles_visible);
104 Gtk::TreeModelColumn<std::string> name;
105 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
106 Gtk::TreeModelColumn<Gdk::Color> color_;
107 Gtk::TreeModelColumn<std::string> position;
108 Gtk::TreeModelColumn<std::string> end;
109 Gtk::TreeModelColumn<std::string> length;
110 Gtk::TreeModelColumn<std::string> sync;
111 Gtk::TreeModelColumn<std::string> fadein;
112 Gtk::TreeModelColumn<std::string> fadeout;
113 Gtk::TreeModelColumn<bool> locked;
114 Gtk::TreeModelColumn<bool> glued;
115 Gtk::TreeModelColumn<bool> muted;
116 Gtk::TreeModelColumn<bool> opaque;
117 Gtk::TreeModelColumn<std::string> used;
118 Gtk::TreeModelColumn<std::string> path;
119 /** used to indicate whether the locked/glued/muted/opaque should be visible or not */
120 Gtk::TreeModelColumn<bool> property_toggles_visible;
125 Gtk::TreeModel::RowReference last_row;
127 void freeze_tree_model ();
128 void thaw_tree_model ();
129 void region_changed (boost::shared_ptr<ARDOUR::Region>, PBD::PropertyChange const &);
130 void selection_changed ();
132 sigc::connection _change_connection;
134 bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
136 Gtk::Widget* old_focus;
137 Gtk::CellEditable* name_editable;
138 void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
140 void name_edit (const std::string&, const std::string&);
141 void locked_changed (std::string const &);
142 void glued_changed (std::string const &);
143 void muted_changed (std::string const &);
144 void opaque_changed (std::string const &);
146 bool key_press (GdkEventKey *);
147 bool button_press (GdkEventButton *);
149 bool focus_in (GdkEventFocus*);
150 bool focus_out (GdkEventFocus*);
151 bool enter_notify (GdkEventCrossing*);
152 bool leave_notify (GdkEventCrossing*);
154 void show_context_menu (int button, int time);
156 int sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
158 void format_position (ARDOUR::samplepos_t pos, char* buf, size_t bufsize, bool onoff = true);
160 void add_region (boost::shared_ptr<ARDOUR::Region>);
162 void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, PBD::PropertyChange const &);
163 void populate_row_used (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
164 void populate_row_position (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
165 void populate_row_end (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
166 void populate_row_sync (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
167 void populate_row_fade_in (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used, boost::shared_ptr<ARDOUR::AudioRegion>);
168 void populate_row_fade_out (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used, boost::shared_ptr<ARDOUR::AudioRegion>);
169 void populate_row_locked (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
170 void populate_row_muted (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
171 void populate_row_glued (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
172 void populate_row_opaque (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
173 void populate_row_length (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
174 void populate_row_name (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
175 void populate_row_source (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
177 void update_row (boost::shared_ptr<ARDOUR::Region>);
178 void update_all_rows ();
180 void insert_into_tmp_regionlist (boost::shared_ptr<ARDOUR::Region>);
182 void drag_data_received (
183 Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
186 Glib::RefPtr<Gtk::RadioAction> sort_type_action (Editing::RegionListSortType) const;
187 void set_full (bool);
189 Glib::RefPtr<Gtk::Action> hide_action () const;
190 Glib::RefPtr<Gtk::Action> show_action () const;
191 Glib::RefPtr<Gtk::Action> remove_unused_regions_action () const;
192 Glib::RefPtr<Gtk::ToggleAction> toggle_full_action () const;
193 Glib::RefPtr<Gtk::ToggleAction> toggle_show_auto_regions_action () const;
196 Gtk::ScrolledWindow _scroller;
199 Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > _display;
201 Glib::RefPtr<Gtk::TreeStore> _model;
203 bool _show_automatic_regions;
204 bool ignore_region_list_selection_change;
205 bool ignore_selected_region_change;
208 Editing::RegionListSortType _sort_type;
210 std::list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
212 typedef boost::unordered_map<boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::iterator> RegionRowMap;
213 typedef boost::unordered_map<std::string, Gtk::TreeModel::RowReference > RegionSourceMap;
215 RegionRowMap region_row_map;
216 RegionSourceMap parent_regions_sources_map;
218 PBD::ScopedConnection region_property_connection;
219 PBD::ScopedConnection check_new_region_connection;
221 PBD::ScopedConnection editor_freeze_connection;
222 PBD::ScopedConnection editor_thaw_connection;
227 #endif /* __gtk_ardour_editor_regions_h__ */