Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

571 lines
12KB

  1. # data file for the Fltk User Interface Designer (fluid)
  2. version 1.0107
  3. header_name {.H}
  4. code_name {.C}
  5. comment {//
  6. // Copyright (C) 2008 Jonathan Moore Liles
  7. //
  8. // This program is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU General Public License
  10. // as published by the Free Software Foundation; either version 2
  11. // of the License, or (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. //
  22. } {in_source in_header
  23. }
  24. decl {\#include "../grid.H"} {}
  25. decl {\#include "../scale.H"} {}
  26. decl {extern Fl_Color velocity_colors[];} {}
  27. decl {class Event_Widget;} {public
  28. }
  29. class Event_Editor {open
  30. } {
  31. decl {int _h;} {}
  32. decl {Grid *_grid;} {}
  33. decl {event_list *_old;} {}
  34. decl {event_list *_el;} {}
  35. decl {int _y;} {}
  36. Function {make_window( Grid *g )} {open
  37. } {
  38. Fl_Window window {
  39. label {Event Editor}
  40. callback {delete _el;
  41. _grid->events( _old );
  42. delete _old;
  43. _el = _old = NULL;
  44. o->hide();
  45. Fl::delete_widget( o );} open selected
  46. xywh {704 82 659 803} type Double box DOWN_BOX resizable
  47. code0 {\#include "event_edit.H"}
  48. code1 {\#include "../grid.H"}
  49. code2 {\#include "../event_list.H"} modal size_range {0 0 659 803} visible
  50. } {
  51. Fl_Pack {} {
  52. label {Event List} open
  53. xywh {10 23 640 738} type HORIZONTAL
  54. } {
  55. Fl_Scroll scroll_w {open
  56. xywh {10 24 620 737} type HORIZONTAL box DOWN_BOX labeltype NO_LABEL resizable
  57. } {
  58. Fl_Pack pack {open
  59. xywh {10 24 620 737} when 6 resizable
  60. } {}
  61. }
  62. Fl_Scrollbar scroll_bar {
  63. user_data this user_data_type {Event_Editor*}
  64. callback {v->scroll( o->value() );
  65. v->update_widgets();}
  66. xywh {629 23 20 738} when 3
  67. }
  68. }
  69. Fl_Return_Button {} {
  70. label {&Save}
  71. callback {delete window;
  72. delete _el;
  73. delete _old;}
  74. xywh {489 771 76 25}
  75. }
  76. Fl_Button {} {
  77. label {&Discard}
  78. callback {window->do_callback();}
  79. xywh {575 771 74 25}
  80. }
  81. Fl_Button {} {
  82. label Del
  83. user_data this user_data_type {Event_Editor *}
  84. callback {_el->remove_selected();
  85. sync();}
  86. xywh {10 771 74 25} shortcut 0xffff color 88
  87. }
  88. Fl_Menu_Button {} {
  89. label {&Insert}
  90. user_data this user_data_type {Event_Editor *}
  91. callback {if ( o->value() == 0 )
  92. {
  93. // note;
  94. event *on = new event;
  95. event *off = new event;
  96. on->status( event::NOTE_ON );
  97. on->note( 64 );
  98. on->note_velocity( 64 );
  99. off->status( event::NOTE_OFF );
  100. off->note( 64 );
  101. off->timestamp( 1 );
  102. off->note_velocity( 64 );
  103. on->link( off );
  104. _el->insert( on );
  105. _el->insert( off );
  106. }
  107. else
  108. {
  109. event *e = new event;
  110. int opcode = e->name( o->menu()[ o->value() ].text );
  111. if ( opcode < 0 )
  112. return;
  113. e->status( opcode );
  114. Event_Widget *ew = v->value();
  115. if ( ew && ew->ev() )
  116. e->timestamp( ew->ev()->timestamp() );
  117. _el->insert( e );
  118. }
  119. sync();} open
  120. xywh {94 771 121 25} color 63
  121. } {
  122. MenuItem {} {
  123. label Note
  124. xywh {10 10 40 25}
  125. }
  126. MenuItem {} {
  127. label Aftertouch
  128. xywh {50 50 40 25}
  129. }
  130. MenuItem {} {
  131. label {Control Change}
  132. xywh {20 20 40 25}
  133. }
  134. MenuItem {} {
  135. label {Program Change}
  136. xywh {30 30 40 25}
  137. }
  138. MenuItem {} {
  139. label {Channel Pressure}
  140. xywh {60 60 40 25}
  141. }
  142. MenuItem {} {
  143. label {Pitch Wheel}
  144. xywh {40 40 40 25}
  145. }
  146. }
  147. }
  148. code {// keep a copy
  149. _old = g->events();
  150. _el = g->events();
  151. _grid = g;
  152. _y = 0;
  153. _h = scroll_w->h() / 24;
  154. // create widgets.
  155. for ( int n = _h; n--; )
  156. {
  157. Event_Widget *ew = new Event_Widget( 0, 0, pack->w(), 24, 0 );
  158. ew->callback( cb_changed, (void*)this );
  159. ew->when( FL_WHEN_CHANGED );
  160. pack->add( ew );
  161. }
  162. pack->end();
  163. // Fl_Pack has a bug--it doesn't resize children until we resize it.
  164. pack->resize( scroll_w->x(), scroll_w->y(), scroll_w->w(), scroll_w->h() );
  165. scroll_bar->minimum( 0 );
  166. scroll_bar->maximum( _el->size() - _h );
  167. update_widgets();} {}
  168. }
  169. Function {sync( void )} {open return_type void
  170. } {
  171. code {MESSAGE( "syncing events to grid" );
  172. _grid->events( _el );
  173. update_widgets();} {}
  174. }
  175. Function {update_widgets( void )} {open return_type void
  176. } {
  177. code {// draw em
  178. int i = 0;
  179. if ( ! _el->empty() )
  180. for ( event* e = (*_el)[_y]; e && i < _h; (e = e->next()), i++ )
  181. {
  182. Event_Widget *ew = (Event_Widget *)(pack->child( i ));
  183. ew->ev( e );
  184. ew->show();
  185. }
  186. // hide unused widgets.
  187. for ( int j = i; j < _h; j++ )
  188. {
  189. Event_Widget *ew = (Event_Widget *)(pack->child( j ));
  190. ew->ev( NULL );
  191. ew->hide();
  192. }
  193. // ajdust scrollbar
  194. int sbmax = _el->size() - _h;
  195. if ( sbmax > 0 )
  196. {
  197. scroll_bar->maximum( sbmax );
  198. scroll_bar->show();
  199. scroll_w->size( scroll_w->parent()->w() - scroll_bar->w(), scroll_w->parent()->h() );
  200. }
  201. else
  202. {
  203. scroll_bar->hide();
  204. scroll_w->size( scroll_w->parent()->w(), scroll_w->parent()->h() );
  205. }} {}
  206. }
  207. Function {scroll( int y )} {open return_type void
  208. } {
  209. code {_y = y;} {}
  210. }
  211. Function {value( void )} {return_type {Event_Widget *}
  212. } {
  213. code {for ( int i = _h; i--; )
  214. {
  215. Event_Widget *w = (Event_Widget*)pack->child( i );
  216. if ( w->selected() )
  217. return w;
  218. }
  219. return NULL;} {}
  220. }
  221. Function {cb_changed( Fl_Widget *w, void *ee )} {open return_type {static void}
  222. } {
  223. code {Event_Widget *ew = (Event_Widget*)w;
  224. if ( ew->changed() )
  225. // sorting order changed.
  226. ((Event_Editor*)ee)->_el->sort( ew->ev() );
  227. ((Event_Editor*)ee)->sync();} {}
  228. }
  229. }
  230. Function {event_editor( Grid *g )} {open C return_type void
  231. } {
  232. code {Event_Editor ee;
  233. Fl_Window *w = ee.make_window( g );
  234. w->modal();
  235. w->show();
  236. while( w->shown() )
  237. Fl::wait();} {}
  238. }
  239. widget_class Event_Widget {user_data_type {void *} open
  240. xywh {969 357 594 31} type Single
  241. code0 {\#include "../event.H"}
  242. code1 {_event = NULL;}
  243. class Fl_Group size_range {400 24 0 24} visible
  244. } {
  245. decl {static const Fl_Color note_color = FL_BLACK;} {}
  246. decl {static const Fl_Color control_color = FL_BLUE;} {}
  247. decl {static const Fl_Color prog_color = FL_RED;} {}
  248. decl {static const Fl_Color pressure_color = FL_YELLOW;} {}
  249. decl {static const Fl_Color after_color = FL_CYAN;} {}
  250. decl {static const Fl_Color pitch_color = FL_GREEN} {}
  251. decl {event *_event;} {}
  252. decl {Fl_Group *tab;} {}
  253. Function {ev( event * e )} {open return_type void
  254. } {
  255. code {if ( e && ( _event == NULL ) )
  256. activate();
  257. else
  258. if ( ! e )
  259. {
  260. _event = NULL;
  261. deactivate();
  262. return;
  263. }
  264. activate();
  265. _event = e;
  266. name->label( e->name() );
  267. time->value( e->timestamp() );
  268. // hide all tabs
  269. for ( int i = 2; i < children(); i++ )
  270. child( i )->hide();
  271. Fl_Valuator *d1, *d2;
  272. d1 = d2 = NULL;
  273. name->color( FL_BLACK );
  274. name->value( e->selected() );
  275. // display the proper subtype
  276. switch ( e->opcode() )
  277. {
  278. \#define TWO d1 = (Fl_Valuator*)tab->child( 0 ); d2 = (Fl_Valuator*)tab->child( 1 )
  279. \#define ONE d1 = (Fl_Valuator*)tab->child( 0 ); d2 = NULL
  280. case midievent::NOTE_ON:
  281. case midievent::NOTE_OFF:
  282. tab = note_tab;
  283. name->color( note_color );
  284. note_name->label( Scale::chromatic_name( e->note() ) );
  285. note_name->labelcolor( velocity_colors[ e->note_velocity() ] );
  286. TWO;
  287. break;
  288. case midievent::CONTROL_CHANGE:
  289. tab = control_tab;
  290. name->color( control_color );
  291. TWO;
  292. break;
  293. case midievent::AFTERTOUCH:
  294. tab = after_tab;
  295. name->color( after_color );
  296. TWO;
  297. break;
  298. case midievent::CHANNEL_PRESSURE:
  299. tab = pressure_tab;
  300. name->color( pressure_color );
  301. ONE;
  302. break;
  303. case midievent::PROGRAM_CHANGE:
  304. tab = prog_tab;
  305. name->color( prog_color );
  306. ONE;
  307. break;
  308. case midievent::PITCH_WHEEL:
  309. tab = pitch_tab;
  310. name->color( pitch_color );
  311. ONE;
  312. d1->value( e->pitch() );
  313. goto pitch;
  314. break;
  315. }
  316. byte_t D1, D2;
  317. e->data( &D1, &D2 );
  318. d1->value( D1 );
  319. if ( d2 )
  320. d2->value( D2 );
  321. pitch:
  322. // show the current tab
  323. tab->show();
  324. time->redraw();
  325. name->redraw();
  326. // redraw();} {}
  327. }
  328. Function {ev( void )} {open return_type {event *}
  329. } {
  330. code {return _event;} {}
  331. }
  332. Fl_Value_Input time {
  333. callback {if ( _event->is_note_off() )
  334. {
  335. if ( o->value() < _event->link()->timestamp() )
  336. {
  337. o->value( _event->timestamp() );
  338. return;
  339. }
  340. }
  341. else
  342. if ( _event->is_note_on() )
  343. if ( o->value() > _event->link()->timestamp() )
  344. {
  345. o->value( _event->timestamp() );
  346. return;
  347. }
  348. _event->timestamp( o->value() );
  349. set_changed();
  350. do_callback();}
  351. xywh {3 0 125 24} labeltype NO_LABEL align 0 when 8 maximum 0
  352. code1 {o->maximum( (unsigned long)-1 );}
  353. }
  354. Fl_Button name {
  355. label {<Event Name>} user_data_type {void*}
  356. callback {if ( o->value() )
  357. _event->select();
  358. else
  359. _event->deselect();
  360. do_callback();}
  361. xywh {132 -1 149 25} type Toggle when 1
  362. }
  363. Fl_Group note_tab {open
  364. xywh {282 0 309 24} align 16
  365. } {
  366. Fl_Counter {} {
  367. label {Note:}
  368. user_data this
  369. callback cb_note
  370. xywh {359 0 76 24} type Simple align 4 minimum 0 maximum 127 step 1
  371. }
  372. Fl_Counter {} {
  373. label {Velocity:}
  374. user_data this
  375. callback cb_msb
  376. xywh {518 0 73 24} type Simple align 4 minimum 0 maximum 127 step 1
  377. }
  378. Fl_Box note_name {
  379. label {A\#}
  380. private xywh {284 1 31 24} labeltype SHADOW_LABEL labelfont 14 labelcolor 135
  381. }
  382. }
  383. Fl_Group after_tab {open
  384. xywh {317 0 277 24} align 16 hide
  385. } {
  386. Fl_Counter {} {
  387. label {Note:}
  388. user_data this
  389. callback cb_note
  390. xywh {359 0 76 24} type Simple align 4 minimum 0 maximum 127 step 1
  391. }
  392. Fl_Counter {} {
  393. label {Pressure:}
  394. user_data this
  395. callback cb_msb
  396. xywh {518 0 76 24} type Simple align 4 minimum 0 maximum 127 step 1
  397. }
  398. }
  399. Fl_Group control_tab {open
  400. xywh {358 0 238 24} align 16 hide
  401. } {
  402. Fl_Counter {} {
  403. label {Control:}
  404. user_data this
  405. callback cb_lsb
  406. xywh {360 0 76 24} type Simple align 4 minimum 0 maximum 127 step 1
  407. }
  408. Fl_Counter {} {
  409. label {Value:}
  410. user_data this
  411. callback cb_msb
  412. xywh {517 0 76 24} type Simple align 4 minimum 0 maximum 127 step 1
  413. }
  414. }
  415. Fl_Group prog_tab {open
  416. xywh {287 0 238 24} align 16 hide
  417. } {
  418. Fl_Counter {} {
  419. label {Program:}
  420. user_data this
  421. callback cb_lsb
  422. xywh {360 0 76 24} type Simple align 4 minimum 0 maximum 127 step 1
  423. }
  424. }
  425. Fl_Group pitch_tab {open
  426. xywh {306 0 290 24} align 16 hide
  427. } {
  428. Fl_Slider {} {
  429. label {Pitch:} user_data_type {void *}
  430. callback {_event->pitch( o->value() );
  431. do_callback();}
  432. xywh {358 0 238 24} type Horizontal align 4 when 4 minimum -8192 maximum 8191 step 1
  433. }
  434. }
  435. Fl_Group pressure_tab {open
  436. xywh {307 0 290 24} align 16 hide
  437. } {
  438. Fl_Slider {} {
  439. label {Pressure:}
  440. user_data this
  441. callback cb_lsb
  442. xywh {358 0 239 24} type Horizontal align 4 when 4 maximum 127 step 1
  443. }
  444. }
  445. Function {select( bool b )} {open return_type void
  446. } {
  447. code {/*
  448. _selected = b;
  449. if ( b )
  450. name->color( FL_WHITE );
  451. redraw();
  452. */} {}
  453. }
  454. Function {button()} {open return_type {Fl_Button *}
  455. } {
  456. code {return name;} {}
  457. }
  458. Function {selected( void )} {open return_type bool
  459. } {
  460. code {/*
  461. int n = name->value();
  462. name->value( 0 );
  463. return n;
  464. */
  465. return name->value();} {}
  466. }
  467. Function {cb_lsb( Fl_Valuator *o, Event_Widget *w )} {open return_type {static void}
  468. } {
  469. code {w->ev()->lsb( o->value() );
  470. w->do_callback();} {}
  471. }
  472. Function {cb_msb( Fl_Valuator *o, Event_Widget *w )} {open return_type {static void}
  473. } {
  474. code {w->ev()->msb( o->value() );
  475. w->do_callback();} {}
  476. }
  477. Function {cb_note( Fl_Valuator *o, Event_Widget *w )} {open return_type {static void}
  478. } {
  479. code {w->ev()->note( o->value() );
  480. w->do_callback();} {}
  481. }
  482. }