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.
20 #ifndef __gtk_ardour_canvas_midi_event_h__
21 #define __gtk_ardour_canvas_midi_event_h__
23 #include "simplerect.h"
24 #include "midi_channel_selector.h"
25 #include <libgnomecanvasmm/text.h>
26 #include <libgnomecanvasmm/widget.h>
27 #include <ardour/midi_model.h>
36 /** This manages all the event handling for any MIDI event on the canvas.
38 * This is not actually a canvas item itself to avoid the dreaded diamond,
39 * since various types of canvas items (Note (rect), Hit (diamond), etc)
40 * need to share this functionality but can't share an ancestor.
42 * Note: Because of this, derived classes need to manually bounce events to
43 * on_event, it won't happen automatically.
45 * A newer, better canvas should remove the need for all the ugly here.
47 class CanvasNoteEvent : public sigc::trackable {
50 MidiRegionView& region,
52 const boost::shared_ptr<ARDOUR::Note> note = boost::shared_ptr<ARDOUR::Note>());
54 virtual ~CanvasNoteEvent();
56 bool on_event(GdkEvent* ev);
58 bool selected() const { return _selected; }
59 void selected(bool yn);
61 void move_event(double dx, double dy);
67 * This slot is called, when a new channel is selected for the single event
69 void on_channel_change(uint8_t channel);
70 void on_channel_selection_change(uint16_t selection);
72 void show_channel_selector();
74 void hide_channel_selector();
76 virtual void set_outline_color(uint32_t c) = 0;
77 virtual void set_fill_color(uint32_t c) = 0;
79 virtual double x1() = 0;
80 virtual double y1() = 0;
81 virtual double x2() = 0;
82 virtual double y2() = 0;
84 const boost::shared_ptr<ARDOUR::Note> note() const { return _note; }
87 enum State { None, Pressed, Dragging };
89 MidiRegionView& _region;
92 Widget* _channel_selector_widget;
94 const boost::shared_ptr<ARDOUR::Note> _note;
100 } // namespace Canvas
102 #endif /* __gtk_ardour_canvas_midi_event_h__ */