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 <ardour/curve.h>
30 #include "ardour_dialog.h"
40 class CrossfadeEditor
: public ArdourDialog
43 CrossfadeEditor (ARDOUR::Session
&, boost::shared_ptr
<ARDOUR::Crossfade
>, double miny
, double maxy
);
48 static const double canvas_border
;
50 /* these are public so that a caller/subclass can make them do the right thing.
53 Gtk::Button
* cancel_button
;
54 Gtk::Button
* ok_button
;
60 PresetPoint (double a
, double b
)
64 struct Preset
: public list
<PresetPoint
> {
66 const char* image_name
;
68 Preset (const char* n
, const char* x
) : name (n
), image_name (x
) {}
71 typedef list
<Preset
*> Presets
;
73 static Presets
* fade_in_presets
;
74 static Presets
* fade_out_presets
;
77 bool on_key_press_event (GdkEventKey
*);
78 bool on_key_release_event (GdkEventKey
*);
81 boost::shared_ptr
<ARDOUR::Crossfade
> xfade
;
82 ARDOUR::Session
& session
;
89 ArdourCanvas::SimpleRect
* box
;
90 ArdourCanvas::Line
* curve
;
94 static const int32_t size
;
96 void move_to (double x
, double y
, double xfract
, double yfract
);
101 bool operator() (const CrossfadeEditor::Point
* a
, const CrossfadeEditor::Point
*b
) {
106 ArdourCanvas::SimpleRect
* toplevel
;
107 ArdourCanvas::Canvas
* canvas
;
110 ArdourCanvas::Line
* line
;
111 ArdourCanvas::Polygon
* shading
;
113 ARDOUR::Curve normative_curve
; /* 0 - 1.0, linear */
114 ARDOUR::Curve gain_curve
; /* 0 - 2.0, gain mapping */
115 vector
<ArdourCanvas::WaveView
*> waves
;
129 vector
<Gtk::Button
*> fade_out_buttons
;
130 vector
<Gtk::Button
*> fade_in_buttons
;
134 Gtk::Button clear_button
;
135 Gtk::Button revert_button
;
137 Gtk::ToggleButton audition_both_button
;
138 Gtk::ToggleButton audition_left_dry_button
;
139 Gtk::ToggleButton audition_left_button
;
140 Gtk::ToggleButton audition_right_dry_button
;
141 Gtk::ToggleButton audition_right_button
;
143 Gtk::ToggleButton preroll_button
;
144 Gtk::ToggleButton postroll_button
;
148 gint
event_handler (GdkEvent
*);
150 bool canvas_event (GdkEvent
* event
);
151 bool point_event (GdkEvent
* event
, Point
*);
152 bool curve_event (GdkEvent
* event
);
154 void canvas_allocation (Gtk::Allocation
&);
155 void add_control_point (double x
, double y
);
156 Point
* make_point ();
159 double effective_width () const { return canvas
->get_allocation().get_width() - (2.0 * canvas_border
); }
160 double effective_height () const { return canvas
->get_allocation().get_height() - (2.0 * canvas_border
); }
168 Gtk::Table fade_in_table
;
169 Gtk::Table fade_out_table
;
171 void build_presets ();
172 void apply_preset (Preset
*);
174 Gtk::RadioButton select_in_button
;
175 Gtk::RadioButton select_out_button
;
176 Gtk::HBox curve_button_box
;
177 Gtk::HBox audition_box
;
179 void curve_select_clicked (WhichFade
);
181 double x_coordinate (double& xfract
) const;
182 double y_coordinate (double& yfract
) const;
184 void set (const ARDOUR::Curve
& alist
, WhichFade
);
186 sigc::connection peaks_ready_connection
;
188 void make_waves (boost::shared_ptr
<ARDOUR::AudioRegion
>, WhichFade
);
189 void peaks_ready (boost::shared_ptr
<ARDOUR::AudioRegion
> r
, WhichFade
);
191 void _apply_to (boost::shared_ptr
<ARDOUR::Crossfade
> xf
);
192 void setup (boost::shared_ptr
<ARDOUR::Crossfade
>);
193 void cancel_audition ();
194 void audition_state_changed (bool);
202 void audition_toggled ();
203 void audition_right_toggled ();
204 void audition_right_dry_toggled ();
205 void audition_left_toggled ();
206 void audition_left_dry_toggled ();
208 void audition (Audition
);
209 void audition_both ();
210 void audition_left_dry ();
211 void audition_left ();
212 void audition_right_dry ();
213 void audition_right ();
215 void xfade_changed (ARDOUR::Change
);
220 #endif /* __gtk_ardour_xfade_edit_h__ */