Ardour  9.0-pre0-1950-g391fe97693
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 
81  void set_region (std::shared_ptr<ARDOUR::Region> r);
82  void region_changed (const PBD::PropertyChange& what_changed);
83 
85 
86  /* EditingContext API. As of July 2025, we do not implement most of
87  * these
88  */
89 
94  bool button_press_dispatch (GdkEventButton*) { return true; }
95  bool button_release_dispatch (GdkEventButton*) { return true; }
96 
97  bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false);
98 
103 
104  bool canvas_note_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
105  bool canvas_velocity_base_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
106  bool canvas_velocity_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
108  bool canvas_bg_event (GdkEvent* event, ArdourCanvas::Item*) { return true; }
109 
112 
113  Gdk::Cursor* which_track_cursor () const { return nullptr; }
114  Gdk::Cursor* which_mode_cursor () const { return nullptr; }
115  Gdk::Cursor* which_trim_cursor (bool left_side) const { return nullptr; }
117 
120 
121  void select_all_within (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list<SelectableOwner*> const &, ARDOUR::SelectionOperation, bool) {}
122  void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<std::shared_ptr<Evoral::Note<Temporal::Beats> > > > >&) const {}
124 
126  void delete_ () {}
127  void paste (float times, bool from_context_menu) {}
128  void keyboard_paste () {}
130 
131  void maybe_update ();
132 
134 
135  void set_overlay_text (std::string const &);
138 
139  private:
147 
149  {
150  public:
152  units_per_pixel = 1;
153  }
154 
155  void get_marks (std::vector<ArdourCanvas::Ruler::Mark>& marks, int64_t lower, int64_t upper, int maxchars) const;
156 
157  private:
159 
160  };
161 
163  std::vector<ArdourWaveView::WaveView*> waves;
167 
168  void scroll_left ();
169  void scrol_right ();
170 
174  void drop_waves ();
178  void set_colors ();
179  void position_lines ();
180  void scroll_changed ();
181 
183 
184  void build_canvas ();
188 
190 
191  void begin_write ();
192  void end_write ();
193 
194  void show_count_in (std::string const &);
195  void hide_count_in ();
196 
197  void unset_region ();
198  void unset_trigger ();
199 
201 
204 
207 
210 
211  Gtk::Box* pack_mouse_mode_box () { return nullptr; }
212 };
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 show_overlay_text()
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
void hide_overlay_text()
bool key_release_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void set_region(std::shared_ptr< ARDOUR::Region > r)
bool idle_data_captured()
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)
ArdourCanvas::Text * overlay_text
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 set_overlay_text(std::string const &)
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 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()
void unset_trigger()
samplecnt_t current_page_samples() const
void get_regionviews_by_id(PBD::ID const id, RegionSelection &regions) const
void update_fixed_rulers()
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.