mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Move some bits from MonoPanner and StereoPanner into a
common base class. git-svn-id: svn://localhost/ardour2/branches/3.0@11071 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
0dbc0429a8
commit
6e79521e8b
7 changed files with 187 additions and 168 deletions
|
|
@ -57,15 +57,13 @@ MonoPanner::ColorScheme MonoPanner::colors;
|
|||
bool MonoPanner::have_colors = false;
|
||||
|
||||
MonoPanner::MonoPanner (boost::shared_ptr<ARDOUR::Panner> panner)
|
||||
: _panner (panner)
|
||||
: PannerInterface (panner)
|
||||
, position_control (_panner->pannable()->pan_azimuth_control)
|
||||
, dragging (false)
|
||||
, drag_start_x (0)
|
||||
, last_drag_x (0)
|
||||
, accumulated_delta (0)
|
||||
, detented (false)
|
||||
, drag_data_window (0)
|
||||
, drag_data_label (0)
|
||||
, position_binder (position_control)
|
||||
{
|
||||
if (!have_colors) {
|
||||
|
|
@ -75,26 +73,18 @@ MonoPanner::MonoPanner (boost::shared_ptr<ARDOUR::Panner> panner)
|
|||
|
||||
position_control->Changed.connect (connections, invalidator(*this), boost::bind (&MonoPanner::value_change, this), gui_context());
|
||||
|
||||
set_flags (Gtk::CAN_FOCUS);
|
||||
|
||||
add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|
|
||||
Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|
|
||||
Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|
|
||||
Gdk::SCROLL_MASK|
|
||||
Gdk::POINTER_MOTION_MASK);
|
||||
|
||||
ColorsChanged.connect (sigc::mem_fun (*this, &MonoPanner::color_handler));
|
||||
}
|
||||
|
||||
MonoPanner::~MonoPanner ()
|
||||
{
|
||||
delete drag_data_window;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MonoPanner::set_drag_data ()
|
||||
{
|
||||
if (!drag_data_label) {
|
||||
if (!_drag_data_label) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -112,14 +102,7 @@ MonoPanner::set_drag_data ()
|
|||
snprintf (buf, sizeof (buf), "L:%3d R:%3d",
|
||||
(int) rint (100.0 * (1.0 - pos)),
|
||||
(int) rint (100.0 * pos));
|
||||
drag_data_label->set_markup (buf);
|
||||
}
|
||||
|
||||
void
|
||||
MonoPanner::value_change ()
|
||||
{
|
||||
set_drag_data ();
|
||||
queue_draw ();
|
||||
_drag_data_label->set_markup (buf);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -330,8 +313,8 @@ MonoPanner::on_button_release_event (GdkEventButton* ev)
|
|||
accumulated_delta = 0;
|
||||
detented = false;
|
||||
|
||||
if (drag_data_window) {
|
||||
drag_data_window->hide ();
|
||||
if (_drag_data_window) {
|
||||
_drag_data_window->hide ();
|
||||
}
|
||||
|
||||
if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
|
||||
|
|
@ -379,32 +362,7 @@ MonoPanner::on_motion_notify_event (GdkEventMotion* ev)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!drag_data_window) {
|
||||
drag_data_window = new Window (WINDOW_POPUP);
|
||||
drag_data_window->set_name (X_("ContrastingPopup"));
|
||||
drag_data_window->set_position (WIN_POS_MOUSE);
|
||||
drag_data_window->set_decorated (false);
|
||||
|
||||
drag_data_label = manage (new Label);
|
||||
drag_data_label->set_use_markup (true);
|
||||
|
||||
drag_data_window->set_border_width (6);
|
||||
drag_data_window->add (*drag_data_label);
|
||||
drag_data_label->show ();
|
||||
|
||||
Window* toplevel = dynamic_cast<Window*> (get_toplevel());
|
||||
if (toplevel) {
|
||||
drag_data_window->set_transient_for (*toplevel);
|
||||
}
|
||||
}
|
||||
|
||||
if (!drag_data_window->is_visible ()) {
|
||||
/* move the window a little away from the mouse */
|
||||
int rx, ry;
|
||||
get_window()->get_origin (rx, ry);
|
||||
drag_data_window->move (rx, ry+get_height());
|
||||
drag_data_window->present ();
|
||||
}
|
||||
show_drag_data_window ();
|
||||
|
||||
int w = get_width();
|
||||
double delta = (ev->x - last_drag_x) / (double) w;
|
||||
|
|
@ -469,27 +427,6 @@ MonoPanner::on_key_press_event (GdkEventKey* ev)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
MonoPanner::on_key_release_event (GdkEventKey*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
MonoPanner::on_enter_notify_event (GdkEventCrossing*)
|
||||
{
|
||||
grab_focus ();
|
||||
Keyboard::magic_widget_grab_focus ();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
MonoPanner::on_leave_notify_event (GdkEventCrossing*)
|
||||
{
|
||||
Keyboard::magic_widget_drop_focus ();
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
MonoPanner::set_colors ()
|
||||
{
|
||||
|
|
@ -507,3 +444,4 @@ MonoPanner::color_handler ()
|
|||
set_colors ();
|
||||
queue_draw ();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,16 +22,17 @@
|
|||
|
||||
#include "pbd/signals.h"
|
||||
|
||||
#include <gtkmm/drawingarea.h>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "gtkmm2ext/binding_proxy.h"
|
||||
|
||||
#include "panner_interface.h"
|
||||
|
||||
namespace PBD {
|
||||
class Controllable;
|
||||
}
|
||||
|
||||
class MonoPanner : public Gtk::DrawingArea
|
||||
class MonoPanner : public PannerInterface
|
||||
{
|
||||
public:
|
||||
MonoPanner (boost::shared_ptr<ARDOUR::Panner>);
|
||||
|
|
@ -49,12 +50,8 @@ class MonoPanner : public Gtk::DrawingArea
|
|||
bool on_motion_notify_event (GdkEventMotion*);
|
||||
bool on_scroll_event (GdkEventScroll*);
|
||||
bool on_key_press_event (GdkEventKey*);
|
||||
bool on_key_release_event (GdkEventKey*);
|
||||
bool on_enter_notify_event (GdkEventCrossing* ev);
|
||||
bool on_leave_notify_event (GdkEventCrossing* ev);
|
||||
|
||||
private:
|
||||
boost::shared_ptr<ARDOUR::Panner> _panner;
|
||||
boost::shared_ptr<PBD::Controllable> position_control;
|
||||
PBD::ScopedConnectionList connections;
|
||||
bool dragging;
|
||||
|
|
@ -63,12 +60,8 @@ class MonoPanner : public Gtk::DrawingArea
|
|||
double accumulated_delta;
|
||||
bool detented;
|
||||
|
||||
Gtk::Window* drag_data_window;
|
||||
Gtk::Label* drag_data_label;
|
||||
|
||||
BindingProxy position_binder;
|
||||
|
||||
void value_change ();
|
||||
void set_drag_data ();
|
||||
|
||||
struct ColorScheme {
|
||||
|
|
|
|||
109
gtk2_ardour/panner_interface.cc
Normal file
109
gtk2_ardour/panner_interface.cc
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Copyright (C) 2011 Paul Davis
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include "gtkmm2ext/keyboard.h"
|
||||
#include "panner_interface.h"
|
||||
#include "global_signals.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace Gtk;
|
||||
using namespace ARDOUR;
|
||||
using namespace Gtkmm2ext;
|
||||
|
||||
PannerInterface::PannerInterface (boost::shared_ptr<Panner> p)
|
||||
: _panner (p)
|
||||
, _drag_data_window (0)
|
||||
, _drag_data_label (0)
|
||||
{
|
||||
set_flags (Gtk::CAN_FOCUS);
|
||||
|
||||
add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|
|
||||
Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|
|
||||
Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|
|
||||
Gdk::SCROLL_MASK|
|
||||
Gdk::POINTER_MOTION_MASK);
|
||||
|
||||
}
|
||||
|
||||
PannerInterface::~PannerInterface ()
|
||||
{
|
||||
delete _drag_data_window;
|
||||
}
|
||||
|
||||
void
|
||||
PannerInterface::show_drag_data_window ()
|
||||
{
|
||||
if (!_drag_data_window) {
|
||||
_drag_data_window = new Window (WINDOW_POPUP);
|
||||
_drag_data_window->set_name (X_("ContrastingPopup"));
|
||||
_drag_data_window->set_position (WIN_POS_MOUSE);
|
||||
_drag_data_window->set_decorated (false);
|
||||
|
||||
_drag_data_label = manage (new Label);
|
||||
_drag_data_label->set_use_markup (true);
|
||||
|
||||
_drag_data_window->set_border_width (6);
|
||||
_drag_data_window->add (*_drag_data_label);
|
||||
_drag_data_label->show ();
|
||||
|
||||
Window* toplevel = dynamic_cast<Window*> (get_toplevel());
|
||||
if (toplevel) {
|
||||
_drag_data_window->set_transient_for (*toplevel);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_drag_data_window->is_visible ()) {
|
||||
/* move the window a little away from the mouse */
|
||||
int rx, ry;
|
||||
get_window()->get_origin (rx, ry);
|
||||
_drag_data_window->move (rx, ry + get_height());
|
||||
_drag_data_window->present ();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
PannerInterface::on_enter_notify_event (GdkEventCrossing *)
|
||||
{
|
||||
grab_focus ();
|
||||
Keyboard::magic_widget_grab_focus ();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
PannerInterface::on_leave_notify_event (GdkEventCrossing *)
|
||||
{
|
||||
Keyboard::magic_widget_drop_focus ();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
PannerInterface::on_key_release_event (GdkEventKey*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
PannerInterface::value_change ()
|
||||
{
|
||||
set_drag_data ();
|
||||
queue_draw ();
|
||||
}
|
||||
|
||||
52
gtk2_ardour/panner_interface.h
Normal file
52
gtk2_ardour/panner_interface.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
Copyright (C) 2011 Paul Davis
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __gtk_ardour_panner_interface_h__
|
||||
#define __gtk_ardour_panner_interface_h__
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <gtkmm/drawingarea.h>
|
||||
#include <gtkmm/label.h>
|
||||
|
||||
namespace ARDOUR {
|
||||
class Panner;
|
||||
}
|
||||
|
||||
/** Parent class for some panner UI classes that contains some common code */
|
||||
class PannerInterface : public Gtk::DrawingArea
|
||||
{
|
||||
public:
|
||||
PannerInterface (boost::shared_ptr<ARDOUR::Panner>);
|
||||
virtual ~PannerInterface ();
|
||||
|
||||
protected:
|
||||
virtual void set_drag_data () = 0;
|
||||
|
||||
void show_drag_data_window ();
|
||||
void value_change ();
|
||||
bool on_enter_notify_event (GdkEventCrossing *);
|
||||
bool on_leave_notify_event (GdkEventCrossing *);
|
||||
bool on_key_release_event (GdkEventKey *);
|
||||
|
||||
boost::shared_ptr<ARDOUR::Panner> _panner;
|
||||
Gtk::Window* _drag_data_window;
|
||||
Gtk::Label* _drag_data_label;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -57,7 +57,7 @@ bool StereoPanner::have_colors = false;
|
|||
using namespace ARDOUR;
|
||||
|
||||
StereoPanner::StereoPanner (boost::shared_ptr<Panner> panner)
|
||||
: _panner (panner)
|
||||
: PannerInterface (panner)
|
||||
, position_control (_panner->pannable()->pan_azimuth_control)
|
||||
, width_control (_panner->pannable()->pan_width_control)
|
||||
, dragging (false)
|
||||
|
|
@ -68,8 +68,6 @@ StereoPanner::StereoPanner (boost::shared_ptr<Panner> panner)
|
|||
, last_drag_x (0)
|
||||
, accumulated_delta (0)
|
||||
, detented (false)
|
||||
, drag_data_window (0)
|
||||
, drag_data_label (0)
|
||||
, position_binder (position_control)
|
||||
, width_binder (width_control)
|
||||
{
|
||||
|
|
@ -81,26 +79,18 @@ StereoPanner::StereoPanner (boost::shared_ptr<Panner> panner)
|
|||
position_control->Changed.connect (connections, invalidator(*this), boost::bind (&StereoPanner::value_change, this), gui_context());
|
||||
width_control->Changed.connect (connections, invalidator(*this), boost::bind (&StereoPanner::value_change, this), gui_context());
|
||||
|
||||
set_flags (Gtk::CAN_FOCUS);
|
||||
|
||||
add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|
|
||||
Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|
|
||||
Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|
|
||||
Gdk::SCROLL_MASK|
|
||||
Gdk::POINTER_MOTION_MASK);
|
||||
|
||||
ColorsChanged.connect (sigc::mem_fun (*this, &StereoPanner::color_handler));
|
||||
}
|
||||
|
||||
StereoPanner::~StereoPanner ()
|
||||
{
|
||||
delete drag_data_window;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
StereoPanner::set_drag_data ()
|
||||
{
|
||||
if (!drag_data_label) {
|
||||
if (!_drag_data_label) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -118,14 +108,7 @@ StereoPanner::set_drag_data ()
|
|||
snprintf (buf, sizeof (buf), "L:%3d R:%3d Width:%d%%", (int) rint (100.0 * (1.0 - pos)),
|
||||
(int) rint (100.0 * pos),
|
||||
(int) floor (100.0 * width_control->get_value()));
|
||||
drag_data_label->set_markup (buf);
|
||||
}
|
||||
|
||||
void
|
||||
StereoPanner::value_change ()
|
||||
{
|
||||
set_drag_data ();
|
||||
queue_draw ();
|
||||
_drag_data_label->set_markup (buf);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -427,8 +410,8 @@ StereoPanner::on_button_release_event (GdkEventButton* ev)
|
|||
accumulated_delta = 0;
|
||||
detented = false;
|
||||
|
||||
if (drag_data_window) {
|
||||
drag_data_window->hide ();
|
||||
if (_drag_data_window) {
|
||||
_drag_data_window->hide ();
|
||||
}
|
||||
|
||||
if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
|
||||
|
|
@ -487,32 +470,7 @@ StereoPanner::on_motion_notify_event (GdkEventMotion* ev)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!drag_data_window) {
|
||||
drag_data_window = new Window (WINDOW_POPUP);
|
||||
drag_data_window->set_name (X_("ContrastingPopup"));
|
||||
drag_data_window->set_position (WIN_POS_MOUSE);
|
||||
drag_data_window->set_decorated (false);
|
||||
|
||||
drag_data_label = manage (new Label);
|
||||
drag_data_label->set_use_markup (true);
|
||||
|
||||
drag_data_window->set_border_width (6);
|
||||
drag_data_window->add (*drag_data_label);
|
||||
drag_data_label->show ();
|
||||
|
||||
Window* toplevel = dynamic_cast<Window*> (get_toplevel());
|
||||
if (toplevel) {
|
||||
drag_data_window->set_transient_for (*toplevel);
|
||||
}
|
||||
}
|
||||
|
||||
if (!drag_data_window->is_visible ()) {
|
||||
/* move the popup window vertically down from the panner display */
|
||||
int rx, ry;
|
||||
get_window()->get_origin (rx, ry);
|
||||
drag_data_window->move (rx, ry+get_height());
|
||||
drag_data_window->present ();
|
||||
}
|
||||
show_drag_data_window ();
|
||||
|
||||
int w = get_width();
|
||||
double delta = (ev->x - last_drag_x) / (double) w;
|
||||
|
|
@ -616,27 +574,6 @@ StereoPanner::on_key_press_event (GdkEventKey* ev)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
StereoPanner::on_key_release_event (GdkEventKey*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
StereoPanner::on_enter_notify_event (GdkEventCrossing*)
|
||||
{
|
||||
grab_focus ();
|
||||
Keyboard::magic_widget_grab_focus ();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
StereoPanner::on_leave_notify_event (GdkEventCrossing*)
|
||||
{
|
||||
Keyboard::magic_widget_drop_focus ();
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
StereoPanner::set_colors ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,11 +21,8 @@
|
|||
#define __gtk_ardour_stereo_panner_h__
|
||||
|
||||
#include "pbd/signals.h"
|
||||
|
||||
#include <gtkmm/drawingarea.h>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "gtkmm2ext/binding_proxy.h"
|
||||
#include "panner_interface.h"
|
||||
|
||||
namespace PBD {
|
||||
class Controllable;
|
||||
|
|
@ -35,7 +32,7 @@ namespace ARDOUR {
|
|||
class Panner;
|
||||
}
|
||||
|
||||
class StereoPanner : public Gtk::DrawingArea
|
||||
class StereoPanner : public PannerInterface
|
||||
{
|
||||
public:
|
||||
StereoPanner (boost::shared_ptr<ARDOUR::Panner>);
|
||||
|
|
@ -53,12 +50,8 @@ class StereoPanner : public Gtk::DrawingArea
|
|||
bool on_motion_notify_event (GdkEventMotion*);
|
||||
bool on_scroll_event (GdkEventScroll*);
|
||||
bool on_key_press_event (GdkEventKey*);
|
||||
bool on_key_release_event (GdkEventKey*);
|
||||
bool on_enter_notify_event (GdkEventCrossing* ev);
|
||||
bool on_leave_notify_event (GdkEventCrossing* ev);
|
||||
|
||||
private:
|
||||
boost::shared_ptr<ARDOUR::Panner> _panner;
|
||||
boost::shared_ptr<PBD::Controllable> position_control;
|
||||
boost::shared_ptr<PBD::Controllable> width_control;
|
||||
PBD::ScopedConnectionList connections;
|
||||
|
|
@ -71,13 +64,9 @@ class StereoPanner : public Gtk::DrawingArea
|
|||
double accumulated_delta;
|
||||
bool detented;
|
||||
|
||||
Gtk::Window* drag_data_window;
|
||||
Gtk::Label* drag_data_label;
|
||||
|
||||
BindingProxy position_binder;
|
||||
BindingProxy width_binder;
|
||||
|
||||
void value_change ();
|
||||
void set_drag_data ();
|
||||
|
||||
struct ColorScheme {
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ gtk2_ardour_sources = [
|
|||
'option_editor.cc',
|
||||
'opts.cc',
|
||||
'panner2d.cc',
|
||||
'panner_interface.cc',
|
||||
'panner_ui.cc',
|
||||
'piano_roll_header.cc',
|
||||
'playlist_selector.cc',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue