2011-12-26 09:05:19 -05:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2011-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2014-2017 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.
|
|
|
|
*/
|
2011-12-26 09:05:19 -05:00
|
|
|
|
|
|
|
#include <gtkmm.h>
|
|
|
|
#include "gtkmm2ext/keyboard.h"
|
2012-06-11 17:21:10 -04:00
|
|
|
#include "gtkmm2ext/persistent_tooltip.h"
|
2017-07-02 09:29:57 -04:00
|
|
|
|
|
|
|
#include "pbd/controllable.h"
|
|
|
|
|
2011-12-26 09:05:19 -05:00
|
|
|
#include "panner_interface.h"
|
2012-06-06 07:47:09 -04:00
|
|
|
#include "panner_editor.h"
|
2011-12-26 09:05:19 -05:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2011-12-26 09:05:19 -05:00
|
|
|
|
2011-12-26 09:30:35 -05:00
|
|
|
using namespace std;
|
2011-12-26 09:05:19 -05:00
|
|
|
using namespace Gtk;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
PannerInterface::PannerInterface (std::shared_ptr<Panner> p)
|
2011-12-26 09:05:19 -05:00
|
|
|
: _panner (p)
|
2012-06-11 17:21:10 -04:00
|
|
|
, _tooltip (this)
|
2014-06-17 09:51:49 -04:00
|
|
|
, _send_mode (false)
|
2012-06-06 07:47:09 -04:00
|
|
|
, _editor (0)
|
2011-12-26 09:05:19 -05:00
|
|
|
{
|
2022-01-26 16:29:36 -05:00
|
|
|
set_can_focus ();
|
2011-12-26 09:05:19 -05:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
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);
|
2011-12-26 09:05:19 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PannerInterface::~PannerInterface ()
|
|
|
|
{
|
2012-06-06 07:47:09 -04:00
|
|
|
delete _editor;
|
2011-12-26 09:05:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PannerInterface::on_enter_notify_event (GdkEventCrossing *)
|
|
|
|
{
|
|
|
|
grab_focus ();
|
|
|
|
Keyboard::magic_widget_grab_focus ();
|
2017-07-02 09:29:57 -04:00
|
|
|
|
|
|
|
if (!proxy_controllable ().expired ()) {
|
|
|
|
PBD::Controllable::GUIFocusChanged (proxy_controllable ());
|
|
|
|
}
|
2011-12-26 09:05:19 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PannerInterface::on_leave_notify_event (GdkEventCrossing *)
|
|
|
|
{
|
|
|
|
Keyboard::magic_widget_drop_focus ();
|
2017-07-02 09:29:57 -04:00
|
|
|
if (!proxy_controllable ().expired ()) {
|
2023-02-16 18:33:28 -05:00
|
|
|
PBD::Controllable::GUIFocusChanged (std::weak_ptr<PBD::Controllable> ());
|
2017-07-02 09:29:57 -04:00
|
|
|
}
|
2011-12-26 09:05:19 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PannerInterface::on_key_release_event (GdkEventKey*)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerInterface::value_change ()
|
|
|
|
{
|
2012-06-11 17:21:10 -04:00
|
|
|
set_tooltip ();
|
2011-12-26 09:05:19 -05:00
|
|
|
queue_draw ();
|
|
|
|
}
|
|
|
|
|
2012-06-06 07:47:09 -04:00
|
|
|
bool
|
|
|
|
PannerInterface::on_button_press_event (GdkEventButton* ev)
|
|
|
|
{
|
|
|
|
if (Gtkmm2ext::Keyboard::is_edit_event (ev)) {
|
|
|
|
edit ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PannerInterface::on_button_release_event (GdkEventButton* ev)
|
|
|
|
{
|
|
|
|
if (Gtkmm2ext::Keyboard::is_edit_event (ev)) {
|
|
|
|
/* We edited on the press, so claim the release */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerInterface::edit ()
|
|
|
|
{
|
|
|
|
delete _editor;
|
|
|
|
_editor = editor ();
|
|
|
|
_editor->show ();
|
|
|
|
}
|
2012-06-11 17:21:10 -04:00
|
|
|
|
2014-06-17 09:51:49 -04:00
|
|
|
void
|
|
|
|
PannerInterface::set_send_drawing_mode(bool onoff) {
|
|
|
|
if (_send_mode != onoff) {
|
|
|
|
_send_mode = onoff;
|
|
|
|
queue_draw ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-11 17:21:10 -04:00
|
|
|
PannerPersistentTooltip::PannerPersistentTooltip (Gtk::Widget* w)
|
2015-06-30 07:08:55 -04:00
|
|
|
: PersistentTooltip (w, true)
|
2012-06-11 17:21:10 -04:00
|
|
|
, _dragging (false)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerPersistentTooltip::target_start_drag ()
|
|
|
|
{
|
|
|
|
_dragging = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerPersistentTooltip::target_stop_drag ()
|
|
|
|
{
|
|
|
|
_dragging = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PannerPersistentTooltip::dragging () const
|
|
|
|
{
|
|
|
|
return _dragging;
|
|
|
|
}
|