if STRIP is not set, don't strip included libraries either
[ardour2.git] / gtk2_ardour / panner2d.h
blob4a324e4c8a2c9da0b157a32497842266a89f2982
1 /*
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>
24 #include <map>
25 #include <vector>
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 namespace ARDOUR {
38 class Panner;
41 namespace Gtk {
42 class Menu;
43 class CheckMenuItem;
46 namespace Pango {
47 class Layout;
50 class Panner2dWindow;
52 class Panner2d : public Gtk::DrawingArea
54 public:
55 Panner2d (boost::shared_ptr<ARDOUR::Panner>, int32_t height);
56 ~Panner2d ();
58 void allow_target_motion (bool);
60 int add_target (const PBD::AngularVector&);
61 int add_puck (const char* text, const PBD::AngularVector&);
62 void move_puck (int which, const PBD::AngularVector&);
63 void reset (uint32_t n_inputs);
65 boost::shared_ptr<ARDOUR::Panner> get_panner() const { return panner; }
67 sigc::signal<void,int> PuckMoved;
68 sigc::signal<void,int> TargetMoved;
70 void cart_to_gtk (PBD::CartesianVector&) const;
71 void gtk_to_cart (PBD::CartesianVector&) const;
73 protected:
74 bool on_expose_event (GdkEventExpose *);
75 bool on_button_press_event (GdkEventButton *);
76 bool on_button_release_event (GdkEventButton *);
77 bool on_motion_notify_event (GdkEventMotion *);
78 void on_size_allocate (Gtk::Allocation& alloc);
80 private:
81 class Target {
82 public:
83 PBD::AngularVector position;
84 bool visible;
85 std::string text;
87 Target (const PBD::AngularVector&, const char* txt = 0);
88 ~Target ();
90 void set_text (const char*);
91 void set_selected (bool yn) {
92 _selected = yn;
94 bool selected() const {
95 return _selected;
98 private:
99 bool _selected;
102 boost::shared_ptr<ARDOUR::Panner> panner;
103 Glib::RefPtr<Pango::Layout> layout;
105 typedef std::vector<Target*> Targets;
106 Targets targets;
107 Targets pucks;
109 Target *drag_target;
110 int drag_x;
111 int drag_y;
112 int drag_index;
113 bool allow_target;
114 int width;
115 int height;
117 bool bypassflag;
119 gint compute_x (float);
120 gint compute_y (float);
122 Target *find_closest_object (gdouble x, gdouble y, int& which) const;
124 gint handle_motion (gint, gint, GdkModifierType);
126 void toggle_bypass ();
127 void handle_state_change ();
128 void handle_position_change ();
130 PBD::ScopedConnection state_connection;
131 PBD::ScopedConnection change_connection;
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);
139 class Panner2dWindow : public Gtk::Window
141 public:
142 Panner2dWindow (boost::shared_ptr<ARDOUR::Panner>, int32_t height, uint32_t inputs);
144 void reset (uint32_t n_inputs);
146 private:
147 Panner2d widget;
149 Gtk::HBox hpacker;
150 Gtk::VBox button_box;
151 Gtk::Button reset_button;
152 Gtk::ToggleButton bypass_button;
153 Gtk::ToggleButton mute_button;
154 Gtk::VBox spinner_box;
155 Gtk::VBox left_side;
157 std::vector<Gtk::SpinButton*> spinners;
160 #endif /* __ardour_panner_2d_h__ */