2 * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
4 * Copyright (C) 2009-2018 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2018 Ben Loftis <ben@harrisonconsoles.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef __gtk_ardour_editor_regions_h__
22 #define __gtk_ardour_editor_regions_h__
24 #include <boost/unordered_map.hpp>
26 #include <gtkmm/scrolledwindow.h>
27 #include <gtkmm/treemodel.h>
28 #include <gtkmm/treerowreference.h>
29 #include <gtkmm/treestore.h>
31 #include "editor_component.h"
33 class EditorRegions : public EditorComponent, public ARDOUR::SessionHandlePtr
36 EditorRegions (Editor *);
38 void set_session (ARDOUR::Session *);
40 Gtk::Widget& widget () {
46 void set_selected (RegionSelection &);
47 void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
49 boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
50 boost::shared_ptr<ARDOUR::Region> get_single_selection ();
54 void suspend_redisplay () {
58 void resume_redisplay () {
59 _no_redisplay = false;
63 void block_change_connection (bool b) {
64 _change_connection.block (b);
67 void unselect_all () {
68 _display.get_selection()->unselect_all ();
71 void remove_unused_regions ();
73 XMLNode& get_state () const;
74 void set_state (const XMLNode &);
78 struct Columns : public Gtk::TreeModel::ColumnRecord {
98 Gtk::TreeModelColumn<std::string> name;
99 Gtk::TreeModelColumn<std::string> tags;
100 Gtk::TreeModelColumn<samplepos_t> position;
101 Gtk::TreeModelColumn<std::string> start;
102 Gtk::TreeModelColumn<std::string> end;
103 Gtk::TreeModelColumn<std::string> length;
104 Gtk::TreeModelColumn<std::string> sync;
105 Gtk::TreeModelColumn<std::string> fadein;
106 Gtk::TreeModelColumn<std::string> fadeout;
107 Gtk::TreeModelColumn<bool> locked;
108 Gtk::TreeModelColumn<bool> glued;
109 Gtk::TreeModelColumn<bool> muted;
110 Gtk::TreeModelColumn<bool> opaque;
111 Gtk::TreeModelColumn<std::string> path;
112 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
113 Gtk::TreeModelColumn<Gdk::Color> color_;
118 Gtk::TreeModel::RowReference last_row;
120 void freeze_tree_model ();
121 void thaw_tree_model ();
122 void region_changed (boost::shared_ptr<ARDOUR::Region>, PBD::PropertyChange const &);
123 void selection_changed ();
125 sigc::connection _change_connection;
127 bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
129 Gtk::Widget* old_focus;
131 Gtk::CellEditable* name_editable;
132 void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
133 void name_edit (const std::string&, const std::string&);
136 Gtk::CellEditable* tags_editable;
137 void tag_editing_started (Gtk::CellEditable*, const Glib::ustring&);
138 void tag_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 void format_position (ARDOUR::samplepos_t pos, char* buf, size_t bufsize, bool onoff = true);
158 void add_region (boost::shared_ptr<ARDOUR::Region>);
159 void destroy_region (boost::shared_ptr<ARDOUR::Region>);
161 void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, PBD::PropertyChange const &);
162 void populate_row_used (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
163 void populate_row_position (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
164 void populate_row_end (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
165 void populate_row_sync (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
166 void populate_row_fade_in (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
167 void populate_row_fade_out (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
168 void populate_row_locked (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
169 void populate_row_muted (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
170 void populate_row_glued (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
171 void populate_row_opaque (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
172 void populate_row_length (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
173 void populate_row_name (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
174 void populate_row_source (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
176 void update_row (boost::shared_ptr<ARDOUR::Region>);
178 void clock_format_changed ();
180 void drag_data_received (
181 Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
184 Glib::RefPtr<Gtk::Action> remove_unused_regions_action () const;
187 Gtk::ScrolledWindow _scroller;
190 Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > _display;
192 Glib::RefPtr<Gtk::TreeStore> _model;
196 typedef boost::unordered_map<boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::iterator> RegionRowMap;
198 RegionRowMap region_row_map;
200 PBD::ScopedConnection region_property_connection;
201 PBD::ScopedConnection check_new_region_connection;
203 PBD::ScopedConnection editor_freeze_connection;
204 PBD::ScopedConnection editor_thaw_connection;
207 #endif /* __gtk_ardour_editor_regions_h__ */