1 #ifndef __gtk_ardour_xfade_edit_h__
2 #define __gtk_ardour_xfade_edit_h__
7 #include <gtkmm/button.h>
8 #include <gtkmm/radiobutton.h>
10 #include <ardour/curve.h>
11 #include "ardour_dialog.h"
21 class CrossfadeEditor : public ArdourDialog
24 CrossfadeEditor (ARDOUR::Session&, boost::shared_ptr<ARDOUR::Crossfade>, double miny, double maxy);
29 static const double canvas_border;
31 /* these are public so that a caller/subclass can make them do the right thing.
34 Gtk::Button* cancel_button;
35 Gtk::Button* ok_button;
41 PresetPoint (double a, double b)
45 struct Preset : public list<PresetPoint> {
46 const char* image_name;
48 Preset (const char* x) : image_name (x) {}
51 typedef list<Preset*> Presets;
53 static Presets* fade_in_presets;
54 static Presets* fade_out_presets;
57 boost::shared_ptr<ARDOUR::Crossfade> xfade;
58 ARDOUR::Session& session;
65 ArdourCanvas::SimpleRect* box;
66 ArdourCanvas::Line* curve;
70 static const int32_t size;
72 void move_to (double x, double y, double xfract, double yfract);
77 bool operator() (const CrossfadeEditor::Point* a, const CrossfadeEditor::Point *b) {
82 ArdourCanvas::SimpleRect* toplevel;
83 ArdourCanvas::Canvas* canvas;
86 ArdourCanvas::Line* line;
87 ArdourCanvas::Polygon* shading;
89 ARDOUR::Curve normative_curve; /* 0 - 1.0, linear */
90 ARDOUR::Curve gain_curve; /* 0 - 2.0, gain mapping */
91 vector<ArdourCanvas::WaveView*> waves;
105 vector<Gtk::Button*> fade_out_buttons;
106 vector<Gtk::Button*> fade_in_buttons;
110 Gtk::Button clear_button;
111 Gtk::Button revert_button;
113 Gtk::ToggleButton audition_both_button;
114 Gtk::ToggleButton audition_left_dry_button;
115 Gtk::ToggleButton audition_left_button;
116 Gtk::ToggleButton audition_right_dry_button;
117 Gtk::ToggleButton audition_right_button;
119 Gtk::ToggleButton preroll_button;
120 Gtk::ToggleButton postroll_button;
124 gint event_handler (GdkEvent*);
126 bool canvas_event (GdkEvent* event);
127 bool point_event (GdkEvent* event, Point*);
128 bool curve_event (GdkEvent* event);
130 void canvas_allocation (Gtk::Allocation&);
131 void add_control_point (double x, double y);
132 Point* make_point ();
135 double effective_width () const { return canvas->get_allocation().get_width() - (2.0 * canvas_border); }
136 double effective_height () const { return canvas->get_allocation().get_height() - (2.0 * canvas_border); }
144 Gtk::Table fade_in_table;
145 Gtk::Table fade_out_table;
147 void build_presets ();
148 void apply_preset (Preset*);
150 Gtk::RadioButton select_in_button;
151 Gtk::RadioButton select_out_button;
152 Gtk::HBox curve_button_box;
153 Gtk::HBox audition_box;
155 void curve_select_clicked (WhichFade);
157 double x_coordinate (double& xfract) const;
158 double y_coordinate (double& yfract) const;
160 void set (const ARDOUR::Curve& alist, WhichFade);
162 sigc::connection peaks_ready_connection;
164 void make_waves (boost::shared_ptr<ARDOUR::AudioRegion>, WhichFade);
165 void peaks_ready (boost::shared_ptr<ARDOUR::AudioRegion> r, WhichFade);
167 void _apply_to (boost::shared_ptr<ARDOUR::Crossfade> xf);
168 void setup (boost::shared_ptr<ARDOUR::Crossfade>);
169 void cancel_audition ();
170 void audition_state_changed (bool);
172 void audition_toggled ();
173 void audition_right_toggled ();
174 void audition_right_dry_toggled ();
175 void audition_left_toggled ();
176 void audition_left_dry_toggled ();
178 void audition_both ();
179 void audition_left_dry ();
180 void audition_left ();
181 void audition_right_dry ();
182 void audition_right ();
184 void xfade_changed (ARDOUR::Change);
189 #endif /* __gtk_ardour_xfade_edit_h__ */