2 * Copyright (C) 2005-2014 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
4 * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
5 * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
6 * Copyright (C) 2014-2015 Robin Gareus <robin@gareus.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef __ardour_panner_2d_h__
24 #define __ardour_panner_2d_h__
26 #include <sys/types.h>
30 #include <glibmm/refptr.h>
31 #include <gtkmm/drawingarea.h>
32 #include <gtkmm/window.h>
33 #include <gtkmm/box.h>
34 #include <gtkmm/button.h>
35 #include <gtkmm/spinbutton.h>
36 #include <gtkmm/adjustment.h>
38 #include "pbd/cartesian.h"
40 #include "ardour_window.h"
57 class Panner2d : public Gtk::DrawingArea
60 Panner2d (boost::shared_ptr<ARDOUR::PannerShell>, int32_t height);
63 void allow_target_motion (bool);
65 int add_speaker (const PBD::AngularVector&);
66 int add_signal (const char* text, const PBD::AngularVector&);
67 void move_signal (int which, const PBD::AngularVector&);
68 void reset (uint32_t n_inputs);
69 void set_send_drawing_mode (bool);
71 boost::shared_ptr<ARDOUR::PannerShell> get_panner_shell() const { return panner_shell; }
73 void cart_to_gtk (PBD::CartesianVector&) const;
74 void gtk_to_cart (PBD::CartesianVector&) const;
77 bool on_expose_event (GdkEventExpose *);
78 bool on_button_press_event (GdkEventButton *);
79 bool on_button_release_event (GdkEventButton *);
80 bool on_motion_notify_event (GdkEventMotion *);
81 bool on_scroll_event (GdkEventScroll *);
82 void on_size_allocate (Gtk::Allocation& alloc);
87 PBD::AngularVector position;
91 Target (const PBD::AngularVector&, const char* txt = 0);
94 void set_text (const char*);
95 void set_selected (bool yn) {
98 bool selected() const {
109 uint32_t signalcircle_border;
110 uint32_t signalcircle;
112 uint32_t diffusion_inv;
113 uint32_t pos_outline;
115 uint32_t signal_outline;
116 uint32_t signal_fill;
117 uint32_t speaker_fill;
121 static ColorScheme colors;
122 static void set_colors ();
123 static bool have_colors;
124 void color_handler ();
126 boost::shared_ptr<ARDOUR::PannerShell> panner_shell;
127 Glib::RefPtr<Pango::Layout> layout;
129 typedef std::vector<Target*> Targets;
146 Target *find_closest_object (gdouble x, gdouble y, bool& is_signal);
148 gint handle_motion (gint, gint, GdkModifierType);
150 void toggle_bypass ();
151 void handle_state_change ();
152 void handle_position_change ();
153 void label_signals ();
155 PBD::ScopedConnectionList panshell_connections;
156 PBD::ScopedConnectionList panner_connections;
158 /* cartesian coordinates in GTK units ; adjust to same but on a circle of radius 1.0
159 and centered in the middle of our area
161 void clamp_to_circle (double& x, double& y);
162 void sphere_project (double& x, double& y, double& z);
165 class Panner2dWindow : public ArdourWindow
168 Panner2dWindow (boost::shared_ptr<ARDOUR::PannerShell>, int32_t height, uint32_t inputs);
170 void reset (uint32_t n_inputs);
176 Gtk::VBox button_box;
177 Gtk::ToggleButton bypass_button;
178 Gtk::VBox spinner_box;
181 Gtk::Adjustment width_adjustment;
182 Gtk::SpinButton width_spinner;
184 PBD::ScopedConnectionList panshell_connections;
185 PBD::ScopedConnectionList panvalue_connections;
189 void pannable_handler ();
190 void bypass_toggled ();
191 void width_changed ();
192 bool on_key_press_event (GdkEventKey*);
193 bool on_key_release_event (GdkEventKey*);
196 #endif /* __ardour_panner_2d_h__ */