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> tags;
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;
129 Gtk::CellEditable* name_editable;
130 void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
131 void name_edit (const std::string&, const std::string&);
134 Gtk::CellEditable* tags_editable;
135 void tag_editing_started (Gtk::CellEditable*, const Glib::ustring&);
136 void tag_edit (const std::string&, const std::string&);
139 void locked_changed (std::string const &);
140 void glued_changed (std::string const &);
141 void muted_changed (std::string const &);
142 void opaque_changed (std::string const &);
144 bool key_press (GdkEventKey *);
145 bool button_press (GdkEventButton *);
147 bool focus_in (GdkEventFocus*);
148 bool focus_out (GdkEventFocus*);
149 bool enter_notify (GdkEventCrossing*);
150 bool leave_notify (GdkEventCrossing*);
152 void show_context_menu (int button, int time);
154 void format_position (ARDOUR::samplepos_t pos, char* buf, size_t bufsize, bool onoff = true);
156 void add_region (boost::shared_ptr<ARDOUR::Region>);
157 void destroy_region (boost::shared_ptr<ARDOUR::Region>);
159 void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, PBD::PropertyChange const &);
160 void populate_row_used (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
161 void populate_row_position (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
162 void populate_row_end (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
163 void populate_row_sync (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
164 void populate_row_fade_in (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
165 void populate_row_fade_out (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
166 void populate_row_locked (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
167 void populate_row_muted (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
168 void populate_row_glued (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
169 void populate_row_opaque (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
170 void populate_row_length (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
171 void populate_row_name (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
172 void populate_row_source (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
174 void update_row (boost::shared_ptr<ARDOUR::Region>);
176 void clock_format_changed ();
178 void drag_data_received (
179 Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
182 Glib::RefPtr<Gtk::Action> remove_unused_regions_action () const;
185 Gtk::ScrolledWindow _scroller;
188 Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > _display;
190 Glib::RefPtr<Gtk::TreeStore> _model;
194 typedef boost::unordered_map<boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::iterator> RegionRowMap;
196 RegionRowMap region_row_map;
198 PBD::ScopedConnection region_property_connection;
199 PBD::ScopedConnection check_new_region_connection;
201 PBD::ScopedConnection editor_freeze_connection;
202 PBD::ScopedConnection editor_thaw_connection;
205 #endif /* __gtk_ardour_editor_regions_h__ */