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 () {
44 void set_selected (RegionSelection &);
45 void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
47 boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
48 boost::shared_ptr<ARDOUR::Region> get_single_selection ();
52 void suspend_redisplay () {
56 void resume_redisplay () {
57 _no_redisplay = false;
61 void block_change_connection (bool b) {
62 _change_connection.block (b);
65 void unselect_all () {
66 _display.get_selection()->unselect_all ();
69 void remove_unused_regions ();
71 XMLNode& get_state () const;
72 void set_state (const XMLNode &);
76 struct Columns : public Gtk::TreeModel::ColumnRecord {
96 Gtk::TreeModelColumn<std::string> name;
97 Gtk::TreeModelColumn<std::string> take_id;
98 Gtk::TreeModelColumn<samplepos_t> position;
99 Gtk::TreeModelColumn<std::string> start;
100 Gtk::TreeModelColumn<std::string> end;
101 Gtk::TreeModelColumn<std::string> length;
102 Gtk::TreeModelColumn<std::string> sync;
103 Gtk::TreeModelColumn<std::string> fadein;
104 Gtk::TreeModelColumn<std::string> fadeout;
105 Gtk::TreeModelColumn<bool> locked;
106 Gtk::TreeModelColumn<bool> glued;
107 Gtk::TreeModelColumn<bool> muted;
108 Gtk::TreeModelColumn<bool> opaque;
109 Gtk::TreeModelColumn<std::string> path;
110 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
111 Gtk::TreeModelColumn<Gdk::Color> color_;
116 Gtk::TreeModel::RowReference last_row;
118 void freeze_tree_model ();
119 void thaw_tree_model ();
120 void region_changed (boost::shared_ptr<ARDOUR::Region>, PBD::PropertyChange const &);
121 void selection_changed ();
123 sigc::connection _change_connection;
125 bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
127 Gtk::Widget* old_focus;
128 Gtk::CellEditable* name_editable;
129 void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
131 void name_edit (const std::string&, const std::string&);
132 void locked_changed (std::string const &);
133 void glued_changed (std::string const &);
134 void muted_changed (std::string const &);
135 void opaque_changed (std::string const &);
137 bool key_press (GdkEventKey *);
138 bool button_press (GdkEventButton *);
140 bool focus_in (GdkEventFocus*);
141 bool focus_out (GdkEventFocus*);
142 bool enter_notify (GdkEventCrossing*);
143 bool leave_notify (GdkEventCrossing*);
145 void show_context_menu (int button, int time);
147 void format_position (ARDOUR::samplepos_t pos, char* buf, size_t bufsize, bool onoff = true);
149 void add_region (boost::shared_ptr<ARDOUR::Region>);
150 void destroy_region (boost::shared_ptr<ARDOUR::Region>);
152 void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, PBD::PropertyChange const &);
153 void populate_row_used (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
154 void populate_row_position (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
155 void populate_row_end (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
156 void populate_row_sync (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
157 void populate_row_fade_in (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
158 void populate_row_fade_out (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
159 void populate_row_locked (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
160 void populate_row_muted (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
161 void populate_row_glued (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
162 void populate_row_opaque (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
163 void populate_row_length (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
164 void populate_row_name (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
165 void populate_row_source (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
167 void update_row (boost::shared_ptr<ARDOUR::Region>);
169 void clock_format_changed ();
171 void drag_data_received (
172 Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
175 Glib::RefPtr<Gtk::Action> remove_unused_regions_action () const;
178 Gtk::ScrolledWindow _scroller;
181 Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > _display;
183 Glib::RefPtr<Gtk::TreeStore> _model;
187 typedef boost::unordered_map<boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::iterator> RegionRowMap;
189 RegionRowMap region_row_map;
191 PBD::ScopedConnection region_property_connection;
192 PBD::ScopedConnection check_new_region_connection;
194 PBD::ScopedConnection editor_freeze_connection;
195 PBD::ScopedConnection editor_thaw_connection;
198 #endif /* __gtk_ardour_editor_regions_h__ */