Ardour  9.0-pre0-822-g12e3bc5c20
time_axis_view.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2008 Nick Mainsbridge <mainsbridge@gmail.com>
3  * Copyright (C) 2005-2019 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
5  * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
6  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
7  * Copyright (C) 2007 Doug McLain <doug@nostar.net>
8  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
9  * Copyright (C) 2014-2015 Ben Loftis <ben@harrisonconsoles.com>
10  * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  */
26 
27 #pragma once
28 
29 #include <vector>
30 #include <list>
31 
32 #include <ytkmm/box.h>
33 #include <ytkmm/fixed.h>
34 #include <ytkmm/frame.h>
35 #include <ytkmm/drawingarea.h>
36 #include <ytkmm/eventbox.h>
37 #include <ytkmm/table.h>
38 #include <ytkmm/entry.h>
39 #include <ytkmm/label.h>
40 #include <ytkmm/sizegroup.h>
41 
42 #include "pbd/stateful.h"
43 #include "pbd/signals.h"
44 
45 #include "evoral/Parameter.h"
46 
47 #include "ardour/types.h"
49 #include "ardour/region.h"
50 
51 #include "canvas/line.h"
52 
53 #include "widgets/focus_entry.h"
54 
55 #include "axis_view.h"
56 #include "enums.h"
57 #include "editing.h"
58 #include "selectable.h"
59 
60 namespace ARDOUR {
61  class Session;
62  class Region;
63  class Session;
64  class RouteGroup;
65  class Playlist;
66  class Stripable;
67 }
68 
69 namespace Gtk {
70  class Menu;
71 }
72 
73 namespace ArdourCanvas {
74  class Canvas;
75  class Container;
76  class Item;
77 }
78 
79 class PublicEditor;
80 class RegionSelection;
81 class TimeSelection;
82 class PointSelection;
83 class TimeAxisViewItem;
84 class Selection;
85 class RegionView;
86 class GhostRegion;
87 class StreamView;
88 class ArdourDialog;
89 class ItemCounts;
90 class PasteContext;
91 
97 class TimeAxisView : public virtual AxisView, public SelectableOwner
98 {
99 private:
102  NameEntryPacked = 0x2
103  };
104 
105 public:
107  virtual ~TimeAxisView ();
108 
110 
111  static void setup_sizes ();
112 
114  int order () const { return _order; }
115 
117  static int max_order () { return _max_order; }
118 
121 
124  uint32_t effective_height () const { return _effective_height; }
125 
127  double y_position () const { return _y_position; }
128 
130  PublicEditor& editor () const { return _editor; }
131 
132  uint32_t current_height() const { return height; }
133 
134  void idle_resize (int32_t);
135 
136  virtual guint32 show_at (double y, int& nth, Gtk::VBox *parent);
137  virtual void hide ();
138 
139  bool touched (double top, double bot);
140 
142  bool hidden () const { return _hidden; }
143 
144  void set_selected (bool);
145 
146  virtual bool selectable() const { return true; }
147 
152  virtual void entered () {}
153  virtual void exited () {}
154 
159  };
160 
161  virtual void set_height (uint32_t h, TrackHeightMode m = OnlySelf, bool from_idle = false);
162  void set_height_enum (Height, bool apply_to_selection = false);
163  void reset_height();
164 
165  virtual void reset_visual_state ();
166 
167  std::pair<TimeAxisView*, double> covers_y_position (double) const;
168  bool covered_by_y_range (double y0, double y1) const;
169 
170  virtual void step_height (bool);
171 
172  virtual ARDOUR::RouteGroup* route_group() const { return 0; }
173  virtual std::shared_ptr<ARDOUR::Playlist> playlist() const { return std::shared_ptr<ARDOUR::Playlist> (); }
174 
175  virtual void set_samples_per_pixel (double);
176  virtual void show_selection (TimeSelection&);
177  virtual void hide_selection ();
179  virtual void show_timestretch (Temporal::timepos_t const & start, Temporal::timepos_t const & end, int layers, int layer);
180  virtual void hide_timestretch ();
181 
182  /* editing operations */
183 
185 
191  virtual bool paste (Temporal::timepos_t const & pos,
192  const Selection& selection,
193  PasteContext& ctx)
194  {
195  return false;
196  }
197 
198 
201 
202  virtual void fade_range (TimeSelection&) {}
203 
204  virtual std::shared_ptr<ARDOUR::Region> find_next_region (ARDOUR::timepos_t const & /*pos*/, ARDOUR::RegionPoint, int32_t /*dir*/) {
205  return std::shared_ptr<ARDOUR::Region> ();
206  }
207 
208  void order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top);
209 
210  void _get_selectables (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list<Selectable*>&, bool within);
211  void get_inverted_selectables (Selection&, std::list<Selectable *>& results);
213 
217 
220  virtual void first_idle () {}
221 
224 
225  virtual LayerDisplay layer_display () const { return Overlaid; }
226  virtual StreamView* view () const { return 0; }
227 
228  typedef std::vector<std::shared_ptr<TimeAxisView> > Children;
230 
231  static uint32_t preset_height (Height);
232 
233 protected:
234  static Glib::RefPtr<Gtk::SizeGroup> controls_meters_size_group;
235  static Glib::RefPtr<Gtk::SizeGroup> midi_scroomer_size_group;
236  static unsigned int name_width_px;
237  /* The Standard LHS Controls */
239  Glib::RefPtr<Gtk::SizeGroup> controls_button_size_group;
240  Gtk::EventBox controls_ebox;
241  Gtk::VBox controls_vbox;
242  Gtk::VBox time_axis_vbox;
243  Gtk::HBox time_axis_hbox;
244  Gtk::Frame time_axis_frame;
245  Gtk::HBox top_hbox;
248  uint32_t height; /* in canvas units */
251  Gtk::Menu* display_menu; /* The standard LHS Track control popup-menus */
255  std::list<GhostRegion*> ghosts;
256  std::list<SelectionRect*> free_selection_rects;
257  std::list<SelectionRect*> used_selection_rects;
258  bool _hidden;
260  Gtk::Menu* _size_menu;
263  double _y_position;
265 
266  virtual bool can_edit_name() const;
267 
269  void end_name_edit (std::string, int);
270  virtual std::string name () const { return name_label.get_text (); }
271 
272  /* derived classes can override these */
273 
274  virtual bool name_entry_changed (std::string const&);
275 
280  virtual bool controls_ebox_button_release (GdkEventButton*);
281  virtual bool controls_ebox_scroll (GdkEventScroll*);
282  virtual bool controls_ebox_button_press (GdkEventButton*);
283  virtual bool controls_ebox_motion (GdkEventMotion*);
284  virtual bool controls_ebox_leave (GdkEventCrossing*);
285 
289  virtual void build_display_menu ();
290 
293  virtual bool handle_display_menu_map_event (GdkEventAny * /*ev*/) { return false; }
294 
297  virtual bool propagate_time_selection () const { return false; }
298 
299  virtual void remove_child (std::shared_ptr<TimeAxisView>);
300  void add_child (std::shared_ptr<TimeAxisView>);
301 
302  /* selection display */
303 
304  virtual void selection_click (GdkEventButton*);
305 
306  void color_handler ();
307  void parameter_changed (std::string const &);
308 
310 
312 
313 private:
314  Gtk::VBox* control_parent;
315  int _order;
319  GdkCursor* _preresize_cursor;
322 
323  static uint32_t button_height;
324  static uint32_t extra_height;
325  static int const _max_order;
326 
328 
330  bool maybe_set_cursor (int y);
331  void popup_display_menu (int button, guint32 when);
332 
333 
334 }; /* class TimeAxisView */
335 
Gtk::Label name_label
Definition: axis_view.h:131
Representation of the interface of the Editor class.
Lists of selected things.
double y_position() const
virtual void set_samples_per_pixel(double)
Gtk::Menu * display_menu
static Glib::RefPtr< Gtk::SizeGroup > midi_scroomer_size_group
void order_selection_trims(ArdourCanvas::Item *item, bool put_start_on_top)
virtual bool controls_ebox_button_press(GdkEventButton *)
Gtk::HBox time_axis_hbox
virtual void reset_visual_state()
std::vector< std::shared_ptr< TimeAxisView > > Children
virtual void hide_timestretch()
double _y_position
virtual std::string name() const
Glib::RefPtr< Gtk::SizeGroup > controls_button_size_group
static void setup_sizes()
ArdourCanvas::Container * selection_group
Gtk::HBox top_hbox
virtual void show_timestretch(Temporal::timepos_t const &start, Temporal::timepos_t const &end, int layers, int layer)
std::string controls_base_unselected_name
virtual bool propagate_time_selection() const
Gtk::VBox controls_vbox
uint32_t current_height() const
virtual void entered()
virtual bool can_edit_name() const
ArdourCanvas::Container * _ghost_group
uint32_t _effective_height
bool touched(double top, double bot)
void build_size_menu()
virtual bool controls_ebox_button_release(GdkEventButton *)
virtual bool selectable() const
virtual LayerDisplay layer_display() const
bool _ebox_release_can_act
virtual void fade_range(TimeSelection &)
TimeAxisView * parent
bool maybe_set_cursor(int y)
ArdourCanvas::Container * canvas_display()
virtual void exited()
ArdourCanvas::Container * _canvas_display
void color_handler()
virtual void build_display_menu()
static int const _max_order
PublicEditor & editor() const
void erase_ghost(GhostRegion *)
Children get_child_list() const
static uint32_t extra_height
virtual guint32 show_at(double y, int &nth, Gtk::VBox *parent)
virtual bool controls_ebox_leave(GdkEventCrossing *)
void parameter_changed(std::string const &)
static Glib::RefPtr< Gtk::SizeGroup > controls_meters_size_group
void set_parent(TimeAxisView &p)
virtual StreamView * view() const
void get_inverted_selectables(Selection &, std::list< Selectable * > &results)
std::string controls_base_selected_name
bool covered_by_y_range(double y0, double y1) const
virtual ARDOUR::RouteGroup * route_group() const
virtual void hide()
void _get_selectables(Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list< Selectable * > &, bool within)
virtual void selection_click(GdkEventButton *)
void set_height_enum(Height, bool apply_to_selection=false)
virtual void set_height(uint32_t h, TrackHeightMode m=OnlySelf, bool from_idle=false)
Children children
virtual void hide_selection()
virtual void reshow_selection(TimeSelection &)
void set_selected(bool)
Gtk::Fixed scroomer_placeholder
SelectionRect * get_selection_rect(uint32_t id)
Gtk::VBox time_axis_vbox
virtual void step_height(bool)
Gtk::Frame time_axis_frame
void add_child(std::shared_ptr< TimeAxisView >)
static PBD::Signal< void(TimeAxisView *)> CatchDeletion
bool _have_preresize_cursor
double _resize_drag_start
Gtk::Menu * _size_menu
uint32_t height
Gtk::VBox * control_parent
void reset_height()
bool is_child(TimeAxisView *)
std::list< SelectionRect * > used_selection_rects
void idle_resize(int32_t)
virtual void set_selected_regionviews(RegionSelection &)
virtual bool handle_display_menu_map_event(GdkEventAny *)
std::list< SelectionRect * > free_selection_rects
Gtk::Table controls_table
void popup_display_menu(int button, guint32 when)
std::list< GhostRegion * > ghosts
bool hidden() const
TimeAxisView * get_parent()
virtual void set_selected_points(PointSelection &)
virtual bool controls_ebox_motion(GdkEventMotion *)
virtual void first_idle()
virtual ~TimeAxisView()
virtual bool controls_ebox_scroll(GdkEventScroll *)
TimeAxisView(ARDOUR::Session *sess, PublicEditor &ed, TimeAxisView *parent, ArdourCanvas::Canvas &canvas)
Gtk::EventBox controls_ebox
virtual void get_regionviews_at_or_after(Temporal::timepos_t const &, RegionSelection &)
virtual bool paste(Temporal::timepos_t const &pos, const Selection &selection, PasteContext &ctx)
void end_name_edit(std::string, int)
PublicEditor & _editor
void compute_heights()
static uint32_t preset_height(Height)
int order() const
void conditionally_add_to_selection()
static unsigned int name_width_px
GdkCursor * _preresize_cursor
virtual void cut_copy_clear(Selection &, Editing::CutCopyOp)
virtual std::shared_ptr< ARDOUR::Playlist > playlist() const
uint32_t effective_height() const
std::pair< TimeAxisView *, double > covers_y_position(double) const
void add_ghost(RegionView *)
virtual void remove_child(std::shared_ptr< TimeAxisView >)
static int max_order()
virtual std::shared_ptr< ARDOUR::Region > find_next_region(ARDOUR::timepos_t const &, ARDOUR::RegionPoint, int32_t)
ArdourCanvas::Line * _canvas_separator
static uint32_t button_height
ArdourCanvas::Container * ghost_group()
void remove_ghost(RegionView *)
void begin_name_edit()
virtual bool name_entry_changed(std::string const &)
virtual void show_selection(TimeSelection &)
Height
Definition: enums.h:48
LayerDisplay
Definition: enums.h:35
@ Overlaid
Definition: enums.h:36
struct Table Table
PBD::PropertyDescriptor< timepos_t > start
PBD::PropertyDescriptor< layer_t > layer
CutCopyOp
Definition: editing.h:228
Definition: ardour_ui.h:189
link region and track selection