Ardour  9.0-pre0-1467-gc8540a5ad6
audio_clip_editor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2021 Ben Loftis <ben@harrisonconsoles.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #pragma once
21 
22 #include <map>
23 
24 #include <ytkmm/box.h>
25 #include <ytkmm/label.h>
26 #include <ytkmm/table.h>
27 
28 #include "pbd/history_owner.h"
29 
30 #include "ardour/ardour.h"
31 #include "ardour/session_handle.h"
32 #include "ardour/triggerbox.h"
33 #include "ardour/types.h"
34 
35 #include "gtkmm2ext/actions.h"
36 #include "gtkmm2ext/bindings.h"
37 #include "gtkmm2ext/cairo_packer.h"
38 
39 #include "widgets/ardour_button.h"
40 
41 #include "canvas/container.h"
42 #include "canvas/line.h"
43 #include "canvas/rectangle.h"
44 #include "canvas/ruler.h"
45 #include "canvas/scroll_group.h"
46 
47 #include "audio_clock.h"
48 #include "cue_editor.h"
49 
50 namespace ARDOUR
51 {
52  class Session;
53  class Location;
54  class Trigger;
55 }
56 
57 namespace ArdourCanvas
58 {
59  class Text;
60  class Polygon;
61 }
62 
63 namespace ArdourWaveView
64 {
65  class WaveView;
66 }
67 
68 class AudioClipEditor : public CueEditor
69 {
70 public:
71  AudioClipEditor (std::string const &, bool with_transport = false);
73 
75 
77 
79  void set_region (std::shared_ptr<ARDOUR::Region> r);
80  void region_changed (const PBD::PropertyChange& what_changed);
81 
83 
84  /* EditingContext API. As of July 2025, we do not implement most of
85  * these
86  */
87 
92  bool button_press_dispatch (GdkEventButton*) { return true; }
93  bool button_release_dispatch (GdkEventButton*) { return true; }
94  bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false) { return true; }
95  bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType) { return true; }
96  bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType) { return true; }
99 
100  bool canvas_note_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
101  bool canvas_velocity_base_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
102  bool canvas_velocity_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
104  bool canvas_bg_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
105 
108 
109  Gdk::Cursor* which_track_cursor () const { return nullptr; }
110  Gdk::Cursor* which_mode_cursor () const { return nullptr; }
111  Gdk::Cursor* which_trim_cursor (bool left_side) const { return nullptr; }
112  Gdk::Cursor* which_canvas_cursor (ItemType type) const { return nullptr; }
113 
116 
117  void select_all_within (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list<SelectableOwner*> const &, ARDOUR::SelectionOperation, bool) {}
118  void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<std::shared_ptr<Evoral::Note<Temporal::Beats> > > > >&) const {}
120 
122  void delete_ () {}
123  void paste (float times, bool from_context_menu) {}
124  void keyboard_paste () {}
126 
127  void maybe_update ();
128 
129  bool idle_data_captured () { return false; }
130 
131  private:
138 
140  {
141  public:
143  units_per_pixel = 1;
144  }
145 
146  void get_marks (std::vector<ArdourCanvas::Ruler::Mark>& marks, int64_t lower, int64_t upper, int maxchars) const;
147 
148  private:
150 
151  };
152 
154  std::vector<ArdourWaveView::WaveView*> waves;
158 
159  void scroll_left ();
160  void scrol_right ();
161 
162  enum LineType {
166  };
167 
170  void drop_waves ();
174  void set_colors ();
175  void position_lines ();
176  void scroll_changed ();
177 
178  class LineDrag
179  {
180  public:
182 
186 
187  private:
190  };
191 
192  friend class LineDrag;
194 
196 
197  void build_canvas ();
201 
203 
204  void begin_write ();
205  void end_write ();
206 
207  void show_count_in (std::string const &);
208  void hide_count_in ();
209 
210  void unset (bool trigger_too);
212 };
void get_marks(std::vector< ArdourCanvas::Ruler::Mark > &marks, int64_t lower, int64_t upper, int maxchars) const
ClipBBTMetric(ARDOUR::TriggerReference tr)
ARDOUR::TriggerReference tref
LineDrag(AudioClipEditor &, ArdourCanvas::Line &)
ArdourCanvas::Line & line
void motion(GdkEventMotion *)
void begin(GdkEventButton *)
void end(GdkEventButton *)
void show_count_in(std::string const &)
void scroll_changed()
Gdk::Cursor * which_mode_cursor() const
samplepos_t left_origin
bool canvas_enter_leave(GdkEventCrossing *ev)
bool line_event_handler(GdkEvent *ev, ArdourCanvas::Line *)
void point_selection_changed()
bool key_press_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void paste(float times, bool from_context_menu)
bool canvas_bg_event(GdkEvent *event, ArdourCanvas::Item *)
Gdk::Cursor * which_track_cursor() const
ArdourCanvas::Container * ruler_container
ArdourCanvas::Line * end_line
LineDrag * current_line_drag
bool key_release_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void set_region(std::shared_ptr< ARDOUR::Region > r)
void pack_inner(Gtk::Box &)
Gdk::Cursor * which_trim_cursor(bool left_side) const
bool canvas_note_event(GdkEvent *event, ArdourCanvas::Item *)
bool canvas_velocity_base_event(GdkEvent *event, ArdourCanvas::Item *)
bool canvas_velocity_event(GdkEvent *event, ArdourCanvas::Item *)
ArdourCanvas::Container * line_container
void region_changed(const PBD::PropertyChange &what_changed)
void get_per_region_note_selection(std::list< std::pair< PBD::ID, std::set< std::shared_ptr< Evoral::Note< Temporal::Beats > > > > > &) const
bool leave_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void position_lines()
void select_all_within(Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list< SelectableOwner * > const &, ARDOUR::SelectionOperation, bool)
void set_waveform_colors()
void build_lower_toolbar()
ClipBBTMetric * clip_metric
void set_samples_per_pixel(samplecnt_t)
PBD::ScopedConnection state_connection
bool canvas_control_point_event(GdkEvent *event, ArdourCanvas::Item *, ControlPoint *)
ArdourCanvas::Line * loop_line
Gdk::Cursor * which_canvas_cursor(ItemType type) const
bool motion_handler(ArdourCanvas::Item *, GdkEvent *, bool from_autoscroll=false)
bool enter_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
std::vector< ArdourWaveView::WaveView * > waves
bool event_handler(GdkEvent *ev)
void canvas_allocate(Gtk::Allocation &)
bool button_press_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void set_spp_from_length(ARDOUR::samplecnt_t)
bool button_press_handler_1(ArdourCanvas::Item *, GdkEvent *, ItemType)
void pack_outer(Gtk::Box &)
AudioClipEditor(std::string const &, bool with_transport=false)
void hide_count_in()
ArdourCanvas::Line * start_line
bool button_release_dispatch(GdkEventButton *)
Temporal::timepos_t snap_to_grid(Temporal::timepos_t const &start, Temporal::RoundMode direction, ARDOUR::SnapPref gpref) const
void set_trigger(ARDOUR::TriggerReference &)
void snap_to_internal(Temporal::timepos_t &first, Temporal::RoundMode direction=Temporal::RoundNearest, ARDOUR::SnapPref gpref=ARDOUR::SnapToAny_Visual, bool ensure_snap=false) const
void set_wave_heights()
samplecnt_t current_page_samples() const
void get_regionviews_by_id(PBD::ID const id, RegionSelection &regions) const
void unset(bool trigger_too)
bool button_press_dispatch(GdkEventButton *)
void cut_copy(Editing::CutCopyOp)
Gtk::Widget & contents()
void load_shared_bindings()
ArdourCanvas::Ruler * minsec_ruler
bool key_press(GdkEventKey *)
bool button_press_handler_2(ArdourCanvas::Item *, GdkEvent *, ItemType)
bool button_release_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
Definition: id.h:34
ItemType
Definition: editor_items.h:24
PBD::PropertyDescriptor< bool > regions
PBD::PropertyDescriptor< timepos_t > start
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t
CutCopyOp
Definition: editing.h:228
@ RoundNearest
Round to nearest.