2005-09-25 18:42:24 +00:00
|
|
|
/*
|
2019-08-02 23:26:43 +02: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 18:42:24 +00:00
|
|
|
|
|
|
|
|
#ifndef __ardour_panner_2d_h__
|
|
|
|
|
#define __ardour_panner_2d_h__
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <map>
|
2008-12-13 15:18:32 +00:00
|
|
|
#include <vector>
|
2005-11-29 04:41:15 +00:00
|
|
|
|
|
|
|
|
#include <glibmm/refptr.h>
|
2025-02-01 15:15:02 +01:00
|
|
|
#include <ytkmm/drawingarea.h>
|
|
|
|
|
#include <ytkmm/window.h>
|
|
|
|
|
#include <ytkmm/box.h>
|
|
|
|
|
#include <ytkmm/button.h>
|
|
|
|
|
#include <ytkmm/spinbutton.h>
|
|
|
|
|
#include <ytkmm/adjustment.h>
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2010-11-26 17:43:03 +00:00
|
|
|
#include "pbd/cartesian.h"
|
|
|
|
|
|
2011-11-19 00:56:35 +00:00
|
|
|
#include "ardour_window.h"
|
2011-02-17 19:47:53 +00:00
|
|
|
|
2005-09-25 18:42:24 +00:00
|
|
|
namespace ARDOUR {
|
2011-07-14 22:17:43 +00:00
|
|
|
class PannerShell;
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
2005-11-29 04:41:15 +00:00
|
|
|
namespace Gtk {
|
|
|
|
|
class Menu;
|
|
|
|
|
class CheckMenuItem;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-13 15:18:32 +00:00
|
|
|
class Panner2dWindow;
|
|
|
|
|
|
2005-09-25 18:42:24 +00:00
|
|
|
class Panner2d : public Gtk::DrawingArea
|
|
|
|
|
{
|
2014-01-14 21:11:41 +01:00
|
|
|
public:
|
2023-02-16 16:33:28 -07:00
|
|
|
Panner2d (std::shared_ptr<ARDOUR::PannerShell>, int32_t height);
|
2005-09-25 18:42:24 +00:00
|
|
|
~Panner2d ();
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2005-09-25 18:42:24 +00:00
|
|
|
void allow_target_motion (bool);
|
|
|
|
|
|
2011-03-01 21:52:59 +00: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 18:42:24 +00:00
|
|
|
void reset (uint32_t n_inputs);
|
2014-06-17 15:51:49 +02:00
|
|
|
void set_send_drawing_mode (bool);
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2023-02-16 16:33:28 -07:00
|
|
|
std::shared_ptr<ARDOUR::PannerShell> get_panner_shell() const { return panner_shell; }
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2010-11-26 19:57:03 +00:00
|
|
|
void cart_to_gtk (PBD::CartesianVector&) const;
|
|
|
|
|
void gtk_to_cart (PBD::CartesianVector&) const;
|
2010-11-26 17:43:03 +00:00
|
|
|
|
2014-01-14 21:11:41 +01:00
|
|
|
protected:
|
2005-09-26 03:13:13 +00: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 21:55:25 +00:00
|
|
|
bool on_scroll_event (GdkEventScroll *);
|
2006-06-20 18:50:38 +00:00
|
|
|
void on_size_allocate (Gtk::Allocation& alloc);
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2014-01-14 21:11:41 +01:00
|
|
|
private:
|
2010-11-23 16:38:17 +00:00
|
|
|
class Target {
|
2014-01-14 21:11:41 +01:00
|
|
|
public:
|
2010-11-26 19:57:03 +00:00
|
|
|
PBD::AngularVector position;
|
|
|
|
|
bool visible;
|
|
|
|
|
std::string text;
|
2011-06-01 17:00:29 +00:00
|
|
|
|
2010-11-26 19:57:03 +00:00
|
|
|
Target (const PBD::AngularVector&, const char* txt = 0);
|
|
|
|
|
~Target ();
|
2011-06-01 17:00:29 +00:00
|
|
|
|
2010-11-26 19:57:03 +00:00
|
|
|
void set_text (const char*);
|
|
|
|
|
void set_selected (bool yn) {
|
|
|
|
|
_selected = yn;
|
|
|
|
|
}
|
2011-06-01 17:00:29 +00:00
|
|
|
bool selected() const {
|
2010-11-26 19:57:03 +00:00
|
|
|
return _selected;
|
|
|
|
|
}
|
2011-06-01 17:00:29 +00:00
|
|
|
|
2014-01-14 21:11:41 +01:00
|
|
|
private:
|
2010-11-26 19:57:03 +00:00
|
|
|
bool _selected;
|
2005-09-25 18:42:24 +00:00
|
|
|
};
|
|
|
|
|
|
2015-08-08 17:33:18 +02: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-24 00:51:29 +02:00
|
|
|
uint32_t send_bg;
|
|
|
|
|
uint32_t send_pan;
|
2015-08-08 17:33:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static ColorScheme colors;
|
|
|
|
|
static void set_colors ();
|
|
|
|
|
static bool have_colors;
|
|
|
|
|
void color_handler ();
|
|
|
|
|
|
2023-02-16 16:33:28 -07:00
|
|
|
std::shared_ptr<ARDOUR::PannerShell> panner_shell;
|
2005-11-25 03:36:42 +00:00
|
|
|
Glib::RefPtr<Pango::Layout> layout;
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2010-08-07 23:30:37 +00:00
|
|
|
typedef std::vector<Target*> Targets;
|
2011-03-01 21:52:59 +00:00
|
|
|
Targets speakers;
|
|
|
|
|
Targets signals;
|
2014-01-14 21:11:41 +01:00
|
|
|
Target position;
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
Target *drag_target;
|
2010-11-26 17:43:03 +00:00
|
|
|
int width;
|
|
|
|
|
int height;
|
2014-01-14 21:11:41 +01:00
|
|
|
double radius;
|
|
|
|
|
double border;
|
|
|
|
|
double hoffset;
|
|
|
|
|
double voffset;
|
|
|
|
|
double last_width;
|
2011-03-01 21:52:59 +00:00
|
|
|
bool did_move;
|
2014-01-12 03:56:35 +01:00
|
|
|
bool have_elevation;
|
2014-06-17 15:51:49 +02:00
|
|
|
bool _send_mode;
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2011-03-01 21:52:59 +00:00
|
|
|
Target *find_closest_object (gdouble x, gdouble y, bool& is_signal);
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
gint handle_motion (gint, gint, GdkModifierType);
|
|
|
|
|
|
|
|
|
|
void toggle_bypass ();
|
|
|
|
|
void handle_state_change ();
|
2008-12-13 15:18:32 +00:00
|
|
|
void handle_position_change ();
|
2014-01-14 21:11:41 +01:00
|
|
|
void label_signals ();
|
2009-12-19 20:26:31 +00:00
|
|
|
|
2014-01-14 23:08:34 +01:00
|
|
|
PBD::ScopedConnectionList panshell_connections;
|
|
|
|
|
PBD::ScopedConnectionList panner_connections;
|
2010-11-23 16:38:17 +00:00
|
|
|
|
2010-11-26 19:57:03 +00: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 23:30:01 +01:00
|
|
|
void sphere_project (double& x, double& y, double& z);
|
2008-12-13 15:18:32 +00:00
|
|
|
};
|
|
|
|
|
|
2011-11-19 00:56:35 +00:00
|
|
|
class Panner2dWindow : public ArdourWindow
|
2008-12-13 15:18:32 +00:00
|
|
|
{
|
2014-01-14 21:11:41 +01:00
|
|
|
public:
|
2023-02-16 16:33:28 -07:00
|
|
|
Panner2dWindow (std::shared_ptr<ARDOUR::PannerShell>, int32_t height, uint32_t inputs);
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-12-13 15:18:32 +00:00
|
|
|
void reset (uint32_t n_inputs);
|
|
|
|
|
|
2014-01-14 21:11:41 +01:00
|
|
|
private:
|
2008-12-13 15:18:32 +00:00
|
|
|
Panner2d widget;
|
|
|
|
|
|
2010-11-26 19:57:03 +00:00
|
|
|
Gtk::HBox hpacker;
|
|
|
|
|
Gtk::VBox button_box;
|
2008-12-13 15:18:32 +00:00
|
|
|
Gtk::ToggleButton bypass_button;
|
2010-11-26 19:57:03 +00:00
|
|
|
Gtk::VBox spinner_box;
|
|
|
|
|
Gtk::VBox left_side;
|
2008-12-13 15:18:32 +00:00
|
|
|
|
2014-01-11 23:30:13 +01:00
|
|
|
Gtk::Adjustment width_adjustment;
|
|
|
|
|
Gtk::SpinButton width_spinner;
|
|
|
|
|
|
2014-01-14 23:08:34 +01:00
|
|
|
PBD::ScopedConnectionList panshell_connections;
|
|
|
|
|
PBD::ScopedConnectionList panvalue_connections;
|
2014-01-14 21:11:41 +01:00
|
|
|
void set_bypassed();
|
|
|
|
|
void set_width();
|
2011-02-22 20:49:04 +00:00
|
|
|
|
2014-01-14 23:08:34 +01:00
|
|
|
void pannable_handler ();
|
2014-01-14 21:11:41 +01:00
|
|
|
void bypass_toggled ();
|
|
|
|
|
void width_changed ();
|
|
|
|
|
bool on_key_press_event (GdkEventKey*);
|
|
|
|
|
bool on_key_release_event (GdkEventKey*);
|
2005-09-25 18:42:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* __ardour_panner_2d_h__ */
|