Strip trailing whitespace and fix other whitespace errors (e.g. space/tab mixing...
[ardour.git] / gtk2_ardour / piano_roll_header.h
1 /*
2     Copyright (C) 2008 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 #ifndef __ardour_piano_roll_header_h__
20 #define __ardour_piano_roll_header_h__
21
22 #include "ardour/types.h"
23
24 #include <gtkmm/drawingarea.h>
25
26 namespace ARDOUR {
27         class MidiTrack;
28 }
29
30 class MidiTimeAxisView;
31 class MidiStreamView;
32
33 class PianoRollHeader : public Gtk::DrawingArea {
34 public:
35         PianoRollHeader(MidiStreamView&);
36
37         bool on_expose_event (GdkEventExpose*);
38         bool on_motion_notify_event (GdkEventMotion*);
39         bool on_button_press_event (GdkEventButton*);
40         bool on_button_release_event (GdkEventButton*);
41         bool on_scroll_event (GdkEventScroll*);
42         bool on_enter_notify_event (GdkEventCrossing*);
43         bool on_leave_notify_event (GdkEventCrossing*);
44
45         void on_size_request(Gtk::Requisition*);
46         void on_size_allocate(Gtk::Allocation& a);
47
48         void note_range_changed();
49
50         struct Color {
51                 Color();
52                 Color(double _r, double _g, double _b);
53                 inline void set(const Color& c);
54
55                 double r;
56                 double g;
57                 double b;
58         };
59
60 private:
61         static Color white;
62         static Color white_highlight;
63         static Color white_shade_light;
64         static Color white_shade_dark;
65         static Color black;
66         static Color black_highlight;
67         static Color black_shade_light;
68         static Color black_shade_dark;
69
70         PianoRollHeader(const PianoRollHeader&);
71
72         enum ItemType {
73                 BLACK_SEPARATOR,
74                 BLACK_MIDDLE_SEPARATOR,
75                 BLACK,
76                 WHITE_SEPARATOR,
77                 WHITE_RECT,
78                 WHITE_CF,
79                 WHITE_EB,
80                 WHITE_DGA
81         };
82
83         void invalidate_note_range(int lowest, int highest);
84
85         void get_path(ItemType, int note, double x[], double y[]);
86
87         void send_note_on(uint8_t note);
88         void send_note_off(uint8_t note);
89
90         MidiStreamView& _view;
91
92         uint8_t _event[3];
93
94         Cairo::RefPtr<Cairo::Context> cc;
95         bool _active_notes[128];
96         uint8_t _highlighted_note;
97         uint8_t _clicked_note;
98         double _grab_y;
99         bool _dragging;
100
101         double _note_height;
102         double _black_note_width;
103 };
104
105 #endif /* __ardour_piano_roll_header_h__ */