# data file for the Fltk User Interface Designer (fluid) version 1.0300 header_name {.H} code_name {.C} comment {// // Copyright (C) 2008 Jonathan Moore Liles // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // } {in_source in_header } decl {\#include "../grid.H"} {private local } decl {\#include "../scale.H"} {private local } decl {\#include } {public global } decl {\#include } {selected public global } decl {using namespace MIDI;} {private local } decl {extern Fl_Color velocity_colors[];} {private local } decl {class Event_Widget;} {public local } class Event_Editor {open } { decl {int _h;} {private local } decl {Grid *_grid;} {private local } decl {MIDI::event_list *_old;} {private local } decl {MIDI::event_list *_el;} {private local } decl {int _y;} {private local } Function {make_window( Grid *g )} {open } { Fl_Window window { label {Event Editor} callback {delete _el; _grid->events( _old ); delete _old; _el = _old = NULL; o->hide(); Fl::delete_widget( o );} open xywh {968 122 655 805} type Double resizable code0 {\#include "event_edit.H"} code1 {\#include "../grid.H"} modal size_range {0 0 659 803} visible } { Fl_Scroll {} { label {Event List} open xywh {10 29 635 737} type VERTICAL_ALWAYS box FLAT_BOX } { Fl_Pack pack {open xywh {10 29 635 737} color 47 when 6 resizable } {} } Fl_Return_Button {} { label {&Save} callback {delete window; delete _el; delete _old;} xywh {489 771 76 25} } Fl_Button {} { label {&Discard} callback {window->do_callback();} xywh {575 771 74 25} } Fl_Button {} { label Del user_data this user_data_type {Event_Editor *} callback {_el->remove_selected(); sync();} xywh {10 771 74 25} shortcut 0xffff color 88 } Fl_Menu_Button {} { label {&Insert} user_data this user_data_type {Event_Editor *} callback {if ( o->value() == 0 ) { // note; event *on = new event; event *off = new event; on->status( event::NOTE_ON ); on->note( 64 ); on->note_velocity( 64 ); off->status( event::NOTE_OFF ); off->note( 64 ); off->timestamp( 1 ); off->note_velocity( 64 ); on->link( off ); _el->insert( on ); _el->insert( off ); } else { event *e = new event; int opcode = e->name( o->menu()[ o->value() ].text ); if ( opcode < 0 ) return; e->status( opcode ); Event_Widget *ew = v->value(); if ( ew && ew->ev() ) e->timestamp( ew->ev()->timestamp() ); _el->insert( e ); } sync();} open xywh {94 771 121 25} color 63 } { MenuItem {} { label Note xywh {10 10 40 25} } MenuItem {} { label Aftertouch xywh {50 50 40 25} } MenuItem {} { label {Control Change} xywh {20 20 40 25} } MenuItem {} { label {Program Change} xywh {30 30 40 25} } MenuItem {} { label {Channel Pressure} xywh {60 60 40 25} } MenuItem {} { label {Pitch Wheel} xywh {40 40 40 25} } } } code {// keep a copy _old = g->events(); _el = g->events(); _grid = g; _y = 0; _h = pack->h() / 24; update_widgets();} {} } Function {sync( void )} {open return_type void } { code {DMESSAGE( "syncing events to grid" ); _grid->events( _el ); update_widgets();} {} } Function {update_widgets( void )} {open return_type void } { code {int i = 0; if ( ! _el->empty() ) for ( event* e = (*_el)[0]; e; ( e = e->next() ), i++ ) { Event_Widget *ew; if ( i < pack->children() ) { ew = (Event_Widget*)pack->child(i); } else { ew = new Event_Widget( 0, 0, pack->w() - Fl::box_dw( pack->box() ), 24, 0 ); ew->callback( cb_changed, (void*)this ); ew->when( FL_WHEN_CHANGED ); pack->add( ew ); } ew->ev( e ); } // pack->parent()->redraw();} {} } Function {value( void )} {return_type {Event_Widget *} } { code {for ( int i = 0; i < pack->children(); i++ ) { Event_Widget *w = (Event_Widget*)pack->child( i ); if ( w->selected() ) return w; } return NULL;} {} } Function {cb_changed( Fl_Widget *w, void *ee )} {open return_type {static void} } { code {Event_Widget *ew = (Event_Widget*)w; if ( ew->changed() ) // sorting order changed. ((Event_Editor*)ee)->_el->sort( ew->ev() ); ((Event_Editor*)ee)->sync();} {} } } Function {event_editor( Grid *g )} {open C return_type void } { code {Event_Editor ee; Fl_Window *w = ee.make_window( g ); w->modal(); w->show(); while( w->shown() ) Fl::wait();} {} } widget_class Event_Widget {user_data_type {void *} open xywh {945 239 590 30} type Single code0 {_event = NULL;} class Fl_Group size_range {400 24 0 24} visible } { decl {static const Fl_Color note_color = FL_BLACK;} {private local } decl {static const Fl_Color control_color = FL_BLUE;} {private local } decl {static const Fl_Color prog_color = FL_RED;} {private local } decl {static const Fl_Color pressure_color = FL_YELLOW;} {private local } decl {static const Fl_Color after_color = FL_CYAN;} {private local } decl {static const Fl_Color pitch_color = FL_GREEN} {private local } decl {MIDI::event *_event;} {private local } decl {Fl_Group *tab;} {private local } Function {ev( MIDI::event * e )} {open return_type void } { code {if ( e && ( _event == NULL ) ) activate(); else if ( ! e ) { _event = NULL; deactivate(); return; } activate(); _event = e; name->label( e->name() ); time->value( e->timestamp() ); // hide all tabs for ( int i = 2; i < children(); i++ ) child( i )->hide(); Fl_Valuator *d1, *d2; d1 = d2 = NULL; name->color( FL_BLACK ); name->value( e->selected() ); // display the proper subtype switch ( e->opcode() ) { \#define TWO d1 = (Fl_Valuator*)tab->child( 0 ); d2 = (Fl_Valuator*)tab->child( 1 ) \#define ONE d1 = (Fl_Valuator*)tab->child( 0 ); d2 = NULL case midievent::NOTE_ON: case midievent::NOTE_OFF: tab = note_tab; name->color( note_color ); note_name->label( Scale::chromatic_name( e->note() ) ); note_name->labelcolor( velocity_colors[ e->note_velocity() ] ); TWO; break; case midievent::CONTROL_CHANGE: tab = control_tab; name->color( control_color ); TWO; break; case midievent::AFTERTOUCH: tab = after_tab; name->color( after_color ); TWO; break; case midievent::CHANNEL_PRESSURE: tab = pressure_tab; name->color( pressure_color ); ONE; break; case midievent::PROGRAM_CHANGE: tab = prog_tab; name->color( prog_color ); ONE; break; case midievent::PITCH_WHEEL: tab = pitch_tab; name->color( pitch_color ); ONE; d1->value( e->pitch() ); goto pitch; break; default: WARNING("Encountered unknown opcode"); return; break; } byte_t D1, D2; e->data( &D1, &D2 ); d1->value( D1 ); if ( d2 ) d2->value( D2 ); pitch: // show the current tab tab->show(); time->redraw(); name->redraw(); // redraw();} {} } Function {ev( void )} {open return_type {MIDI::event *} } { code {return _event;} {} } Fl_Value_Input time { callback {if ( _event->is_note_off() ) { if ( o->value() < _event->link()->timestamp() ) { o->value( _event->timestamp() ); return; } } else if ( _event->is_note_on() ) if ( o->value() > _event->link()->timestamp() ) { o->value( _event->timestamp() ); return; } _event->timestamp( o->value() ); set_changed(); do_callback();} xywh {3 0 125 24} labeltype NO_LABEL align 0 when 8 maximum 0 code1 {o->maximum( (unsigned long)-1 );} } Fl_Button name { label {} user_data_type {void*} callback {if ( o->value() ) _event->select(); else _event->deselect(); do_callback();} xywh {132 -1 149 25} type Toggle when 1 } Fl_Group note_tab {open xywh {282 -3 324 37} align 16 } { Fl_Value_Input {} { label {Note:} user_data this callback cb_note xywh {359 0 51 24} when 4 maximum 127 step 1 } Fl_Value_Slider {} { label {Velocity:} user_data this user_data_type {void *} callback cb_msb xywh {480 0 110 24} type {Horz Fill} selection_color 80 align 4 when 4 maximum 127 step 1 } Fl_Box note_name { label {A\#} private xywh {284 1 31 24} labeltype SHADOW_LABEL labelfont 14 labelcolor 135 } } Fl_Group after_tab {open xywh {317 0 277 25} align 16 hide } { Fl_Value_Input {} { label {Note:} user_data this callback cb_note xywh {359 0 51 24} when 4 maximum 127 step 1 } Fl_Value_Slider {} { label {Pressure:} user_data this user_data_type {void *} callback cb_msb xywh {480 0 110 24} type {Horz Fill} selection_color 80 align 4 when 4 maximum 127 step 1 } } Fl_Group control_tab {open xywh {358 0 238 34} align 16 hide } { Fl_Value_Input {} { label {Control:} user_data this callback cb_lsb xywh {359 0 51 24} when 4 maximum 127 step 1 } Fl_Value_Input {} { label {Value:} user_data this callback cb_msb xywh {480 0 51 24} when 4 maximum 127 step 1 } } Fl_Group prog_tab {open xywh {287 0 238 25} align 16 hide } { Fl_Value_Input {} { label {Program:} user_data this callback cb_lsb xywh {359 0 51 24} when 4 maximum 127 step 1 } } Fl_Group pitch_tab {open xywh {306 0 290 24} align 16 hide } { Fl_Slider {} { label {Pitch:} user_data_type {void *} callback {_event->pitch( o->value() ); do_callback();} xywh {358 0 231 24} type Horizontal align 4 when 4 minimum -8192 maximum 8191 step 1 } } Fl_Group pressure_tab {open xywh {307 0 291 24} align 16 hide } { Fl_Slider {} { label {Pressure:} user_data this callback cb_lsb xywh {359 0 230 24} type {Horz Fill} align 4 when 4 maximum 127 step 1 } } Function {select( bool b )} {open return_type void } { code {/* _selected = b; if ( b ) name->color( FL_WHITE ); redraw(); */} {} } Function {button()} {open return_type {Fl_Button *} } { code {return name;} {} } Function {selected( void )} {open return_type bool } { code {/* int n = name->value(); name->value( 0 ); return n; */ return name->value();} {} } Function {cb_lsb( Fl_Valuator *o, Event_Widget *w )} {open return_type {static void} } { code {w->ev()->lsb( o->value() ); w->do_callback();} {} } Function {cb_msb( Fl_Valuator *o, Event_Widget *w )} {open return_type {static void} } { code {w->ev()->msb( o->value() ); w->do_callback();} {} } Function {cb_note( Fl_Valuator *o, Event_Widget *w )} {open return_type {static void} } { code {w->ev()->note( o->value() ); w->do_callback();} {} } }