remove Id: lines from many/all headers and some more source files
[ardour.git] / gtk2_ardour / panner2d.h
1 /*
2     Copyright (C) 2002 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __ardour_panner_2d_h__
21 #define __ardour_panner_2d_h__
22
23 #include <sys/types.h>
24 #include <map>
25 #include <string>
26
27 #include <glibmm/refptr.h>
28 #include <gtkmm/drawingarea.h>
29
30 using std::map;
31 using std::string;
32
33 namespace ARDOUR {
34         class Panner;
35 }
36
37 namespace Gtk {
38         class Menu;
39         class CheckMenuItem;
40 }
41
42 namespace Pango {
43         class Layout;
44 }
45
46 class Panner2d : public Gtk::DrawingArea
47 {
48   public:
49         Panner2d (ARDOUR::Panner&, int32_t height);
50         ~Panner2d ();
51         
52         int puck_position (int which_puck, float& x, float& y);
53         int target_position (int which_target, float& x, float& y);
54
55         void allow_x_motion(bool);
56         void allow_y_motion(bool);
57         void allow_target_motion (bool);
58
59         void hide_puck (int which);
60         void show_puck (int which);
61         int  add_target (float x, float y);
62         int  add_puck (const char* text, float x, float y);
63         void hide_target (int);
64         void show_target (int);
65         void remove_target (int);
66         void drop_targets ();
67         void drop_pucks ();
68         void move_target (int, float x, float y);
69         void move_puck (int, float x, float y);
70         void reset (uint32_t n_inputs);
71
72         sigc::signal<void,int> PuckMoved;
73         sigc::signal<void,int> TargetMoved;
74
75   protected:
76         bool on_expose_event (GdkEventExpose *);
77         bool on_button_press_event (GdkEventButton *);
78         bool on_button_release_event (GdkEventButton *);
79         bool on_motion_notify_event (GdkEventMotion *);
80         void on_size_allocate (Gtk::Allocation& alloc);
81
82   private:
83         struct Target {
84             float x;
85             float y;
86             bool visible;
87             char* text;
88             size_t textlen;
89
90             Target (float xa, float ya, const char* txt = 0);
91             ~Target ();
92         };
93
94         ARDOUR::Panner& panner;
95         Gtk::Menu* context_menu;
96         Gtk::CheckMenuItem* bypass_menu_item;
97         Glib::RefPtr<Pango::Layout> layout;
98
99         typedef std::map<int,Target *> Targets;
100         Targets targets;
101         Targets pucks;
102
103         Target *drag_target;
104         int     drag_index;
105         bool    drag_is_puck;
106         bool  allow_x;
107         bool  allow_y;
108         bool  allow_target;
109         int width;
110         int height;
111
112         bool bypassflag;
113         
114         gint compute_x (float);
115         gint compute_y (float);
116
117         Target *find_closest_object (gdouble x, gdouble y, int& which, bool& is_puck) const;
118
119         gint handle_motion (gint, gint, GdkModifierType);
120
121         void toggle_bypass ();
122         void show_context_menu ();
123         void handle_state_change ();
124 };
125
126 #endif /* __ardour_panner_2d_h__ */