Ardour  9.0-pre0-1786-g726295c4ce
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 StartBoundaryRect;
69 class EndBoundaryRect;
70 
71 class AudioClipEditor : public CueEditor
72 {
73 public:
74  AudioClipEditor (std::string const &, bool with_transport = false);
76 
78 
80 
82  void set_region (std::shared_ptr<ARDOUR::Region> r);
83  void region_changed (const PBD::PropertyChange& what_changed);
84 
86 
87  /* EditingContext API. As of July 2025, we do not implement most of
88  * these
89  */
90 
95  bool button_press_dispatch (GdkEventButton*) { return true; }
96  bool button_release_dispatch (GdkEventButton*) { return true; }
97 
98  bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false);
99 
104 
105  bool canvas_note_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
106  bool canvas_velocity_base_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
107  bool canvas_velocity_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
109  bool canvas_bg_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
110 
113 
114  Gdk::Cursor* which_track_cursor () const { return nullptr; }
115  Gdk::Cursor* which_mode_cursor () const { return nullptr; }
116  Gdk::Cursor* which_trim_cursor (bool left_side) const { return nullptr; }
118 
121 
122  void select_all_within (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list<SelectableOwner*> const &, ARDOUR::SelectionOperation, bool) {}
123  void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<std::shared_ptr<Evoral::Note<Temporal::Beats> > > > >&) const {}
125 
127  void delete_ () {}
128  void paste (float times, bool from_context_menu) {}
129  void keyboard_paste () {}
131 
132  void maybe_update ();
133 
134  bool idle_data_captured () { return false; }
135 
136  private:
143 
145  {
146  public:
148  units_per_pixel = 1;
149  }
150 
151  void get_marks (std::vector<ArdourCanvas::Ruler::Mark>& marks, int64_t lower, int64_t upper, int maxchars) const;
152 
153  private:
155 
156  };
157 
159  std::vector<ArdourWaveView::WaveView*> waves;
163 
164  void scroll_left ();
165  void scrol_right ();
166 
170  void drop_waves ();
174  void set_colors ();
175  void position_lines ();
176  void scroll_changed ();
177 
179 
180  void build_canvas ();
184 
186 
187  void begin_write ();
188  void end_write ();
189 
190  void show_count_in (std::string const &);
191  void hide_count_in ();
192 
193  void unset (bool trigger_too);
195 
198 
201 
204 
205  Gtk::Box* pack_mouse_mode_box () { return nullptr; }
206 };
void get_marks(std::vector< ArdourCanvas::Ruler::Mark > &marks, int64_t lower, int64_t upper, int maxchars) const
ClipMetric(AudioClipEditor &ac)
void show_count_in(std::string const &)
void scroll_changed()
Gtk::Box * pack_mouse_mode_box()
ArdourCanvas::Ruler * main_ruler
Gdk::Cursor * which_mode_cursor() const
samplepos_t left_origin
bool canvas_enter_leave(GdkEventCrossing *ev)
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 *)
void grid_type_chosen(Editing::GridType)
Gdk::Cursor * which_track_cursor() const
ArdourCanvas::Container * ruler_container
bool key_release_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void set_region(std::shared_ptr< ARDOUR::Region > r)
void pack_inner(Gtk::Box &)
bool end_line_event_handler(GdkEvent *ev, EndBoundaryRect *)
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 compute_fixed_ruler_scale()
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()
EndBoundaryRect * end_line
void build_lower_toolbar()
void set_samples_per_pixel(samplecnt_t)
PBD::ScopedConnection state_connection
StartBoundaryRect * start_line
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)
bool start_line_event_handler(GdkEvent *ev, StartBoundaryRect *)
void hide_count_in()
void set_action_defaults()
bool button_release_dispatch(GdkEventButton *)
Temporal::timepos_t snap_to_grid(Temporal::timepos_t const &start, Temporal::RoundMode direction, ARDOUR::SnapPref gpref) const
ClipMetric * clip_metric
void snap_mode_chosen(Editing::SnapMode)
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 update_fixed_rulers()
void unset(bool trigger_too)
bool button_press_dispatch(GdkEventButton *)
void cut_copy(Editing::CutCopyOp)
Gtk::Widget & contents()
void load_shared_bindings()
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:241
SnapMode
Definition: editing.h:71
GridType
Definition: editing.h:53
@ RoundNearest
Round to nearest.