Ardour  8.12
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 #ifndef __audio_region_trimmer_box_h__
21 #define __audio_region_trimmer_box_h__
22 
23 #include <map>
24 
25 #include <gtkmm/box.h>
26 #include <gtkmm/label.h>
27 #include <gtkmm/table.h>
28 
29 #include "ardour/ardour.h"
30 #include "ardour/session_handle.h"
31 #include "ardour/triggerbox.h"
32 #include "ardour/types.h"
33 
34 #include "gtkmm2ext/actions.h"
35 #include "gtkmm2ext/bindings.h"
36 #include "gtkmm2ext/cairo_packer.h"
37 
38 #include "widgets/ardour_button.h"
39 
40 #include "canvas/canvas.h"
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 
49 namespace ARDOUR
50 {
51  class Session;
52  class Location;
53  class Trigger;
54 }
55 
56 namespace ArdourCanvas
57 {
58  class Text;
59  class Polygon;
60 }
61 
62 namespace ArdourWaveView
63 {
64  class WaveView;
65 }
66 
68 {
69 public:
72 
73  virtual void set_region (std::shared_ptr<ARDOUR::Region>, ARDOUR::TriggerReference) = 0;
74 
75  static void init ();
77  static Glib::RefPtr<Gtk::ActionGroup> clip_editor_actions;
78 };
79 
81 {
82 public:
83  virtual ~ClipEditor () {}
84 
85  virtual void zoom_in () = 0;
86  virtual void zoom_out () = 0;
87 };
88 
90 {
91 public:
94 
95  void set_region (std::shared_ptr<ARDOUR::AudioRegion>, ARDOUR::TriggerReference);
97 
100 
101  void set_spp (double);
102  double spp () const
103  {
104  return _spp;
105  }
106 
108 
109 private:
120 
122  {
123  public:
125  units_per_pixel = 1;
126  }
127 
128  void get_marks (std::vector<ArdourCanvas::Ruler::Mark>& marks, int64_t lower, int64_t upper, int maxchars) const;
129 
130  private:
132 
133  };
134 
136  std::vector<ArdourWaveView::WaveView*> waves;
139  double _spp;
141  std::shared_ptr<ARDOUR::AudioRegion> audio_region;
142 
143  void scroll_left ();
144  void scrol_right ();
145 
146  enum LineType {
150  };
151 
155  void drop_waves ();
159  void set_colors ();
160  void position_lines ();
161  void scroll_changed ();
162 
163  class LineDrag
164  {
165  public:
167 
171 
172  private:
175  };
176 
177  friend class LineDrag;
179 
181  {
182  public:
184 
188 
189  private:
191  double last_x;
192  };
193 
194  friend class ScrollDrag;
196 };
197 
199 {
200 public:
203 
204  void set_region (std::shared_ptr<ARDOUR::Region>, ARDOUR::TriggerReference);
205  void region_changed (const PBD::PropertyChange& what_changed);
206 
207 private:
213 
215 
217 
218  std::shared_ptr<ARDOUR::Region> _region;
219 
220  void zoom_in_click ();
221  void zoom_out_click ();
222 };
223 
224 #endif /* __audio_region_trimmer_box_h__ */
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