ardour
editor_regions.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2000-2009 Paul Davis
3 
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.
8 
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.
13 
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.
17 
18 */
19 #ifndef __gtk_ardour_editor_regions_h__
20 #define __gtk_ardour_editor_regions_h__
21 
22 #include "editor_component.h"
23 #include <boost/unordered_map.hpp>
24 
26 {
27 public:
29 
31 
32  Gtk::Widget& widget () {
33  return _scroller;
34  }
35 
36  void clear ();
37 
38  void toggle_full ();
40  void reset_sort_direction (bool);
44 
47 
49  return _sort_type;
50  }
51 
52  void redisplay ();
53 
55  _no_redisplay = true;
56  }
57 
58  void resume_redisplay () {
59  _no_redisplay = false;
60  redisplay ();
61  }
62 
63  void block_change_connection (bool b) {
64  _change_connection.block (b);
65  }
66 
67  void unselect_all () {
68  _display.get_selection()->unselect_all ();
69  }
70 
71  void remove_unused_regions ();
72 
73  XMLNode& get_state () const;
74  void set_state (const XMLNode &);
75 
76 private:
77 
78  struct Columns : public Gtk::TreeModel::ColumnRecord {
79  Columns () {
80  add (name);
81  add (region);
82  add (color_);
83  add (position);
84  add (end);
85  add (length);
86  add (sync);
87  add (fadein);
88  add (fadeout);
89  add (locked);
90  add (glued);
91  add (muted);
92  add (opaque);
93  add (used);
94  add (path);
96  }
97 
98  Gtk::TreeModelColumn<std::string> name;
99  Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
100  Gtk::TreeModelColumn<Gdk::Color> color_;
101  Gtk::TreeModelColumn<std::string> position;
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> used;
112  Gtk::TreeModelColumn<std::string> path;
114  Gtk::TreeModelColumn<bool> property_toggles_visible;
115  };
116 
118 
119  Gtk::TreeModel::RowReference last_row;
120 
121  void freeze_tree_model ();
122  void thaw_tree_model ();
124  void selection_changed ();
125 
126  sigc::connection _change_connection;
127 
128  bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
129 
130  Gtk::Widget* old_focus;
131  Gtk::CellEditable* name_editable;
132  void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
133 
134  void name_edit (const std::string&, const std::string&);
135  void locked_changed (std::string const &);
136  void glued_changed (std::string const &);
137  void muted_changed (std::string const &);
138  void opaque_changed (std::string const &);
139 
140  bool key_press (GdkEventKey *);
141  bool button_press (GdkEventButton *);
142 
143  bool focus_in (GdkEventFocus*);
144  bool focus_out (GdkEventFocus*);
145  bool enter_notify (GdkEventCrossing*);
146  bool leave_notify (GdkEventCrossing*);
147 
148  void show_context_menu (int button, int time);
149 
150  int sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
151 
152  void format_position (ARDOUR::framepos_t pos, char* buf, size_t bufsize, bool onoff = true);
153 
155 
156  void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &);
157  void populate_row_used (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
158  void populate_row_position (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
159  void populate_row_end (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
160  void populate_row_sync (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
161  void populate_row_fade_in (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used, boost::shared_ptr<ARDOUR::AudioRegion>);
162  void populate_row_fade_out (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used, boost::shared_ptr<ARDOUR::AudioRegion>);
163  void populate_row_locked (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
164  void populate_row_muted (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
165  void populate_row_glued (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
166  void populate_row_opaque (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, uint32_t used);
167  void populate_row_length (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
168  void populate_row_name (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
169  void populate_row_source (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
170 
172  void update_all_rows ();
173 
175 
176  void drag_data_received (
177  Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
178  );
179 
180  Glib::RefPtr<Gtk::RadioAction> sort_type_action (Editing::RegionListSortType) const;
181  void set_full (bool);
182 
183  Glib::RefPtr<Gtk::Action> hide_action () const;
184  Glib::RefPtr<Gtk::Action> show_action () const;
185  Glib::RefPtr<Gtk::Action> remove_unused_regions_action () const;
186  Glib::RefPtr<Gtk::ToggleAction> toggle_full_action () const;
187  Glib::RefPtr<Gtk::ToggleAction> toggle_show_auto_regions_action () const;
188 
189  Gtk::Menu* _menu;
190  Gtk::ScrolledWindow _scroller;
191  Gtk::Frame _frame;
192 
194 
195  Glib::RefPtr<Gtk::TreeStore> _model;
196 
201 
203 
204  std::list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
205 
206  typedef boost::unordered_map<boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::RowReference> RegionRowMap;
207  typedef boost::unordered_map<std::string, Gtk::TreeModel::RowReference > RegionSourceMap;
208 
209  RegionRowMap region_row_map;
210  RegionSourceMap parent_regions_sources_map;
211 
214 
217 
218  bool expanded;
219 };
220 
221 #endif /* __gtk_ardour_editor_regions_h__ */
Gtk::TreeModelColumn< Gdk::Color > color_
void populate_row_glued(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, uint32_t used)
Gtk::TreeModelColumn< std::string > used
Gtk::Widget & widget()
void update_all_rows()
void region_changed(boost::shared_ptr< ARDOUR::Region >, PBD::PropertyChange const &)
void show_context_menu(int button, int time)
Gtk::TreeModelColumn< std::string > path
void populate_row(boost::shared_ptr< ARDOUR::Region >, Gtk::TreeModel::Row const &)
void reset_sort_type(Editing::RegionListSortType, bool)
void populate_row_sync(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, uint32_t used)
bool focus_out(GdkEventFocus *)
Glib::RefPtr< Gtk::TreeStore > _model
Gtkmm2ext::DnDTreeView< boost::shared_ptr< ARDOUR::Region > > _display
Gtk::TreeModelColumn< bool > locked
void set_full(bool)
void block_change_connection(bool b)
bool enter_notify(GdkEventCrossing *)
Gtk::TreeModelColumn< std::string > end
void populate_row_position(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, uint32_t used)
int sorter(Gtk::TreeModel::iterator, Gtk::TreeModel::iterator)
Gtk::TreeModelColumn< std::string > fadeout
void drag_data_received(Glib::RefPtr< Gdk::DragContext > const &, gint, gint, Gtk::SelectionData const &, guint, guint)
void populate_row_name(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
PBD::ScopedConnection editor_thaw_connection
bool leave_notify(GdkEventCrossing *)
void freeze_tree_model()
bool key_press(GdkEventKey *)
bool button_press(GdkEventButton *)
Gtk::TreeModelColumn< boost::shared_ptr< ARDOUR::Region > > region
void update_row(boost::shared_ptr< ARDOUR::Region >)
Gtk::TreeModelColumn< bool > muted
Glib::RefPtr< Gtk::ToggleAction > toggle_show_auto_regions_action() const
void reset_sort_direction(bool)
void toggle_show_auto_regions()
boost::shared_ptr< ARDOUR::Region > get_single_selection()
Gtk::ScrolledWindow _scroller
void add_region(boost::shared_ptr< ARDOUR::Region >)
void name_edit(const std::string &, const std::string &)
Glib::RefPtr< Gtk::Action > hide_action() const
void populate_row_source(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
void populate_row_opaque(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, uint32_t used)
bool ignore_region_list_selection_change
void populate_row_used(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, uint32_t used)
Gtk::TreeModelColumn< std::string > sync
Gtk::Widget * old_focus
Gtk::Frame _frame
void locked_changed(std::string const &)
Gtk::TreeModelColumn< bool > opaque
boost::unordered_map< std::string, Gtk::TreeModel::RowReference > RegionSourceMap
void populate_row_fade_in(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, uint32_t used, boost::shared_ptr< ARDOUR::AudioRegion >)
void insert_into_tmp_regionlist(boost::shared_ptr< ARDOUR::Region >)
void remove_unused_regions()
std::list< boost::shared_ptr< ARDOUR::Region > > tmp_region_list
void muted_changed(std::string const &)
bool selection_filter(const Glib::RefPtr< Gtk::TreeModel > &model, const Gtk::TreeModel::Path &path, bool yn)
void opaque_changed(std::string const &)
void set_session(ARDOUR::Session *)
EditorRegions(Editor *)
RegionSourceMap parent_regions_sources_map
Gtk::TreeModelColumn< std::string > length
PBD::ScopedConnection check_new_region_connection
bool _show_automatic_regions
Gtk::TreeModelColumn< bool > glued
int64_t framepos_t
Definition: types.h:66
void resume_redisplay()
sigc::connection _change_connection
Glib::RefPtr< Gtk::ToggleAction > toggle_full_action() const
void format_position(ARDOUR::framepos_t pos, char *buf, size_t bufsize, bool onoff=true)
Gtk::TreeModel::RowReference last_row
void set_state(const XMLNode &)
void populate_row_fade_out(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, uint32_t used, boost::shared_ptr< ARDOUR::AudioRegion >)
void suspend_redisplay()
void populate_row_muted(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, uint32_t used)
void unselect_all()
void set_selected(RegionSelection &)
boost::unordered_map< boost::shared_ptr< ARDOUR::Region >, Gtk::TreeModel::RowReference > RegionRowMap
void selection_changed()
Editing::RegionListSortType sort_type() const
Definition: editor.h:134
PBD::ScopedConnection region_property_connection
Definition: xml++.h:95
Gtk::TreeModelColumn< std::string > fadein
void name_editing_started(Gtk::CellEditable *, const Glib::ustring &)
void populate_row_length(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row)
Gtk::TreeModelColumn< bool > property_toggles_visible
Gtk::Menu * _menu
bool ignore_selected_region_change
void selection_mapover(sigc::slot< void, boost::shared_ptr< ARDOUR::Region > >)
void populate_row_end(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, uint32_t used)
boost::shared_ptr< ARDOUR::Region > get_dragged_region()
Gtk::TreeModelColumn< std::string > name
XMLNode & get_state() const
RegionRowMap region_row_map
void glued_changed(std::string const &)
Gtk::TreeModelColumn< std::string > position
Glib::RefPtr< Gtk::Action > show_action() const
PBD::ScopedConnection editor_freeze_connection
Gtk::CellEditable * name_editable
Glib::RefPtr< Gtk::Action > remove_unused_regions_action() const
Editing::RegionListSortType _sort_type
bool focus_in(GdkEventFocus *)
void populate_row_locked(boost::shared_ptr< ARDOUR::Region > region, Gtk::TreeModel::Row const &row, uint32_t used)
Glib::RefPtr< Gtk::RadioAction > sort_type_action(Editing::RegionListSortType) const
RegionListSortType
Definition: editing.h:77