Ardour  9.0-pre0-386-g96ef4d20f2
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 <gtkmm/box.h>
25 #include <gtkmm/label.h>
26 #include <gtkmm/table.h>
27 
28 #include "ardour/ardour.h"
29 #include "ardour/session_handle.h"
30 #include "ardour/triggerbox.h"
31 #include "ardour/types.h"
32 
33 #include "gtkmm2ext/actions.h"
34 #include "gtkmm2ext/bindings.h"
35 #include "gtkmm2ext/cairo_packer.h"
36 
37 #include "widgets/ardour_button.h"
38 
39 #include "canvas/canvas.h"
40 #include "canvas/container.h"
41 #include "canvas/line.h"
42 #include "canvas/rectangle.h"
43 #include "canvas/ruler.h"
44 #include "canvas/scroll_group.h"
45 
46 #include "audio_clock.h"
47 
48 namespace ARDOUR
49 {
50  class Session;
51  class Location;
52  class Trigger;
53 }
54 
55 namespace ArdourCanvas
56 {
57  class Text;
58  class Polygon;
59 }
60 
61 namespace ArdourWaveView
62 {
63  class WaveView;
64 }
65 
67 {
68 public:
71 
72  virtual void set_region (std::shared_ptr<ARDOUR::Region>, ARDOUR::TriggerReference) = 0;
73 
74  static void init ();
76  static Glib::RefPtr<Gtk::ActionGroup> clip_editor_actions;
77 };
78 
80 {
81 public:
82  virtual ~ClipEditor () {}
83 
84  virtual void zoom_in () = 0;
85  virtual void zoom_out () = 0;
86 };
87 
89 {
90 public:
93 
94  void set_region (std::shared_ptr<ARDOUR::AudioRegion>, ARDOUR::TriggerReference);
96 
99 
100  void set_spp (double);
101  double spp () const
102  {
103  return _spp;
104  }
105 
107 
108 private:
119 
121  {
122  public:
124  units_per_pixel = 1;
125  }
126 
127  void get_marks (std::vector<ArdourCanvas::Ruler::Mark>& marks, int64_t lower, int64_t upper, int maxchars) const;
128 
129  private:
131 
132  };
133 
135  std::vector<ArdourWaveView::WaveView*> waves;
138  double _spp;
140  std::shared_ptr<ARDOUR::AudioRegion> audio_region;
141 
142  void scroll_left ();
143  void scrol_right ();
144 
145  enum LineType {
149  };
150 
154  void drop_waves ();
158  void set_colors ();
159  void position_lines ();
160  void scroll_changed ();
161 
162  class LineDrag
163  {
164  public:
166 
170 
171  private:
174  };
175 
176  friend class LineDrag;
178 
180  {
181  public:
183 
187 
188  private:
190  double last_x;
191  };
192 
193  friend class ScrollDrag;
195 };
196 
198 {
199 public:
202 
203  void set_region (std::shared_ptr<ARDOUR::Region>, ARDOUR::TriggerReference);
204  void region_changed (const PBD::PropertyChange& what_changed);
205 
206 private:
212 
214 
216 
217  std::shared_ptr<ARDOUR::Region> _region;
218 
219  void zoom_in_click ();
220  void zoom_out_click ();
221 };
222 
Declaration of the main canvas classes.
AudioClipEditor * editor
void region_changed(const PBD::PropertyChange &what_changed)
ArdourWidgets::ArdourButton zoom_out_button
PBD::ScopedConnection state_connection
ArdourWidgets::ArdourButton zoom_in_button
void set_region(std::shared_ptr< ARDOUR::Region >, ARDOUR::TriggerReference)
std::shared_ptr< ARDOUR::Region > _region
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 begin(GdkEventButton *)
void end(GdkEventButton *)
void motion(GdkEventMotion *)
ScrollDrag(AudioClipEditor &)
void scroll_changed()
samplepos_t left_origin
void set_region(std::shared_ptr< ARDOUR::AudioRegion >, ARDOUR::TriggerReference)
bool line_event_handler(GdkEvent *ev, ArdourCanvas::Line *)
ArdourCanvas::Rectangle * scroll_bar_trough
ArdourCanvas::Container * ruler_container
ArdourCanvas::Line * end_line
void on_size_allocate(Gtk::Allocation &)
This is a default handler for the signal signal_size_allocate().
LineDrag * current_line_drag
ArdourCanvas::Container * line_container
ScrollDrag * current_scroll_drag
void position_lines()
samplepos_t pixel_to_sample(double)
void set_waveform_colors()
ClipBBTMetric * clip_metric
void set_spp(double)
ArdourCanvas::Line * loop_line
std::vector< ArdourWaveView::WaveView * > waves
bool event_handler(GdkEvent *ev)
bool scroll_event_handler(GdkEvent *ev)
void set_spp_from_length(ARDOUR::samplecnt_t)
ArdourCanvas::Line * start_line
ArdourCanvas::Rectangle * frame
ArdourCanvas::Rectangle * scroll_bar_handle
double sample_to_pixel(ARDOUR::samplepos_t)
double spp() const
std::shared_ptr< ARDOUR::AudioRegion > audio_region
void set_wave_heights()
ArdourCanvas::Ruler * ruler
ArdourCanvas::ScrollGroup * waves_container
bool key_press(GdkEventKey *)
virtual void set_region(std::shared_ptr< ARDOUR::Region >, ARDOUR::TriggerReference)=0
static void register_clip_editor_actions(Gtkmm2ext::Bindings *)
static void init()
static Glib::RefPtr< Gtk::ActionGroup > clip_editor_actions
virtual void zoom_in()=0
virtual void zoom_out()=0
virtual ~ClipEditor()
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t