put the issue of using a monitor section into ~/.config/ardour.rc, not the session...
[ardour2.git] / gtk2_ardour / panner2d.h
blob0299558f8f880a064532d5498b7f8a88723f0bca
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 namespace ARDOUR {
36 class Panner;
39 namespace Gtk {
40 class Menu;
41 class CheckMenuItem;
44 namespace Pango {
45 class Layout;
48 class Panner2dWindow;
50 class Panner2d : public Gtk::DrawingArea
52 public:
53 Panner2d (boost::shared_ptr<ARDOUR::Panner>, int32_t height);
54 ~Panner2d ();
56 void allow_x_motion(bool);
57 void allow_y_motion(bool);
58 void allow_target_motion (bool);
60 void hide_puck (int which);
61 void show_puck (int which);
62 int add_target (float x, float y);
63 int add_puck (const char* text, float x, float y);
64 void hide_target (int);
65 void show_target (int);
66 void remove_target (int);
67 void drop_targets ();
68 void drop_pucks ();
69 void move_target (int, float x, float y);
70 void move_puck (int, float x, float y);
71 void reset (uint32_t n_inputs);
73 Gtk::Adjustment& azimuth (uint32_t which);
75 boost::shared_ptr<ARDOUR::Panner> get_panner() const { return panner; }
77 sigc::signal<void,int> PuckMoved;
78 sigc::signal<void,int> TargetMoved;
80 protected:
81 bool on_expose_event (GdkEventExpose *);
82 bool on_button_press_event (GdkEventButton *);
83 bool on_button_release_event (GdkEventButton *);
84 bool on_motion_notify_event (GdkEventMotion *);
85 void on_size_allocate (Gtk::Allocation& alloc);
87 private:
88 struct Target {
89 Gtk::Adjustment x;
90 Gtk::Adjustment y;
91 Gtk::Adjustment azimuth;
92 bool visible;
93 char* text;
95 Target (float xa, float ya, const char* txt = 0);
96 ~Target ();
98 void set_text (const char*);
101 boost::shared_ptr<ARDOUR::Panner> panner;
102 Glib::RefPtr<Pango::Layout> layout;
104 typedef std::map<int,Target *> Targets;
105 Targets targets;
106 Targets pucks;
108 Target *drag_target;
109 int drag_x;
110 int drag_y;
111 int drag_index;
112 bool drag_is_puck;
113 bool allow_x;
114 bool allow_y;
115 bool allow_target;
116 int width;
117 int height;
119 bool bypassflag;
121 gint compute_x (float);
122 gint compute_y (float);
124 Target *find_closest_object (gdouble x, gdouble y, int& which, bool& is_puck) const;
126 gint handle_motion (gint, gint, GdkModifierType);
128 void toggle_bypass ();
129 void handle_state_change ();
130 void handle_position_change ();
132 PBD::ScopedConnection state_connection;
133 PBD::ScopedConnection change_connection;
136 class Panner2dWindow : public Gtk::Window
138 public:
139 Panner2dWindow (boost::shared_ptr<ARDOUR::Panner>, int32_t height, uint32_t inputs);
141 void reset (uint32_t n_inputs);
143 private:
144 Panner2d widget;
146 Gtk::HBox hpacker;
147 Gtk::VBox button_box;
148 Gtk::Button reset_button;
149 Gtk::ToggleButton bypass_button;
150 Gtk::ToggleButton mute_button;
151 Gtk::VBox spinner_box;
152 Gtk::VBox left_side;
154 std::vector<Gtk::SpinButton*> spinners;
157 #endif /* __ardour_panner_2d_h__ */