2 Copyright (C) 2002 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 __ardour_panner_2d_h__
21 #define __ardour_panner_2d_h__
23 #include <sys/types.h>
27 #include <glibmm/refptr.h>
28 #include <gtkmm/drawingarea.h>
29 #include <gtkmm/window.h>
30 #include <gtkmm/box.h>
31 #include <gtkmm/button.h>
32 #include <gtkmm/spinbutton.h>
33 #include <gtkmm/adjustment.h>
35 #include "pbd/cartesian.h"
37 #include "ardour_window.h"
54 class Panner2d : public Gtk::DrawingArea
57 Panner2d (boost::shared_ptr<ARDOUR::PannerShell>, int32_t height);
60 void allow_target_motion (bool);
62 int add_speaker (const PBD::AngularVector&);
63 int add_signal (const char* text, const PBD::AngularVector&);
64 void move_signal (int which, const PBD::AngularVector&);
65 void reset (uint32_t n_inputs);
67 boost::shared_ptr<ARDOUR::PannerShell> get_panner_shell() const { return panner_shell; }
69 void cart_to_gtk (PBD::CartesianVector&) const;
70 void gtk_to_cart (PBD::CartesianVector&) const;
73 bool on_expose_event (GdkEventExpose *);
74 bool on_button_press_event (GdkEventButton *);
75 bool on_button_release_event (GdkEventButton *);
76 bool on_motion_notify_event (GdkEventMotion *);
77 bool on_scroll_event (GdkEventScroll *);
78 void on_size_allocate (Gtk::Allocation& alloc);
83 PBD::AngularVector position;
87 Target (const PBD::AngularVector&, const char* txt = 0);
90 void set_text (const char*);
91 void set_selected (bool yn) {
94 bool selected() const {
102 boost::shared_ptr<ARDOUR::PannerShell> panner_shell;
103 Glib::RefPtr<Pango::Layout> layout;
105 typedef std::vector<Target*> Targets;
121 Target *find_closest_object (gdouble x, gdouble y, bool& is_signal);
123 gint handle_motion (gint, gint, GdkModifierType);
125 void toggle_bypass ();
126 void handle_state_change ();
127 void handle_position_change ();
128 void label_signals ();
130 PBD::ScopedConnectionList panshell_connections;
131 PBD::ScopedConnectionList panner_connections;
133 /* cartesian coordinates in GTK units ; adjust to same but on a circle of radius 1.0
134 and centered in the middle of our area
136 void clamp_to_circle (double& x, double& y);
137 void sphere_project (double& x, double& y, double& z);
140 class Panner2dWindow : public ArdourWindow
143 Panner2dWindow (boost::shared_ptr<ARDOUR::PannerShell>, int32_t height, uint32_t inputs);
145 void reset (uint32_t n_inputs);
151 Gtk::VBox button_box;
152 Gtk::ToggleButton bypass_button;
153 Gtk::VBox spinner_box;
156 Gtk::Adjustment width_adjustment;
157 Gtk::SpinButton width_spinner;
159 PBD::ScopedConnectionList panshell_connections;
160 PBD::ScopedConnectionList panvalue_connections;
164 void pannable_handler ();
165 void bypass_toggled ();
166 void width_changed ();
167 bool on_key_press_event (GdkEventKey*);
168 bool on_key_release_event (GdkEventKey*);
171 #endif /* __ardour_panner_2d_h__ */