X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fcrossfade_edit.h;h=5d9e665ba0f3f0515b3a1fe53af4402c972b97d0;hb=bcee4e151867dab8c54b38efe101f90e34b1b70e;hp=3aae980ce49725bd7a87f43bb0fe5f5d5209af0f;hpb=a7188399cfad64910d4851c1301d40c809f9953c;p=ardour.git diff --git a/gtk2_ardour/crossfade_edit.h b/gtk2_ardour/crossfade_edit.h index 3aae980ce4..5d9e665ba0 100644 --- a/gtk2_ardour/crossfade_edit.h +++ b/gtk2_ardour/crossfade_edit.h @@ -1,3 +1,22 @@ +/* + Copyright (C) 2000-2007 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + #ifndef __gtk_ardour_xfade_edit_h__ #define __gtk_ardour_xfade_edit_h__ @@ -7,184 +26,204 @@ #include #include -#include +#include "canvas/canvas.h" + +#include "evoral/Curve.hpp" +#include "ardour/session_handle.h" + #include "ardour_dialog.h" -#include "canvas.h" namespace ARDOUR { class Session; - class Curve; + class AutomationList; class Crossfade; } +namespace ArdourCanvas { + class Rectangle; + class Line; + class Polygon; + class WaveView; +} + class CrossfadeEditor : public ArdourDialog { public: - CrossfadeEditor (ARDOUR::Session&, ARDOUR::Crossfade&, double miny, double maxy); - ~CrossfadeEditor (); - - void apply (); - - static const double canvas_border; - - /* these are public so that a caller/subclass can make them do the right thing. - */ - - Gtk::Button* cancel_button; - Gtk::Button* ok_button; - - struct PresetPoint { - double x; - double y; - - PresetPoint (double a, double b) - : x (a), y (b) {} - }; - - struct Preset : public list { - const gchar** xpm; - - Preset (const gchar** x) - : xpm (x) {} - }; - - typedef list Presets; - - static Presets* fade_in_presets; - static Presets* fade_out_presets; + CrossfadeEditor (ARDOUR::Session*, boost::shared_ptr, double miny, double maxy); + ~CrossfadeEditor (); + + void apply (); + + static const double canvas_border; + + /* these are public so that a caller/subclass can make them do the right thing. + */ + + Gtk::Button* cancel_button; + Gtk::Button* ok_button; + + struct PresetPoint { + double x; + double y; + + PresetPoint (double a, double b) + : x (a), y (b) {} + }; + + struct Preset : public std::list { + const char* name; + const char* image_name; + + Preset (const char* n, const char* x) : name (n), image_name (x) {} + }; + + typedef std::list Presets; + + static Presets* fade_in_presets; + static Presets* fade_out_presets; + + protected: + bool on_key_press_event (GdkEventKey*); + bool on_key_release_event (GdkEventKey*); private: - ARDOUR::Crossfade& xfade; - ARDOUR::Session& session; + boost::shared_ptr xfade; + + Gtk::VBox vpacker; + + struct Point { + ~Point(); + + ArdourCanvas::Rectangle* box; + ArdourCanvas::PolyLine* curve; + double x; + double y; + + static const int32_t size; + + void move_to (double x, double y, double xfract, double yfract); + }; + + struct PointSorter { + bool operator() (const CrossfadeEditor::Point* a, const CrossfadeEditor::Point *b) { + return a->x < b->x; + } + }; + + ArdourCanvas::Rectangle* toplevel; + ArdourCanvas::GtkCanvas* canvas; + + struct Half { + ArdourCanvas::PolyLine* line; + ArdourCanvas::Polygon* shading; + std::list points; + ARDOUR::AutomationList normative_curve; /* 0 - 1.0, linear */ + ARDOUR::AutomationList gain_curve; /* 0 - 2.0, gain mapping */ + std::vector waves; + + Half(); + }; + + enum WhichFade { + In = 0, + Out = 1 + }; + + Half fade[2]; + WhichFade current; + + bool point_grabbed; + std::vector fade_out_buttons; + std::vector fade_in_buttons; - Gtk::VBox vpacker; + Gtk::VBox vpacker2; - struct Point { - ~Point(); + Gtk::Button clear_button; + Gtk::Button revert_button; - ArdourCanvas::SimpleRect* box; - ArdourCanvas::Line* curve; - double x; - double y; + Gtk::ToggleButton audition_both_button; + Gtk::ToggleButton audition_left_dry_button; + Gtk::ToggleButton audition_left_button; + Gtk::ToggleButton audition_right_dry_button; + Gtk::ToggleButton audition_right_button; - static const int32_t size; + Gtk::ToggleButton preroll_button; + Gtk::ToggleButton postroll_button; - void move_to (double x, double y, double xfract, double yfract); - }; + Gtk::HBox roll_box; - struct PointSorter - { - bool operator() (const CrossfadeEditor::Point* a, const CrossfadeEditor::Point *b) { - return a->x < b->x; - } - }; - - ArdourCanvas::SimpleRect* toplevel; - ArdourCanvas::Canvas* canvas; - - struct Half { - ArdourCanvas::Line* line; - ArdourCanvas::Polygon* shading; - list points; - ARDOUR::Curve normative_curve; /* 0 - 1.0, linear */ - ARDOUR::Curve gain_curve; /* 0 - 2.0, gain mapping */ - vector waves; + gint event_handler (GdkEvent*); - Half(); - }; + bool canvas_event (GdkEvent* event); + bool point_event (GdkEvent* event, Point*); + bool curve_event (GdkEvent* event); - enum WhichFade { - In = 0, - Out = 1 - }; + void canvas_allocation (Gtk::Allocation&); + void add_control_point (double x, double y); + Point* make_point (); + void redraw (); - Half fade[2]; - WhichFade current; + double effective_width () const { return canvas->get_allocation().get_width() - (2.0 * canvas_border); } + double effective_height () const { return canvas->get_allocation().get_height() - (2.0 * canvas_border); } - bool point_grabbed; - vector fade_out_buttons; - vector fade_in_buttons; + void clear (); + void reset (); - //Gtk::HBox action_box; + double miny; + double maxy; - Gtk::VBox vpacker2; + Gtk::Table fade_in_table; + Gtk::Table fade_out_table; - Gtk::Button clear_button; - Gtk::Button revert_button; + void build_presets (); + void apply_preset (Preset*); - Gtk::ToggleButton audition_both_button; - Gtk::ToggleButton audition_left_dry_button; - Gtk::ToggleButton audition_left_button; - Gtk::ToggleButton audition_right_dry_button; - Gtk::ToggleButton audition_right_button; + Gtk::RadioButton select_in_button; + Gtk::RadioButton select_out_button; + Gtk::HBox curve_button_box; + Gtk::HBox audition_box; - Gtk::ToggleButton preroll_button; - Gtk::ToggleButton postroll_button; + void curve_select_clicked (WhichFade); - Gtk::HBox roll_box; + double x_coordinate (double& xfract) const; + double y_coordinate (double& yfract) const; - gint event_handler (GdkEvent*); + void set (const ARDOUR::AutomationList& alist, WhichFade); - bool canvas_event (GdkEvent* event); - bool point_event (GdkEvent* event, Point*); - bool curve_event (GdkEvent* event); + PBD::ScopedConnection* _peaks_ready_connection; + PBD::ScopedConnection state_connection; - void canvas_allocation (Gtk::Allocation&); - void add_control_point (double x, double y); - Point* make_point (); - void redraw (); - - double effective_width () const { return canvas->get_allocation().get_width() - (2.0 * canvas_border); } - double effective_height () const { return canvas->get_allocation().get_height() - (2.0 * canvas_border); } + void make_waves (boost::shared_ptr, WhichFade); + void peaks_ready (boost::weak_ptr r, WhichFade); - void clear (); - void reset (); + void _apply_to (boost::shared_ptr xf); + void setup (boost::shared_ptr); + void cancel_audition (); + void audition_state_changed (bool); - double miny; - double maxy; + enum Audition { + Both, + Left, + Right + }; - Gtk::Table fade_in_table; - Gtk::Table fade_out_table; + void audition_toggled (); + void audition_right_toggled (); + void audition_right_dry_toggled (); + void audition_left_toggled (); + void audition_left_dry_toggled (); - void build_presets (); - void apply_preset (Preset*); - - Gtk::RadioButton select_in_button; - Gtk::RadioButton select_out_button; - Gtk::HBox curve_button_box; - Gtk::HBox audition_box; + void audition (Audition); + void audition_both (); + void audition_left_dry (); + void audition_left (); + void audition_right_dry (); + void audition_right (); - void curve_select_clicked (WhichFade); + void xfade_changed (const PBD::PropertyChange&); - double x_coordinate (double& xfract) const; - double y_coordinate (double& yfract) const; - - void set (const ARDOUR::Curve& alist, WhichFade); - - void make_waves (ARDOUR::AudioRegion&, WhichFade); - void peaks_ready (ARDOUR::AudioRegion* r, WhichFade); - - void _apply_to (ARDOUR::Crossfade* xf); - void setup (ARDOUR::Crossfade*); - void cancel_audition (); - void audition_state_changed (bool); - - void audition_toggled (); - void audition_right_toggled (); - void audition_right_dry_toggled (); - void audition_left_toggled (); - void audition_left_dry_toggled (); - - void audition_both (); - void audition_left_dry (); - void audition_left (); - void audition_right_dry (); - void audition_right (); - - void xfade_changed (ARDOUR::Change); - - void dump (); + void dump (); }; #endif /* __gtk_ardour_xfade_edit_h__ */