enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[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 #include "panner_interface.h"
24 #include "panner_editor.h"
25
26 #include "pbd/i18n.h"
27
28 using namespace std;
29 using namespace Gtk;
30 using namespace ARDOUR;
31 using namespace Gtkmm2ext;
32
33 PannerInterface::PannerInterface (boost::shared_ptr<Panner> p)
34         : _panner (p)
35         , _tooltip (this)
36         , _send_mode (false)
37         , _editor (0)
38 {
39         set_flags (Gtk::CAN_FOCUS);
40
41         add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|
42                     Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|
43                     Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|
44                     Gdk::SCROLL_MASK|
45                     Gdk::POINTER_MOTION_MASK);
46
47 }
48
49 PannerInterface::~PannerInterface ()
50 {
51         delete _editor;
52 }
53
54 bool
55 PannerInterface::on_enter_notify_event (GdkEventCrossing *)
56 {
57         grab_focus ();
58         Keyboard::magic_widget_grab_focus ();
59         return false;
60 }
61
62 bool
63 PannerInterface::on_leave_notify_event (GdkEventCrossing *)
64 {
65         Keyboard::magic_widget_drop_focus ();
66         return false;
67 }
68
69 bool
70 PannerInterface::on_key_release_event (GdkEventKey*)
71 {
72         return false;
73 }
74
75 void
76 PannerInterface::value_change ()
77 {
78         set_tooltip ();
79         queue_draw ();
80 }
81
82 bool
83 PannerInterface::on_button_press_event (GdkEventButton* ev)
84 {
85         if (Gtkmm2ext::Keyboard::is_edit_event (ev)) {
86                 edit ();
87                 return true;
88         }
89
90         return false;
91 }
92
93 bool
94 PannerInterface::on_button_release_event (GdkEventButton* ev)
95 {
96         if (Gtkmm2ext::Keyboard::is_edit_event (ev)) {
97                 /* We edited on the press, so claim the release */
98                 return true;
99         }
100
101         return false;
102 }
103
104 void
105 PannerInterface::edit ()
106 {
107         delete _editor;
108         _editor = editor ();
109         _editor->show ();
110 }
111
112 void
113 PannerInterface::set_send_drawing_mode(bool onoff) {
114         if (_send_mode != onoff) {
115                 _send_mode = onoff;
116                 queue_draw ();
117         }
118 }
119
120 PannerPersistentTooltip::PannerPersistentTooltip (Gtk::Widget* w)
121         : PersistentTooltip (w, true)
122         , _dragging (false)
123 {
124
125 }
126
127 void
128 PannerPersistentTooltip::target_start_drag ()
129 {
130         _dragging = true;
131 }
132
133 void
134 PannerPersistentTooltip::target_stop_drag ()
135 {
136         _dragging = false;
137 }
138
139 bool
140 PannerPersistentTooltip::dragging () const
141 {
142         return _dragging;
143 }