Ardour  9.0-pre0-582-g084a23a80d
panner2d.h
Go to the documentation of this file.
1 /*
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>
7  *
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.
12  *
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.
17  *
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.
21  */
22 
23 #ifndef __ardour_panner_2d_h__
24 #define __ardour_panner_2d_h__
25 
26 #include <sys/types.h>
27 #include <map>
28 #include <vector>
29 
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>
37 
38 #include "pbd/cartesian.h"
39 
40 #include "ardour_window.h"
41 
42 namespace ARDOUR {
43  class PannerShell;
44 }
45 
46 namespace Gtk {
47  class Menu;
48  class CheckMenuItem;
49 }
50 
51 class Panner2dWindow;
52 
53 class Panner2d : public Gtk::DrawingArea
54 {
55  public:
56  Panner2d (std::shared_ptr<ARDOUR::PannerShell>, int32_t height);
58 
59  void allow_target_motion (bool);
60 
62  int add_signal (const char* text, const PBD::AngularVector&);
63  void move_signal (int which, const PBD::AngularVector&);
64  void reset (uint32_t n_inputs);
65  void set_send_drawing_mode (bool);
66 
67  std::shared_ptr<ARDOUR::PannerShell> get_panner_shell() const { return panner_shell; }
68 
71 
72  protected:
79 
80  private:
81  class Target {
82  public:
84  bool visible;
85  std::string text;
86 
87  Target (const PBD::AngularVector&, const char* txt = 0);
88  ~Target ();
89 
90  void set_text (const char*);
91  void set_selected (bool yn) {
92  _selected = yn;
93  }
94  bool selected() const {
95  return _selected;
96  }
97 
98  private:
99  bool _selected;
100  };
101 
102  struct ColorScheme {
103  uint32_t background;
104  uint32_t crosshairs;
106  uint32_t signalcircle;
107  uint32_t diffusion;
108  uint32_t diffusion_inv;
109  uint32_t pos_outline;
110  uint32_t pos_fill;
111  uint32_t signal_outline;
112  uint32_t signal_fill;
113  uint32_t speaker_fill;
114  uint32_t text;
115  uint32_t send_bg;
116  uint32_t send_pan;
117  };
118 
120  static void set_colors ();
121  static bool have_colors;
122  void color_handler ();
123 
124  std::shared_ptr<ARDOUR::PannerShell> panner_shell;
125  Glib::RefPtr<Pango::Layout> layout;
126 
127  typedef std::vector<Target*> Targets;
131 
133  int width;
134  int height;
135  double radius;
136  double border;
137  double hoffset;
138  double voffset;
139  double last_width;
140  bool did_move;
143 
144  Target *find_closest_object (gdouble x, gdouble y, bool& is_signal);
145 
146  gint handle_motion (gint, gint, GdkModifierType);
147 
148  void toggle_bypass ();
151  void label_signals ();
152 
155 
156  /* cartesian coordinates in GTK units ; adjust to same but on a circle of radius 1.0
157  and centered in the middle of our area
158  */
159  void clamp_to_circle (double& x, double& y);
160  void sphere_project (double& x, double& y, double& z);
161 };
162 
164 {
165  public:
166  Panner2dWindow (std::shared_ptr<ARDOUR::PannerShell>, int32_t height, uint32_t inputs);
167 
168  void reset (uint32_t n_inputs);
169 
170  private:
172 
178 
181 
184  void set_bypassed();
185  void set_width();
186 
188  void bypass_toggled ();
189  void width_changed ();
192 };
193 
194 #endif /* __ardour_panner_2d_h__ */
Gtk::Adjustment width_adjustment
Definition: panner2d.h:179
Gtk::VBox spinner_box
Definition: panner2d.h:176
void width_changed()
void bypass_toggled()
Gtk::VBox button_box
Definition: panner2d.h:174
Panner2d widget
Definition: panner2d.h:171
PBD::ScopedConnectionList panshell_connections
Definition: panner2d.h:182
Gtk::SpinButton width_spinner
Definition: panner2d.h:180
bool on_key_release_event(GdkEventKey *)
This is a default handler for the signal signal_key_release_event().
Gtk::ToggleButton bypass_button
Definition: panner2d.h:175
void pannable_handler()
PBD::ScopedConnectionList panvalue_connections
Definition: panner2d.h:183
bool on_key_press_event(GdkEventKey *)
This is a default handler for the signal signal_key_press_event().
Panner2dWindow(std::shared_ptr< ARDOUR::PannerShell >, int32_t height, uint32_t inputs)
void set_bypassed()
Gtk::HBox hpacker
Definition: panner2d.h:173
void reset(uint32_t n_inputs)
Gtk::VBox left_side
Definition: panner2d.h:177
PBD::AngularVector position
Definition: panner2d.h:83
bool selected() const
Definition: panner2d.h:94
Target(const PBD::AngularVector &, const char *txt=0)
std::string text
Definition: panner2d.h:85
void set_selected(bool yn)
Definition: panner2d.h:91
void set_text(const char *)
double last_width
Definition: panner2d.h:139
bool on_expose_event(GdkEventExpose *)
This is a default handler for the signal signal_expose_event().
static ColorScheme colors
Definition: panner2d.h:119
PBD::ScopedConnectionList panshell_connections
Definition: panner2d.h:153
Panner2d(std::shared_ptr< ARDOUR::PannerShell >, int32_t height)
Targets signals
Definition: panner2d.h:129
std::shared_ptr< ARDOUR::PannerShell > panner_shell
Definition: panner2d.h:124
bool on_button_press_event(GdkEventButton *)
This is a default handler for the signal signal_button_press_event().
std::shared_ptr< ARDOUR::PannerShell > get_panner_shell() const
Definition: panner2d.h:67
void toggle_bypass()
void on_size_allocate(Gtk::Allocation &alloc)
This is a default handler for the signal signal_size_allocate().
void cart_to_gtk(PBD::CartesianVector &) const
gint handle_motion(gint, gint, GdkModifierType)
bool _send_mode
Definition: panner2d.h:142
void handle_state_change()
int add_signal(const char *text, const PBD::AngularVector &)
int add_speaker(const PBD::AngularVector &)
static void set_colors()
int height
Definition: panner2d.h:134
bool have_elevation
Definition: panner2d.h:141
int width
Definition: panner2d.h:133
double voffset
Definition: panner2d.h:138
bool on_button_release_event(GdkEventButton *)
This is a default handler for the signal signal_button_release_event().
double border
Definition: panner2d.h:136
bool did_move
Definition: panner2d.h:140
void allow_target_motion(bool)
bool on_scroll_event(GdkEventScroll *)
This is a default handler for the signal signal_scroll_event().
void reset(uint32_t n_inputs)
void label_signals()
Target * find_closest_object(gdouble x, gdouble y, bool &is_signal)
Targets speakers
Definition: panner2d.h:128
void handle_position_change()
void move_signal(int which, const PBD::AngularVector &)
void color_handler()
bool on_motion_notify_event(GdkEventMotion *)
This is a default handler for the signal signal_motion_notify_event().
Glib::RefPtr< Pango::Layout > layout
Definition: panner2d.h:125
double hoffset
Definition: panner2d.h:137
static bool have_colors
Definition: panner2d.h:121
Target position
Definition: panner2d.h:130
double radius
Definition: panner2d.h:135
void gtk_to_cart(PBD::CartesianVector &) const
void set_send_drawing_mode(bool)
PBD::ScopedConnectionList panner_connections
Definition: panner2d.h:154
void sphere_project(double &x, double &y, double &z)
Target * drag_target
Definition: panner2d.h:132
std::vector< Target * > Targets
Definition: panner2d.h:127
void clamp_to_circle(double &x, double &y)
GdkModifierType
Definition: gdktypes.h:127
Definition: ardour_ui.h:188
uint32_t speaker_fill
Definition: panner2d.h:113
uint32_t signal_outline
Definition: panner2d.h:111
uint32_t diffusion_inv
Definition: panner2d.h:108
uint32_t signalcircle
Definition: panner2d.h:106
uint32_t pos_outline
Definition: panner2d.h:109
uint32_t signal_fill
Definition: panner2d.h:112
uint32_t signalcircle_border
Definition: panner2d.h:105
gint height
Definition: xcursors.h:1