2 Copyright (C) 2007 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "canvas-midi-event.h"
22 #include "midi_region_view.h"
23 #include "public_editor.h"
24 #include "editing_syms.h"
33 CanvasMidiEvent::CanvasMidiEvent(MidiRegionView& region, Item* item)
42 CanvasMidiEvent::on_event(GdkEvent* ev)
44 static double last_x, last_y;
45 double event_x, event_y;
47 if (_region.get_time_axis_view().editor.current_mouse_mode() != Editing::MouseNote)
51 case GDK_ENTER_NOTIFY:
52 cerr << "ENTERED: " << ev->crossing.state << endl;
53 Keyboard::magic_widget_grab_focus();
55 /*if ( (ev->crossing.state & GDK_BUTTON2_MASK) ) {
60 case GDK_LEAVE_NOTIFY:
61 cerr << "LEAVE: " << ev->crossing.state << endl;
62 Keyboard::magic_widget_drop_focus();
63 //_region.get_time_axis_view().editor.reset_focus();
64 _region.get_canvas_group()->grab_focus();
68 cerr << "EVENT KEY PRESS\n"; // doesn't work :/
71 case GDK_BUTTON_PRESS:
75 case GDK_MOTION_NOTIFY:
76 event_x = ev->motion.x;
77 event_y = ev->motion.y;
78 //cerr << "MOTION @ " << event_x << ", " << event_y << endl;
79 _item->property_parent().get_value()->w2i(event_x, event_y);
83 _item->grab(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
84 Gdk::Cursor(Gdk::FLEUR), ev->motion.time);
90 if (ev->motion.is_hint) {
93 GdkModifierType state;
94 gdk_window_get_pointer(ev->motion.window, &t_x, &t_y, &state);
99 _item->move(event_x - last_x, event_y - last_y);
110 case GDK_BUTTON_RELEASE:
112 case Pressed: // Clicked
115 case Dragging: // Dropped
116 _item->ungrab(ev->button.time);
130 } // namespace Canvas