Ardour  9.0-pre0-582-g084a23a80d
region_list_base.h
Go to the documentation of this file.
1 /*
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>
6  * Copyright (C) 2021 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 #ifndef _gtk_ardour_region_list_base_h_
23 #define _gtk_ardour_region_list_base_h_
24 
25 #include <unordered_map>
26 
27 #include <gtkmm/celleditable.h>
28 #include <gtkmm/frame.h>
29 #include <gtkmm/scrolledwindow.h>
30 #include <gtkmm/treemodel.h>
31 #include <gtkmm/treerowreference.h>
32 #include <gtkmm/treestore.h>
33 
34 #include "gtkmm2ext/utils.h"
35 
36 #include "pbd/properties.h"
37 #include "pbd/signals.h"
38 
39 #include "ardour/session_handle.h"
40 #include "ardour/types.h"
41 
42 #include "gtkmm2ext/dndtreeview.h"
43 
44 //#define SHOW_REGION_EXTRAS
45 
46 namespace ARDOUR
47 {
48  class Region;
49  class AudioRegion;
50 }
51 
53 {
54 public:
56 
58 
60  {
61  return _scroller;
62  }
63 
64  void clear ();
65 
66  void redisplay ();
67 
69  {
70  _no_redisplay = true;
71  }
72 
74  {
75  _no_redisplay = false;
76  redisplay ();
77  }
78 
80  {
81  _change_connection.block (b);
82  }
83 
84  void unselect_all ()
85  {
86  _display.get_selection ()->unselect_all ();
87  }
88 
89 protected:
92  {
93  add (name); // 0
94  add (channels); // 1
95  add (tags); // 2
96  add (start); // 3
97  add (length); // 3
98  add (end); // 5
99  add (sync); // 6
100  add (fadein); // 7
101  add (fadeout); // 8
102  add (locked); // 9
103  add (muted); // 11
104  add (opaque); // 12
105  add (path); // 13
106  add (region); // 14
107  add (color_); // 15
108  add (position); // 16
109  /* src-list */
110  add (captd_for); // 17
111  add (take_id); // 18
112  add (natural_pos); // 19
113  add (natural_s); // 20
114  add (captd_xruns);
115  }
116 
138  };
139 
141  void add_tag_column ();
142 
143  template <class T>
145  {
146  Gtk::TreeViewColumn* c = manage (new Gtk::TreeViewColumn ("", col));
147  c->set_fixed_width (width);
149  _display.append_column (*c);
150  return c;
151  }
152 
153  template <class T>
154  Gtk::TreeViewColumn* append_col (Gtk::TreeModelColumn<T> const& col, std::string const& sizing_text)
155  {
156  int w, h;
157  Glib::RefPtr<Pango::Layout> layout = _display.create_pango_layout (sizing_text);
158  layout->get_pixel_size (w, h);
159  return append_col (col, w);
160  }
161 
162  void setup_col (Gtk::TreeViewColumn*, int, Gtk::AlignmentEnum, const char*, const char*, bool require_mod_to_edit = false);
163  void setup_toggle (Gtk::TreeViewColumn*, sigc::slot<void, std::string>);
164 
167  void remove_weak_region (std::weak_ptr<ARDOUR::Region>);
168 
169  virtual void regions_changed (std::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const&);
170 
171  void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
173  void tag_editing_started (Gtk::CellEditable*, const Glib::ustring&);
175 
176  virtual void name_edit (const std::string&, const std::string&);
177  virtual void tag_edit (const std::string&, const std::string&);
178 
179  void locked_changed (std::string const&);
180  void muted_changed (std::string const&);
181  void opaque_changed (std::string const&);
182 
183  virtual bool key_press (GdkEventKey*);
184  virtual bool button_press (GdkEventButton*)
185  {
186  return false;
187  }
188 
191 
194 
195  void format_position (Temporal::timepos_t const& pos, char* buf, size_t bufsize, bool onoff = true) const;
196 
197  void add_region (std::shared_ptr<ARDOUR::Region>);
198 
199  void populate_row (std::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const&, PBD::PropertyChange const&);
200  void populate_row_used (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
201  void populate_row_position (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
202  void populate_row_end (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
203  void populate_row_sync (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
204  void populate_row_fade_in (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, std::shared_ptr<ARDOUR::AudioRegion>);
205  void populate_row_fade_out (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, std::shared_ptr<ARDOUR::AudioRegion>);
206  void populate_row_locked (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
207  void populate_row_muted (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
208  void populate_row_opaque (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
209  void populate_row_length (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
210  void populate_row_name (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
211  void populate_row_source (std::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
212 
214 
215  void drag_begin (Glib::RefPtr<Gdk::DragContext> const&);
216  void drag_end (Glib::RefPtr<Gdk::DragContext> const&);
217  void drag_data_get (Glib::RefPtr<Gdk::DragContext> const&, Gtk::SelectionData&, guint, guint);
218 
219  virtual bool list_region (std::shared_ptr<ARDOUR::Region>) const;
220 
222 
225 
229 
232 
234 
235  Glib::RefPtr<Gtk::TreeStore> _model;
236 
238 
239  typedef std::unordered_map<std::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::iterator> RegionRowMap;
240 
242 
243  sigc::connection _change_connection;
244 
247 
249 };
250 
251 #endif /* _gtk_ardour_region_list_base_h_ */
void add(TreeModelColumnBase &column)
void set_sizing(TreeViewColumnSizing type)
void set_fixed_width(int fixed_width)
int append_column(TreeViewColumn &column)
Glib::RefPtr< TreeSelection > get_selection()
Glib::RefPtr< Pango::Layout > create_pango_layout(const Glib::ustring &text)
void populate_row(std::shared_ptr< ARDOUR::Region >, Gtk::TreeModel::Row const &, PBD::PropertyChange const &)
virtual void regions_changed(std::shared_ptr< ARDOUR::RegionList >, PBD::PropertyChange const &)
void locked_changed(std::string const &)
Gtk::CellEditable * _tags_editable
bool leave_notify(GdkEventCrossing *)
virtual bool key_press(GdkEventKey *)
void opaque_changed(std::string const &)
void populate_row_source(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
PBD::ScopedConnection _editor_thaw_connection
Gtk::TreeViewColumn * append_col(Gtk::TreeModelColumn< T > const &col, std::string const &sizing_text)
virtual bool list_region(std::shared_ptr< ARDOUR::Region >) const
void add_tag_column()
void tag_editing_canceled()
void populate_row_fade_in(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, std::shared_ptr< ARDOUR::AudioRegion >)
Gtkmm2ext::DnDTreeView< std::shared_ptr< ARDOUR::Region > > _display
void tag_editing_started(Gtk::CellEditable *, const Glib::ustring &)
void clock_format_changed()
virtual bool button_press(GdkEventButton *)
Gtk::Widget * _old_focus
void name_editing_started(Gtk::CellEditable *, const Glib::ustring &)
std::unordered_map< std::shared_ptr< ARDOUR::Region >, Gtk::TreeModel::iterator > RegionRowMap
void populate_row_position(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
void populate_row_muted(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
Gtk::CellEditable * _name_editable
void format_position(Temporal::timepos_t const &pos, char *buf, size_t bufsize, bool onoff=true) const
void populate_row_opaque(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
void setup_col(Gtk::TreeViewColumn *, int, Gtk::AlignmentEnum, const char *, const char *, bool require_mod_to_edit=false)
Glib::RefPtr< Gtk::TreeStore > _model
void add_region(std::shared_ptr< ARDOUR::Region >)
void populate_row_end(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
void populate_row_length(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
void populate_row_fade_out(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, std::shared_ptr< ARDOUR::AudioRegion >)
RegionRowMap region_row_map
void set_session(ARDOUR::Session *)
void drag_begin(Glib::RefPtr< Gdk::DragContext > const &)
void remove_weak_region(std::weak_ptr< ARDOUR::Region >)
void drag_data_get(Glib::RefPtr< Gdk::DragContext > const &, Gtk::SelectionData &, guint, guint)
bool focus_in(GdkEventFocus *)
virtual void tag_edit(const std::string &, const std::string &)
Gtk::Widget & widget()
sigc::connection _change_connection
void populate_row_used(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
void populate_row_name(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
bool enter_notify(GdkEventCrossing *)
void block_change_connection(bool b)
Gtk::SortType _sort_type
virtual void name_edit(const std::string &, const std::string &)
PBD::ScopedConnectionList _remove_region_connections
Gtk::TreeViewColumn * append_col(Gtk::TreeModelColumn< T > const &col, int width)
void populate_row_locked(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
bool focus_out(GdkEventFocus *)
void thaw_tree_model()
void add_name_column()
void muted_changed(std::string const &)
PBD::ScopedConnection _editor_freeze_connection
Gtk::ScrolledWindow _scroller
void name_editing_canceled()
void setup_toggle(Gtk::TreeViewColumn *, sigc::slot< void, std::string >)
void drag_end(Glib::RefPtr< Gdk::DragContext > const &)
void populate_row_sync(std::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
void suspend_redisplay()
void freeze_tree_model()
@ TREE_VIEW_COLUMN_FIXED
PBD::PropertyDescriptor< bool > region
T * manage(T *obj)
Definition: object.h:58
Gtk::TreeModelColumn< std::string > fadeout
Gtk::TreeModelColumn< std::string > length
Gtk::TreeModelColumn< std::string > natural_pos
Gtk::TreeModelColumn< std::string > fadein
Gtk::TreeModelColumn< std::string > name
Gtk::TreeModelColumn< Temporal::timepos_t > position
Gtk::TreeModelColumn< std::string > take_id
Gtk::TreeModelColumn< std::shared_ptr< ARDOUR::Region > > region
Gtk::TreeModelColumn< Gdk::Color > color_
Gtk::TreeModelColumn< std::string > path
Gtk::TreeModelColumn< std::string > sync
Gtk::TreeModelColumn< std::string > captd_for
Gtk::TreeModelColumn< bool > muted
Gtk::TreeModelColumn< Temporal::timepos_t > natural_s
Gtk::TreeModelColumn< std::string > end
Gtk::TreeModelColumn< bool > opaque
Gtk::TreeModelColumn< bool > locked
Gtk::TreeModelColumn< size_t > captd_xruns
Gtk::TreeModelColumn< int > channels
Gtk::TreeModelColumn< std::string > tags
Gtk::TreeModelColumn< std::string > start
gint width
Definition: xcursors.h:1