2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2005-2014 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
|
|
|
|
* Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2014-2015 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#ifndef __ardour_panner_2d_h__
|
|
|
|
#define __ardour_panner_2d_h__
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <map>
|
2008-12-13 10:18:32 -05:00
|
|
|
#include <vector>
|
2005-11-28 23:41:15 -05:00
|
|
|
|
|
|
|
#include <glibmm/refptr.h>
|
|
|
|
#include <gtkmm/drawingarea.h>
|
2008-12-13 10:18:32 -05:00
|
|
|
#include <gtkmm/window.h>
|
|
|
|
#include <gtkmm/box.h>
|
|
|
|
#include <gtkmm/button.h>
|
|
|
|
#include <gtkmm/spinbutton.h>
|
|
|
|
#include <gtkmm/adjustment.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-11-26 12:43:03 -05:00
|
|
|
#include "pbd/cartesian.h"
|
|
|
|
|
2011-11-18 19:56:35 -05:00
|
|
|
#include "ardour_window.h"
|
2011-02-17 14:47:53 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
namespace ARDOUR {
|
2011-07-14 18:17:43 -04:00
|
|
|
class PannerShell;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-28 23:41:15 -05:00
|
|
|
namespace Gtk {
|
|
|
|
class Menu;
|
|
|
|
class CheckMenuItem;
|
|
|
|
}
|
|
|
|
|
2008-12-13 10:18:32 -05:00
|
|
|
class Panner2dWindow;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
class Panner2d : public Gtk::DrawingArea
|
|
|
|
{
|
2014-01-14 15:11:41 -05:00
|
|
|
public:
|
2023-02-16 18:33:28 -05:00
|
|
|
Panner2d (std::shared_ptr<ARDOUR::PannerShell>, int32_t height);
|
2005-09-25 14:42:24 -04:00
|
|
|
~Panner2d ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void allow_target_motion (bool);
|
|
|
|
|
2011-03-01 16:52:59 -05:00
|
|
|
int add_speaker (const PBD::AngularVector&);
|
|
|
|
int add_signal (const char* text, const PBD::AngularVector&);
|
|
|
|
void move_signal (int which, const PBD::AngularVector&);
|
2005-09-25 14:42:24 -04:00
|
|
|
void reset (uint32_t n_inputs);
|
2014-06-17 09:51:49 -04:00
|
|
|
void set_send_drawing_mode (bool);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::PannerShell> get_panner_shell() const { return panner_shell; }
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-11-26 14:57:03 -05:00
|
|
|
void cart_to_gtk (PBD::CartesianVector&) const;
|
|
|
|
void gtk_to_cart (PBD::CartesianVector&) const;
|
2010-11-26 12:43:03 -05:00
|
|
|
|
2014-01-14 15:11:41 -05:00
|
|
|
protected:
|
2005-09-25 23:13:13 -04:00
|
|
|
bool on_expose_event (GdkEventExpose *);
|
|
|
|
bool on_button_press_event (GdkEventButton *);
|
|
|
|
bool on_button_release_event (GdkEventButton *);
|
|
|
|
bool on_motion_notify_event (GdkEventMotion *);
|
2011-02-22 16:55:25 -05:00
|
|
|
bool on_scroll_event (GdkEventScroll *);
|
2006-06-20 14:50:38 -04:00
|
|
|
void on_size_allocate (Gtk::Allocation& alloc);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2014-01-14 15:11:41 -05:00
|
|
|
private:
|
2010-11-23 11:38:17 -05:00
|
|
|
class Target {
|
2014-01-14 15:11:41 -05:00
|
|
|
public:
|
2010-11-26 14:57:03 -05:00
|
|
|
PBD::AngularVector position;
|
|
|
|
bool visible;
|
|
|
|
std::string text;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-26 14:57:03 -05:00
|
|
|
Target (const PBD::AngularVector&, const char* txt = 0);
|
|
|
|
~Target ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-26 14:57:03 -05:00
|
|
|
void set_text (const char*);
|
|
|
|
void set_selected (bool yn) {
|
|
|
|
_selected = yn;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
bool selected() const {
|
2010-11-26 14:57:03 -05:00
|
|
|
return _selected;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-01-14 15:11:41 -05:00
|
|
|
private:
|
2010-11-26 14:57:03 -05:00
|
|
|
bool _selected;
|
2005-09-25 14:42:24 -04:00
|
|
|
};
|
|
|
|
|
2015-08-08 11:33:18 -04:00
|
|
|
struct ColorScheme {
|
|
|
|
uint32_t background;
|
|
|
|
uint32_t crosshairs;
|
|
|
|
uint32_t signalcircle_border;
|
|
|
|
uint32_t signalcircle;
|
|
|
|
uint32_t diffusion;
|
|
|
|
uint32_t diffusion_inv;
|
|
|
|
uint32_t pos_outline;
|
|
|
|
uint32_t pos_fill;
|
|
|
|
uint32_t signal_outline;
|
|
|
|
uint32_t signal_fill;
|
|
|
|
uint32_t speaker_fill;
|
|
|
|
uint32_t text;
|
2020-04-23 18:51:29 -04:00
|
|
|
uint32_t send_bg;
|
|
|
|
uint32_t send_pan;
|
2015-08-08 11:33:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static ColorScheme colors;
|
|
|
|
static void set_colors ();
|
|
|
|
static bool have_colors;
|
|
|
|
void color_handler ();
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::PannerShell> panner_shell;
|
2005-11-24 22:36:42 -05:00
|
|
|
Glib::RefPtr<Pango::Layout> layout;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-08-07 19:30:37 -04:00
|
|
|
typedef std::vector<Target*> Targets;
|
2011-03-01 16:52:59 -05:00
|
|
|
Targets speakers;
|
|
|
|
Targets signals;
|
2014-01-14 15:11:41 -05:00
|
|
|
Target position;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
Target *drag_target;
|
2010-11-26 12:43:03 -05:00
|
|
|
int width;
|
|
|
|
int height;
|
2014-01-14 15:11:41 -05:00
|
|
|
double radius;
|
|
|
|
double border;
|
|
|
|
double hoffset;
|
|
|
|
double voffset;
|
|
|
|
double last_width;
|
2011-03-01 16:52:59 -05:00
|
|
|
bool did_move;
|
2014-01-11 21:56:35 -05:00
|
|
|
bool have_elevation;
|
2014-06-17 09:51:49 -04:00
|
|
|
bool _send_mode;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-03-01 16:52:59 -05:00
|
|
|
Target *find_closest_object (gdouble x, gdouble y, bool& is_signal);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
gint handle_motion (gint, gint, GdkModifierType);
|
|
|
|
|
|
|
|
void toggle_bypass ();
|
|
|
|
void handle_state_change ();
|
2008-12-13 10:18:32 -05:00
|
|
|
void handle_position_change ();
|
2014-01-14 15:11:41 -05:00
|
|
|
void label_signals ();
|
2009-12-19 15:26:31 -05:00
|
|
|
|
2014-01-14 17:08:34 -05:00
|
|
|
PBD::ScopedConnectionList panshell_connections;
|
|
|
|
PBD::ScopedConnectionList panner_connections;
|
2010-11-23 11:38:17 -05:00
|
|
|
|
2010-11-26 14:57:03 -05:00
|
|
|
/* cartesian coordinates in GTK units ; adjust to same but on a circle of radius 1.0
|
|
|
|
and centered in the middle of our area
|
|
|
|
*/
|
|
|
|
void clamp_to_circle (double& x, double& y);
|
2014-01-11 17:30:01 -05:00
|
|
|
void sphere_project (double& x, double& y, double& z);
|
2008-12-13 10:18:32 -05:00
|
|
|
};
|
|
|
|
|
2011-11-18 19:56:35 -05:00
|
|
|
class Panner2dWindow : public ArdourWindow
|
2008-12-13 10:18:32 -05:00
|
|
|
{
|
2014-01-14 15:11:41 -05:00
|
|
|
public:
|
2023-02-16 18:33:28 -05:00
|
|
|
Panner2dWindow (std::shared_ptr<ARDOUR::PannerShell>, int32_t height, uint32_t inputs);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-12-13 10:18:32 -05:00
|
|
|
void reset (uint32_t n_inputs);
|
|
|
|
|
2014-01-14 15:11:41 -05:00
|
|
|
private:
|
2008-12-13 10:18:32 -05:00
|
|
|
Panner2d widget;
|
|
|
|
|
2010-11-26 14:57:03 -05:00
|
|
|
Gtk::HBox hpacker;
|
|
|
|
Gtk::VBox button_box;
|
2008-12-13 10:18:32 -05:00
|
|
|
Gtk::ToggleButton bypass_button;
|
2010-11-26 14:57:03 -05:00
|
|
|
Gtk::VBox spinner_box;
|
|
|
|
Gtk::VBox left_side;
|
2008-12-13 10:18:32 -05:00
|
|
|
|
2014-01-11 17:30:13 -05:00
|
|
|
Gtk::Adjustment width_adjustment;
|
|
|
|
Gtk::SpinButton width_spinner;
|
|
|
|
|
2014-01-14 17:08:34 -05:00
|
|
|
PBD::ScopedConnectionList panshell_connections;
|
|
|
|
PBD::ScopedConnectionList panvalue_connections;
|
2014-01-14 15:11:41 -05:00
|
|
|
void set_bypassed();
|
|
|
|
void set_width();
|
2011-02-22 15:49:04 -05:00
|
|
|
|
2014-01-14 17:08:34 -05:00
|
|
|
void pannable_handler ();
|
2014-01-14 15:11:41 -05:00
|
|
|
void bypass_toggled ();
|
|
|
|
void width_changed ();
|
|
|
|
bool on_key_press_event (GdkEventKey*);
|
|
|
|
bool on_key_release_event (GdkEventKey*);
|
2005-09-25 14:42:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __ardour_panner_2d_h__ */
|