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 {
50 class CrossfadeEditor : public ArdourDialog
53 CrossfadeEditor (ARDOUR::Session*, boost::shared_ptr<ARDOUR::Crossfade>, double miny, double maxy);
58 static const double canvas_border;
60 /* these are public so that a caller/subclass can make them do the right thing.
63 Gtk::Button* cancel_button;
64 Gtk::Button* ok_button;
70 PresetPoint (double a, double b)
74 struct Preset : public std::list<PresetPoint> {
76 const char* image_name;
78 Preset (const char* n, const char* x) : name (n), image_name (x) {}
81 typedef std::list<Preset*> Presets;
83 static Presets* fade_in_presets;
84 static Presets* fade_out_presets;
87 bool on_key_press_event (GdkEventKey*);
88 bool on_key_release_event (GdkEventKey*);
91 boost::shared_ptr<ARDOUR::Crossfade> xfade;
98 ArdourCanvas::Rectangle* box;
99 ArdourCanvas::PolyLine* curve;
103 static const int32_t size;
105 void move_to (double x, double y, double xfract, double yfract);
109 bool operator() (const CrossfadeEditor::Point* a, const CrossfadeEditor::Point *b) {
114 ArdourCanvas::Rectangle* toplevel;
115 ArdourCanvas::GtkCanvas* canvas;
118 ArdourCanvas::PolyLine* line;
119 ArdourCanvas::Polygon* shading;
120 std::list<Point*> points;
121 ARDOUR::AutomationList normative_curve; /* 0 - 1.0, linear */
122 ARDOUR::AutomationList gain_curve; /* 0 - 2.0, gain mapping */
123 std::vector<ArdourCanvas::WaveView*> waves;
137 std::vector<Gtk::Button*> fade_out_buttons;
138 std::vector<Gtk::Button*> fade_in_buttons;
142 Gtk::Button clear_button;
143 Gtk::Button revert_button;
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;
151 Gtk::ToggleButton preroll_button;
152 Gtk::ToggleButton postroll_button;
156 gint event_handler (GdkEvent*);
158 bool canvas_event (GdkEvent* event);
159 bool point_event (GdkEvent* event, Point*);
160 bool curve_event (GdkEvent* event);
162 void canvas_allocation (Gtk::Allocation&);
163 void add_control_point (double x, double y);
164 Point* make_point ();
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); }
176 Gtk::Table fade_in_table;
177 Gtk::Table fade_out_table;
179 void build_presets ();
180 void apply_preset (Preset*);
182 Gtk::RadioButton select_in_button;
183 Gtk::RadioButton select_out_button;
184 Gtk::HBox curve_button_box;
185 Gtk::HBox audition_box;
187 void curve_select_clicked (WhichFade);
189 double x_coordinate (double& xfract) const;
190 double y_coordinate (double& yfract) const;
192 void set (const ARDOUR::AutomationList& alist, WhichFade);
194 PBD::ScopedConnection* _peaks_ready_connection;
195 PBD::ScopedConnection state_connection;
197 void make_waves (boost::shared_ptr<ARDOUR::AudioRegion>, WhichFade);
198 void peaks_ready (boost::weak_ptr<ARDOUR::AudioRegion> r, WhichFade);
200 void _apply_to (boost::shared_ptr<ARDOUR::Crossfade> xf);
201 void setup (boost::shared_ptr<ARDOUR::Crossfade>);
202 void cancel_audition ();
203 void audition_state_changed (bool);
211 void audition_toggled ();
212 void audition_right_toggled ();
213 void audition_right_dry_toggled ();
214 void audition_left_toggled ();
215 void audition_left_dry_toggled ();
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 ();
224 void xfade_changed (const PBD::PropertyChange&);
229 #endif /* __gtk_ardour_xfade_edit_h__ */