2 * Copyright (C) 2011-2014 David Robillard <d@drobilla.net>
3 * Copyright (C) 2011-2017 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2011 Carl Hetherington <carl@carlh.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef __ardour_gtk_speaker_dialog_h__
22 #define __ardour_gtk_speaker_dialog_h__
24 #include <gtkmm/drawingarea.h>
25 #include <gtkmm/spinbutton.h>
26 #include <gtkmm/box.h>
27 #include <gtkmm/adjustment.h>
28 #include <gtkmm/aspectframe.h>
30 #include "ardour/speakers.h"
32 #include "ardour_window.h"
34 class SpeakerDialog : public ArdourWindow
39 boost::shared_ptr<ARDOUR::Speakers> get_speakers() const;
40 void set_speakers (boost::shared_ptr<ARDOUR::Speakers>);
43 boost::weak_ptr<ARDOUR::Speakers> _speakers;
46 Gtk::AspectFrame aspect_frame;
47 Gtk::DrawingArea darea;
48 Gtk::Adjustment azimuth_adjustment;
49 Gtk::SpinButton azimuth_spinner;
50 Gtk::Button add_speaker_button;
51 Gtk::Button remove_speaker_button;
52 int width; ///< width of the circle
53 int height; ///< height of the circle
54 int x_origin; ///< x origin of our stuff within the drawing area
55 int y_origin; ///< y origin of our stuff within the drawing area
56 /** distance from the centre of the object being dragged to the mouse pointer
57 * when the drag was started (ie start_pointer - object_position).
62 int selected_index; ///< index of any selected speaker, or -1
63 PBD::ScopedConnection selected_speaker_connection;
64 bool ignore_speaker_position_change;
65 bool ignore_azimuth_change;
67 bool darea_expose_event (GdkEventExpose*);
68 void darea_size_allocate (Gtk::Allocation& alloc);
69 bool darea_motion_notify_event (GdkEventMotion *ev);
70 bool handle_motion (gint evx, gint evy, GdkModifierType state);
71 bool darea_button_press_event (GdkEventButton *ev);
72 bool darea_button_release_event (GdkEventButton *ev);
74 void clamp_to_circle (double& x, double& y);
75 void gtk_to_cart (PBD::CartesianVector& c) const;
76 void cart_to_gtk (PBD::CartesianVector& c) const;
77 int find_closest_object (gdouble x, gdouble y);
80 void remove_speaker ();
81 void azimuth_changed ();
82 void set_selected (int);
83 void speaker_position_changed ();
86 #endif /* __ardour_gtk_speaker_dialog_h__ */