2 Epichord - a midi sequencer
3 Copyright (C) 2008 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (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
18 The Free Software Foundation, Inc.
19 51 Franklin Street, Fifth Floor
20 Boston, MA 02110-1301, USA
28 #include <fltk/Group.h>
29 #include <fltk/Widget.h>
30 #include <fltk/events.h>
34 #include "eventmenu.h"
39 extern struct conf config
;
42 extern std::vector
<track
*> tracks
;
44 extern char controller_names_short
[128][64];
48 EventMenu::EventMenu(int x
, int y
, int w
, int h
, const char* label
) : fltk::Widget(x
, y
, w
, h
, label
) {
54 int EventMenu::handle(int event
){
62 if(event_button()==1){//switch to event
63 i
= xy2menu_index(X
,Y
);
65 case 0: ui
->event_edit
->set_event_type(MIDI_NOTE_ON
,0); break;
66 case 1: ui
->event_edit
->set_event_type(MIDI_NOTE_OFF
,0); break;
67 case 2: ui
->event_edit
->set_event_type(MIDI_AFTERTOUCH
,0); break;
68 case 3: ui
->event_edit
->set_event_type(MIDI_PROGRAM_CHANGE
,0); break;
69 case 4: ui
->event_edit
->set_event_type(MIDI_CHANNEL_PRESSURE
,0); break;
70 case 5: ui
->event_edit
->set_event_type(MIDI_PITCH_WHEEL
,0); break;
72 ui
->event_edit
->set_event_type(MIDI_CONTROLLER_CHANGE
,i
-6);
75 ui
->event_edit
->show();
77 ui
->event_menu_button
->state(0);
79 else if(event_button()==3){//erase events
87 if(event_button()==3){
88 scroll
= scroll_orig
+ (drag_orig_x
- event_x());
89 if(scroll
<0){scroll
=0;}
90 if(scroll
>1000){scroll
=1000;}
98 void EventMenu::draw(){
99 fltk::setfont(fltk::COURIER
,10);
100 fltk::setcolor(fltk::GRAY05
);
101 fltk::fillrect(0,0,w(),h());
103 fltk::push_clip(0,0,w(),h());
105 fltk::Color c1
= fltk::GRAY50
;
106 fltk::Color c2
= fltk::GRAY80
;
108 char buf
[16] = "booya";
110 for(int i
=0; i
<134; i
++){
111 if(ui
->event_edit
->has
[i
])
116 case 0: strcpy(buf
,"noteon"); break;
117 case 1: strcpy(buf
,"noteoff"); break;
118 case 2: strcpy(buf
,"aftertouch"); break;
119 case 3: strcpy(buf
,"program"); break;
120 case 4: strcpy(buf
,"pressure"); break;
121 case 5: strcpy(buf
,"pitchwheel"); break;
122 default: strncpy(buf
,controller_names_short
[i
-6],16); break;
124 fltk::drawtext(buf
,i
/6 * 64-scroll
,12+(12*(i
% 6)));
131 int EventMenu::xy2menu_index(int X
, int Y
){
134 int I
= (X
+scroll
)/W
* 6 + Y
*6/h();
135 if(I
>133){return 133;}