ardour
crossfade_edit.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2000-2007 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #ifndef __gtk_ardour_xfade_edit_h__
21 #define __gtk_ardour_xfade_edit_h__
22 
23 #include <list>
24 
25 #include <gtkmm/box.h>
26 #include <gtkmm/button.h>
27 #include <gtkmm/radiobutton.h>
28 
29 #include "canvas/canvas.h"
30 
31 #include "evoral/Curve.hpp"
32 #include "ardour/session_handle.h"
33 
34 #include "ardour_dialog.h"
35 
36 namespace ARDOUR
37 {
38  class Session;
39  class AutomationList;
40  class Crossfade;
41 }
42 
43 namespace ArdourCanvas {
44  class Rectangle;
45  class Line;
46  class Polygon;
47  class WaveView;
48 }
49 
51 {
52  public:
55 
56  void apply ();
57 
58  static const double canvas_border;
59 
60  /* these are public so that a caller/subclass can make them do the right thing.
61  */
62 
63  Gtk::Button* cancel_button;
64  Gtk::Button* ok_button;
65 
66  struct PresetPoint {
67  double x;
68  double y;
69 
70  PresetPoint (double a, double b)
71  : x (a), y (b) {}
72  };
73 
74  struct Preset : public std::list<PresetPoint> {
75  const char* name;
76  const char* image_name;
77 
78  Preset (const char* n, const char* x) : name (n), image_name (x) {}
79  };
80 
81  typedef std::list<Preset*> Presets;
82 
83  static Presets* fade_in_presets;
84  static Presets* fade_out_presets;
85 
86  protected:
87  bool on_key_press_event (GdkEventKey*);
88  bool on_key_release_event (GdkEventKey*);
89 
90  private:
92 
93  Gtk::VBox vpacker;
94 
95  struct Point {
96  ~Point();
97 
98  ArdourCanvas::Rectangle* box;
99  ArdourCanvas::PolyLine* curve;
100  double x;
101  double y;
102 
103  static const int32_t size;
104 
105  void move_to (double x, double y, double xfract, double yfract);
106  };
107 
108  struct PointSorter {
110  return a->x < b->x;
111  }
112  };
113 
114  ArdourCanvas::Rectangle* toplevel;
115  ArdourCanvas::GtkCanvas* canvas;
116 
117  struct Half {
118  ArdourCanvas::PolyLine* line;
119  ArdourCanvas::Polygon* shading;
120  std::list<Point*> points;
122  ARDOUR::AutomationList gain_curve; /* 0 - 2.0, gain mapping */
123  std::vector<ArdourCanvas::WaveView*> waves;
124 
125  Half();
126  };
127 
128  enum WhichFade {
129  In = 0,
130  Out = 1
131  };
132 
133  Half fade[2];
135 
137  std::vector<Gtk::Button*> fade_out_buttons;
138  std::vector<Gtk::Button*> fade_in_buttons;
139 
140  Gtk::VBox vpacker2;
141 
142  Gtk::Button clear_button;
143  Gtk::Button revert_button;
144 
145  Gtk::ToggleButton audition_both_button;
146  Gtk::ToggleButton audition_left_dry_button;
147  Gtk::ToggleButton audition_left_button;
148  Gtk::ToggleButton audition_right_dry_button;
149  Gtk::ToggleButton audition_right_button;
150 
151  Gtk::ToggleButton preroll_button;
152  Gtk::ToggleButton postroll_button;
153 
154  Gtk::HBox roll_box;
155 
156  gint event_handler (GdkEvent*);
157 
158  bool canvas_event (GdkEvent* event);
159  bool point_event (GdkEvent* event, Point*);
160  bool curve_event (GdkEvent* event);
161 
162  void canvas_allocation (Gtk::Allocation&);
163  void add_control_point (double x, double y);
164  Point* make_point ();
165  void redraw ();
166 
167  double effective_width () const { return canvas->get_allocation().get_width() - (2.0 * canvas_border); }
168  double effective_height () const { return canvas->get_allocation().get_height() - (2.0 * canvas_border); }
169 
170  void clear ();
171  void reset ();
172 
173  double miny;
174  double maxy;
175 
176  Gtk::Table fade_in_table;
177  Gtk::Table fade_out_table;
178 
179  void build_presets ();
180  void apply_preset (Preset*);
181 
182  Gtk::RadioButton select_in_button;
183  Gtk::RadioButton select_out_button;
184  Gtk::HBox curve_button_box;
185  Gtk::HBox audition_box;
186 
188 
189  double x_coordinate (double& xfract) const;
190  double y_coordinate (double& yfract) const;
191 
192  void set (const ARDOUR::AutomationList& alist, WhichFade);
193 
196 
199 
202  void cancel_audition ();
203  void audition_state_changed (bool);
204 
205  enum Audition {
209  };
210 
211  void audition_toggled ();
212  void audition_right_toggled ();
214  void audition_left_toggled ();
216 
217  void audition (Audition);
218  void audition_both ();
219  void audition_left_dry ();
220  void audition_left ();
221  void audition_right_dry ();
222  void audition_right ();
223 
224  void xfade_changed (const PBD::PropertyChange&);
225 
226  void dump ();
227 };
228 
229 #endif /* __gtk_ardour_xfade_edit_h__ */
Gtk::ToggleButton audition_left_button
bool on_key_release_event(GdkEventKey *)
void _apply_to(boost::shared_ptr< ARDOUR::Crossfade > xf)
std::list< Point * > points
double y_coordinate(double &yfract) const
double effective_height() const
Gtk::Button clear_button
double effective_width() const
void xfade_changed(const PBD::PropertyChange &)
void move_to(double x, double y, double xfract, double yfract)
static Presets * fade_in_presets
Gtk::ToggleButton audition_right_dry_button
ArdourCanvas::Rectangle * box
void audition_left_dry_toggled()
PresetPoint(double a, double b)
std::list< Preset * > Presets
CrossfadeEditor(ARDOUR::Session *, boost::shared_ptr< ARDOUR::Crossfade >, double miny, double maxy)
bool curve_event(GdkEvent *event)
Gtk::Button * cancel_button
void audition_left_toggled()
Gtk::RadioButton select_in_button
Gtk::ToggleButton audition_left_dry_button
Gtk::ToggleButton audition_both_button
Gtk::VBox vpacker2
Point * make_point()
static const double canvas_border
Gtk::Button revert_button
ARDOUR::AutomationList gain_curve
std::vector< ArdourCanvas::WaveView * > waves
double x_coordinate(double &xfract) const
bool on_key_press_event(GdkEventKey *)
bool canvas_event(GdkEvent *event)
ArdourCanvas::GtkCanvas * canvas
void apply_preset(Preset *)
Gtk::ToggleButton preroll_button
Gtk::Table fade_out_table
ArdourCanvas::Rectangle * toplevel
Gtk::RadioButton select_out_button
void peaks_ready(boost::weak_ptr< ARDOUR::AudioRegion > r, WhichFade)
Gtk::HBox curve_button_box
void set(const ARDOUR::AutomationList &alist, WhichFade)
std::vector< Gtk::Button * > fade_in_buttons
PBD::ScopedConnection state_connection
ArdourCanvas::Polygon * shading
Definition: amp.h:29
void add_control_point(double x, double y)
gint event_handler(GdkEvent *)
void curve_select_clicked(WhichFade)
Gtk::HBox roll_box
void make_waves(boost::shared_ptr< ARDOUR::AudioRegion >, WhichFade)
void audition(Audition)
PBD::ScopedConnection * _peaks_ready_connection
Gtk::HBox audition_box
static const int32_t size
Preset(const char *n, const char *x)
ARDOUR::AutomationList normative_curve
void audition_state_changed(bool)
void setup(boost::shared_ptr< ARDOUR::Crossfade >)
boost::shared_ptr< ARDOUR::Crossfade > xfade
void audition_right_dry_toggled()
Gtk::Table fade_in_table
bool operator()(const CrossfadeEditor::Point *a, const CrossfadeEditor::Point *b)
void audition_right_toggled()
Gtk::VBox vpacker
Gtk::ToggleButton postroll_button
Gtk::ToggleButton audition_right_button
ArdourCanvas::PolyLine * curve
std::vector< Gtk::Button * > fade_out_buttons
static Presets * fade_out_presets
ArdourCanvas::PolyLine * line
void canvas_allocation(Gtk::Allocation &)
Gtk::Button * ok_button
bool point_event(GdkEvent *event, Point *)