Only show user-presets in favorite sidebar
[ardour.git] / gtk2_ardour / panner_interface.cc
1 /*
2     Copyright (C) 2011 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <gtkmm.h>
21 #include "gtkmm2ext/keyboard.h"
22 #include "gtkmm2ext/persistent_tooltip.h"
23
24 #include "pbd/controllable.h"
25
26 #include "panner_interface.h"
27 #include "panner_editor.h"
28
29 #include "pbd/i18n.h"
30
31 using namespace std;
32 using namespace Gtk;
33 using namespace ARDOUR;
34 using namespace Gtkmm2ext;
35
36 PannerInterface::PannerInterface (boost::shared_ptr<Panner> p)
37         : _panner (p)
38         , _tooltip (this)
39         , _send_mode (false)
40         , _editor (0)
41 {
42         set_flags (Gtk::CAN_FOCUS);
43
44         add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|
45                     Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|
46                     Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|
47                     Gdk::SCROLL_MASK|
48                     Gdk::POINTER_MOTION_MASK);
49
50 }
51
52 PannerInterface::~PannerInterface ()
53 {
54         delete _editor;
55 }
56
57 bool
58 PannerInterface::on_enter_notify_event (GdkEventCrossing *)
59 {
60         grab_focus ();
61         Keyboard::magic_widget_grab_focus ();
62
63         if (!proxy_controllable ().expired ()) {
64                 PBD::Controllable::GUIFocusChanged (proxy_controllable ());
65         }
66         return false;
67 }
68
69 bool
70 PannerInterface::on_leave_notify_event (GdkEventCrossing *)
71 {
72         Keyboard::magic_widget_drop_focus ();
73         if (!proxy_controllable ().expired ()) {
74                 PBD::Controllable::GUIFocusChanged (boost::weak_ptr<PBD::Controllable> ());
75         }
76         return false;
77 }
78
79 bool
80 PannerInterface::on_key_release_event (GdkEventKey*)
81 {
82         return false;
83 }
84
85 void
86 PannerInterface::value_change ()
87 {
88         set_tooltip ();
89         queue_draw ();
90 }
91
92 bool
93 PannerInterface::on_button_press_event (GdkEventButton* ev)
94 {
95         if (Gtkmm2ext::Keyboard::is_edit_event (ev)) {
96                 edit ();
97                 return true;
98         }
99
100         return false;
101 }
102
103 bool
104 PannerInterface::on_button_release_event (GdkEventButton* ev)
105 {
106         if (Gtkmm2ext::Keyboard::is_edit_event (ev)) {
107                 /* We edited on the press, so claim the release */
108                 return true;
109         }
110
111         return false;
112 }
113
114 void
115 PannerInterface::edit ()
116 {
117         delete _editor;
118         _editor = editor ();
119         _editor->show ();
120 }
121
122 void
123 PannerInterface::set_send_drawing_mode(bool onoff) {
124         if (_send_mode != onoff) {
125                 _send_mode = onoff;
126                 queue_draw ();
127         }
128 }
129
130 PannerPersistentTooltip::PannerPersistentTooltip (Gtk::Widget* w)
131         : PersistentTooltip (w, true)
132         , _dragging (false)
133 {
134
135 }
136
137 void
138 PannerPersistentTooltip::target_start_drag ()
139 {
140         _dragging = true;
141 }
142
143 void
144 PannerPersistentTooltip::target_stop_drag ()
145 {
146         _dragging = false;
147 }
148
149 bool
150 PannerPersistentTooltip::dragging () const
151 {
152         return _dragging;
153 }