2 Copyright (C) 2000-2007 Paul Davis
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.
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.
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.
20 #ifndef __gtk_ardour_xfade_edit_h__
21 #define __gtk_ardour_xfade_edit_h__
25 #include <gtkmm/box.h>
26 #include <gtkmm/button.h>
27 #include <gtkmm/radiobutton.h>
29 #include "canvas/canvas.h"
31 #include "evoral/Curve.hpp"
32 #include "ardour/session_handle.h"
34 #include "ardour_dialog.h"
43 namespace ArdourCanvas {
49 namespace ArdourWaveview {
53 class CrossfadeEditor : public ArdourDialog
56 CrossfadeEditor (ARDOUR::Session*, boost::shared_ptr<ARDOUR::Crossfade>, double miny, double maxy);
61 static const double canvas_border;
63 /* these are public so that a caller/subclass can make them do the right thing. */
65 Gtk::Button* cancel_button;
66 Gtk::Button* ok_button;
72 PresetPoint (double a, double b)
76 struct Preset : public std::list<PresetPoint> {
78 const char* image_name;
80 Preset (const char* n, const char* x) : name (n), image_name (x) {}
83 typedef std::list<Preset*> Presets;
85 static Presets* fade_in_presets;
86 static Presets* fade_out_presets;
89 bool on_key_press_event (GdkEventKey*);
90 bool on_key_release_event (GdkEventKey*);
93 boost::shared_ptr<ARDOUR::Crossfade> xfade;
100 ArdourCanvas::Rectangle* box;
101 ArdourCanvas::PolyLine* curve;
105 static const int32_t size;
107 void move_to (double x, double y, double xfract, double yfract);
111 bool operator() (const CrossfadeEditor::Point* a, const CrossfadeEditor::Point *b) {
116 ArdourCanvas::Rectangle* toplevel;
117 ArdourCanvas::GtkCanvas* canvas;
120 ArdourCanvas::PolyLine* line;
121 ArdourCanvas::Polygon* shading;
122 std::list<Point*> points;
123 ARDOUR::AutomationList normative_curve; /* 0 - 1.0, linear */
124 ARDOUR::AutomationList gain_curve; /* 0 - 2.0, gain mapping */
125 std::vector<ArdourWaveView::WaveView*> waves;
139 std::vector<Gtk::Button*> fade_out_buttons;
140 std::vector<Gtk::Button*> fade_in_buttons;
144 Gtk::Button clear_button;
145 Gtk::Button revert_button;
147 Gtk::ToggleButton audition_both_button;
148 Gtk::ToggleButton audition_left_dry_button;
149 Gtk::ToggleButton audition_left_button;
150 Gtk::ToggleButton audition_right_dry_button;
151 Gtk::ToggleButton audition_right_button;
153 Gtk::ToggleButton preroll_button;
154 Gtk::ToggleButton postroll_button;
158 gint event_handler (GdkEvent*);
160 bool canvas_event (GdkEvent* event);
161 bool point_event (GdkEvent* event, Point*);
162 bool curve_event (GdkEvent* event);
164 void canvas_allocation (Gtk::Allocation&);
165 void add_control_point (double x, double y);
166 Point* make_point ();
169 double effective_width () const { return canvas->get_allocation().get_width() - (2.0 * canvas_border); }
170 double effective_height () const { return canvas->get_allocation().get_height() - (2.0 * canvas_border); }
178 Gtk::Table fade_in_table;
179 Gtk::Table fade_out_table;
181 void build_presets ();
182 void apply_preset (Preset*);
184 Gtk::RadioButton select_in_button;
185 Gtk::RadioButton select_out_button;
186 Gtk::HBox curve_button_box;
187 Gtk::HBox audition_box;
189 void curve_select_clicked (WhichFade);
191 double x_coordinate (double& xfract) const;
192 double y_coordinate (double& yfract) const;
194 void set (const ARDOUR::AutomationList& alist, WhichFade);
196 PBD::ScopedConnection* _peaks_ready_connection;
197 PBD::ScopedConnection state_connection;
199 void make_waves (boost::shared_ptr<ARDOUR::AudioRegion>, WhichFade);
200 void peaks_ready (boost::weak_ptr<ARDOUR::AudioRegion> r, WhichFade);
202 void _apply_to (boost::shared_ptr<ARDOUR::Crossfade> xf);
203 void setup (boost::shared_ptr<ARDOUR::Crossfade>);
204 void cancel_audition ();
205 void audition_state_changed (bool);
213 void audition_toggled ();
214 void audition_right_toggled ();
215 void audition_right_dry_toggled ();
216 void audition_left_toggled ();
217 void audition_left_dry_toggled ();
219 void audition (Audition);
220 void audition_both ();
221 void audition_left_dry ();
222 void audition_left ();
223 void audition_right_dry ();
224 void audition_right ();
226 void xfade_changed (const PBD::PropertyChange&);
231 #endif /* __gtk_ardour_xfade_edit_h__ */