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.

1754 lines
44KB

  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 <Fl/Fl_Dial.H>} {public
  25. }
  26. decl {\#include <Fl/Fl_Help_Dialog.H>} {}
  27. decl {\#include "widgets.H"} {}
  28. decl {\#include "event_edit.H"} {}
  29. decl {\#include "../jack.H"} {}
  30. decl {\#include "../lash.H"} {}
  31. decl {extern UI *ui;} {}
  32. decl {class O_Canvas;} {}
  33. decl {class Triggers;} {public
  34. }
  35. decl {class Instrument_Editor;} {}
  36. decl {Fl_Color canvas_background_color;} {public
  37. }
  38. decl {extern Fl_Color velocity_colors[];} {}
  39. Function {update_transport( void * )} {open return_type void
  40. } {
  41. code {// transport_poll();
  42. handle_midi_input();
  43. lash.process();
  44. ui->progress_group->do_callback();
  45. ui->vmetro_widget->update();
  46. if ( transport.rolling )
  47. ui->triggers_widget->update();
  48. Fl::repeat_timeout( TRANSPORT_POLL_INTERVAL, update_transport );
  49. static int oldstate = -1;
  50. if ( transport.rolling != oldstate )
  51. {
  52. ui->play_button->label( transport.rolling ? "@square" : "@>" );
  53. oldstate = transport.rolling;
  54. }
  55. // JUST A TEST
  56. if ( transport.rolling )
  57. {
  58. if ( ui->tabs->value() == ui->pattern_tab )
  59. ui->pattern_canvas_widget->draw_playhead();
  60. else
  61. if ( ui->tabs->value() == ui->phrase_tab )
  62. ui->phrase_canvas_widget->draw_playhead();
  63. }} {}
  64. }
  65. class UI {open selected
  66. } {
  67. decl {Fl_Text_Buffer *sequence_notes_buffer;} {}
  68. decl {Fl_Text_Buffer *pattern_notes_buffer;} {}
  69. decl {Fl_Text_Buffer *phrase_notes_buffer} {}
  70. Function {UI()} {open
  71. } {
  72. code {// Make her pretty
  73. Fl::background( 32, 32, 32 );
  74. Fl::background2( 36, 36, 36 );
  75. Fl::foreground( 255, 255, 255 );
  76. Fl::scheme( "plastic" );
  77. canvas_background_color = FL_GREEN;
  78. main_window = make_main_window();
  79. seq_window = make_seq_window();
  80. make_randomization_dialog();
  81. // make_instrument_edit_dialog();
  82. Fl::add_handler( shortcut_handler );
  83. // use old focus behavior
  84. Fl::visible_focus( 0 );
  85. main_window->show();
  86. Fl::add_timeout( TRANSPORT_POLL_INTERVAL, update_transport );
  87. playlist->signal_new_song.connect( sigc::mem_fun( this, &UI::update_sequence_widgets ) );} {}
  88. }
  89. Function {~UI()} {open
  90. } {
  91. code {delete seq_window;
  92. delete main_window;} {}
  93. }
  94. Function {run()} {open
  95. } {
  96. code {Fl::run();} {}
  97. }
  98. Function {make_main_window()} {open
  99. } {
  100. Fl_Window main_window {
  101. label {Non Sequencer}
  102. callback {// Ignore escape
  103. if ( Fl::event() == FL_SHORTCUT && Fl::event_key() == FL_Escape )
  104. return;
  105. if ( maybe_save_song() )
  106. quit();} open
  107. xywh {699 154 869 801} type Single box PLASTIC_UP_BOX color 37 resizable xclass non size_range {869 801 0 0} visible
  108. } {
  109. Fl_Menu_Bar {} {open
  110. xywh {0 0 869 30} color 37
  111. } {
  112. Submenu {} {
  113. label {&File} open
  114. xywh {0 0 100 20} color 37
  115. } {
  116. MenuItem {} {
  117. label {&New}
  118. callback {if ( transport.rolling )
  119. {
  120. fl_alert( "Can't make new file while the transport is running." );
  121. return;
  122. }
  123. // FIXME: check for dirtiness and ask to save.
  124. if ( maybe_save_song() )
  125. {
  126. init_song();
  127. // Sync the GUI.
  128. update_pattern_widgets();
  129. update_sequence_widgets();
  130. update_phrase_widgets();
  131. }}
  132. xywh {0 0 40 25}
  133. }
  134. MenuItem {} {
  135. label {&Open}
  136. callback {if ( transport.rolling )
  137. {
  138. fl_alert( "Can't open file while transport is rolling." );
  139. return;
  140. }
  141. char *name = fl_file_chooser( "Open File", "Non Files (*.non)", NULL, 0 );
  142. if ( name )
  143. {
  144. if ( ! load_song( name ) )
  145. fl_alert( "Could not load song!" );
  146. update_sequence_widgets();
  147. update_pattern_widgets();
  148. update_phrase_widgets();
  149. playback_mode_menu->value( song.play_mode );
  150. playback_mode_menu->redraw();
  151. }}
  152. xywh {0 0 40 25} shortcut 0x4006f color 37
  153. }
  154. MenuItem {} {
  155. label {&Save}
  156. callback {save_dialog( song.filename );}
  157. xywh {0 0 40 25} shortcut 0x40073 color 37
  158. }
  159. MenuItem {} {
  160. label {Save &As}
  161. callback {save_dialog( NULL );}
  162. xywh {0 0 40 25}
  163. }
  164. MenuItem {} {
  165. label {&Import}
  166. callback {char *name = fl_file_chooser( "MIDI Import", "MIDI Files (*.mid)", NULL, 0 );
  167. if ( ! name )
  168. return;
  169. smf f;
  170. if ( ! f.open( name, smf::READ ) )
  171. {
  172. fl_message( "could not open file" );
  173. return;
  174. }
  175. f.read_header();
  176. switch ( f.format() )
  177. {
  178. case 0:
  179. if ( ! pattern::import( &f, 0 ) )
  180. fl_message( "Error importing MIDI" );
  181. break;
  182. case 1: case 2:
  183. {
  184. char **sa = f.track_listing();
  185. if ( sa && *sa )
  186. {
  187. List_Chooser tc( "Select tracks to import:", "Import" );
  188. char *s;
  189. for ( int i = 0; (s = sa[i]); ++i )
  190. {
  191. tc.add( s );
  192. free( s );
  193. }
  194. free( sa );
  195. tc.show();
  196. while( tc.shown() )
  197. Fl::wait();
  198. int n = 0;
  199. for ( int i = 1; i <= tc.browser->size(); ++i )
  200. {
  201. if ( tc.browser->selected( i ) )
  202. {
  203. if ( pattern::import( &f , i - 1 ) )
  204. ++n;
  205. else
  206. WARNING( "error importing track %d", i - 1 );
  207. }
  208. }
  209. // fl_message( "%d patterns imported.", n );
  210. gui_status( "Imported %d tracks as patterns", n );
  211. }
  212. break;
  213. }
  214. }}
  215. xywh {0 0 40 25}
  216. code0 {\#include "../smf.H"}
  217. }
  218. MenuItem {} {
  219. label {&Export}
  220. callback {// Fl_File_Chooser::custom_filter_label = "*.mid";
  221. Fl_File_Chooser *fc = new Fl_File_Chooser( ".", "MIDI Files (*.mid)", Fl_File_Chooser::CREATE, "MIDI Export" );
  222. fc->show();
  223. // wait for user to make a choice
  224. while( fc->shown() )
  225. Fl::wait();
  226. if ( ! fc->value() )
  227. return;
  228. if ( tabs->value() == pattern_tab )
  229. ((pattern*)pattern_c->grid())->save( fc->value() );}
  230. xywh {0 0 40 25}
  231. code0 {\#include <Fl/Fl_File_Chooser.H>}
  232. }
  233. MenuItem {} {
  234. label {&Quit}
  235. callback {main_window->do_callback();}
  236. xywh {0 0 40 25} shortcut 0x40071 color 37
  237. }
  238. }
  239. Submenu {} {
  240. label {&Edit} open
  241. xywh {0 0 74 25} color 37
  242. } {
  243. MenuItem {} {
  244. label {&Mapping}
  245. xywh {5 5 40 25} color 37
  246. }
  247. MenuItem {} {
  248. label {&Events}
  249. callback {if ( tabs->value() != pattern_tab )
  250. return;
  251. event_editor( pattern_c->grid() );}
  252. xywh {0 0 40 25}
  253. }
  254. MenuItem {} {
  255. label {&Randomization Settings}
  256. callback {randomization_dialog->show();}
  257. xywh {0 0 40 25}
  258. }
  259. }
  260. Submenu {} {
  261. label {&View} open
  262. xywh {10 10 74 25} color 37
  263. } {
  264. MenuItem {} {
  265. label {&Metronome}
  266. callback {int val = o->menu()[ o->value() ].value();
  267. if ( val )
  268. vmetro_widget->show();
  269. else
  270. vmetro_widget->hide();}
  271. xywh {0 0 40 25} type Toggle value 1
  272. }
  273. MenuItem {} {
  274. label {&Compacted}
  275. callback {int val = o->menu()[ o->value() ].value();
  276. pattern_c->row_compact( val ? Canvas::ON : Canvas::OFF );}
  277. xywh {10 10 40 25} type Toggle value 1
  278. }
  279. MenuItem {} {
  280. label {&Follow Playhead}
  281. callback {int val = o->menu()[ o->value() ].value();
  282. config.follow_playhead = val ? true : false;}
  283. xywh {10 10 40 25} type Toggle value 1
  284. }
  285. }
  286. Submenu {} {
  287. label {&Help} open
  288. xywh {100 0 74 25} color 37
  289. } {
  290. MenuItem {} {
  291. label {&Keys}
  292. callback {show_help_dialog( "KEYS" );}
  293. xywh {0 0 40 25}
  294. }
  295. MenuItem {} {
  296. label {&Manual}
  297. callback {show_help_dialog( "MANUAL" );}
  298. xywh {10 10 40 25} divider
  299. }
  300. MenuItem {} {
  301. label {&About}
  302. callback {make_about_popup();
  303. about_popup->show();}
  304. xywh {0 0 40 25} color 37
  305. code0 {\#include "../non.H"}
  306. }
  307. }
  308. }
  309. Fl_Tabs tabs {
  310. callback {// give this tab's canvas the focus
  311. //if ( o->value() == sequence_tab )
  312. // sequence_canvas_widget->take_focus();
  313. //else
  314. if ( o->value() == phrase_tab )
  315. phrase_canvas_widget->take_focus();
  316. else
  317. if ( o->value() == pattern_tab )
  318. pattern_canvas_widget->take_focus();} open
  319. xywh {0 76 868 701} color 37 labeltype SHADOW_LABEL labelsize 19 when 1
  320. code0 {canvas_background_color = fl_rgb_color( 18, 18, 18 );}
  321. } {
  322. Fl_Group sequence_tab {
  323. label Sequence open
  324. xywh {0 98 868 674} color 37 hide resizable
  325. code0 {update_sequence_widgets();}
  326. } {
  327. Fl_Group {} {open
  328. xywh {10 125 233 502} labelsize 12
  329. } {
  330. Fl_Browser playlist_browser {
  331. label Playlist
  332. xywh {10 125 233 435} type Hold box EMBOSSED_BOX color 39 selection_color 30 labelcolor 55 align 1 when 4 textsize 18 textcolor 95 resizable
  333. code0 {static int widths[] = { 40, 30, 0 };}
  334. code1 {o->column_widths( widths ); o->column_char( '\\t' );}
  335. code2 {o->value( 1 );}
  336. }
  337. Fl_Button sequence_phrase_delete_button {
  338. label Delete
  339. callback {int val = playlist_browser->value();
  340. if ( val > 1 )
  341. {
  342. // playlist_browser->value( playlist_browser->value() + 1 );
  343. playlist->remove( val - 2 );
  344. update_sequence_widgets();
  345. if ( ! playlist_browser->value() )
  346. playlist_browser->value( playlist_browser->size() );
  347. }}
  348. xywh {14 566 73 25} shortcut 0xffff color 88 labelcolor 23
  349. }
  350. Fl_Button sequence_phrase_up_button {
  351. label Up
  352. callback {if ( playlist_browser->value() > 2 )
  353. {
  354. playlist->move( playlist_browser->value() - 2, UP );
  355. playlist_browser->value( playlist_browser->value() - 1 );
  356. update_sequence_widgets();
  357. }}
  358. xywh {97 566 65 25} shortcut 0xffbf
  359. }
  360. Fl_Button sequence_phrase_down_button {
  361. label Down
  362. callback {if ( playlist_browser->value() > 1 )
  363. {
  364. playlist->move( playlist_browser->value() - 2, DOWN );
  365. playlist_browser->value( playlist_browser->value() + 1 );
  366. update_sequence_widgets();
  367. }}
  368. xywh {169 566 74 25} shortcut 0xffc0
  369. }
  370. Fl_Menu_Button sequence_phrase_choice {
  371. label {Insert Phrase}
  372. callback {playlist->insert( playlist_browser->value() - 1, o->value() + 1 );
  373. update_sequence_widgets();
  374. int val = playlist_browser->value();
  375. if ( val )
  376. playlist_browser->value( playlist_browser->value() + 1 );
  377. else
  378. playlist_browser->value( playlist_browser->size() );} open
  379. xywh {11 597 232 30} color 63
  380. } {}
  381. }
  382. Fl_Input sequence_name_field {
  383. label {name:}
  384. callback {playlist->name( o->value() );}
  385. xywh {91 740 158 26} color 36 align 20 when 1 textcolor 32
  386. }
  387. Fl_Light_Button detach_button {
  388. label Detach
  389. callback {if ( o->value() )
  390. {
  391. Fl_Group *g = seq_detached_group;
  392. g->add( sequence_tab );
  393. sequence_tab->resize( g->x(), g->y(), g->w(), g->h() );
  394. seq_window->show();
  395. }
  396. else
  397. {
  398. seq_window->hide();
  399. tabs->insert( (Fl_Widget&)*sequence_tab, 0 );
  400. sequence_tab->resize( pattern_tab->x(), pattern_tab->y(), pattern_tab->w(), pattern_tab->h() );
  401. }}
  402. xywh {7 740 78 26}
  403. }
  404. Fl_Text_Editor sequence_notes_edit {
  405. label {Notes:}
  406. callback {playlist->notes( o->buffer()->text() );}
  407. xywh {254 691 606 73} selection_color 48 labelsize 12 align 5 textcolor 94
  408. code0 {o->buffer( sequence_notes_buffer = new Fl_Text_Buffer );}
  409. }
  410. Fl_Box triggers_widget {
  411. label Patterns
  412. xywh {253 125 607 549} box UP_BOX color 72 align 1 resizable
  413. code0 {o->box( FL_NO_BOX );}
  414. class Triggers
  415. }
  416. Fl_Group progress_group {
  417. callback {if ( ! o->visible_r() )
  418. return;
  419. phrase *p = phrase::phrase_by_number( playlist->playing() );
  420. if ( p )
  421. phrase_progress->value( p->index() / (double)p->length() );
  422. if ( playlist->length() )
  423. sequence_progress->value( playlist->index() / (double)playlist->length() );} open
  424. xywh {10 656 233 66}
  425. } {
  426. Fl_Slider phrase_progress {
  427. label Phrase
  428. xywh {10 656 233 24} type Horizontal labelsize 12 align 1
  429. }
  430. Fl_Slider sequence_progress {
  431. label Sequence
  432. callback {transport.locate( (tick_t)((double)playlist->length() * o->value()) );}
  433. xywh {10 698 233 24} type Horizontal labelsize 12 align 1
  434. }
  435. }
  436. }
  437. Fl_Group phrase_tab {
  438. label Phrase open
  439. xywh {0 98 868 674} color 37 hide
  440. code0 {update_phrase_widgets();}
  441. } {
  442. Fl_Box phrase_canvas_widget {
  443. label Phrase
  444. xywh {4 102 860 590} box FLAT_BOX color 37 labelsize 100 align 16 resizable
  445. code0 {o->set_canvas( phrase_c );}
  446. code1 {o->box( FL_NO_BOX );}
  447. class O_Canvas
  448. }
  449. Fl_Group {} {open
  450. xywh {10 703 854 60}
  451. } {
  452. Fl_Input phrase_name_field {
  453. label {name:}
  454. callback {phrase_c->grid()->name( strdup( o->value() ) );
  455. // if the name changed..
  456. update_sequence_widgets();}
  457. xywh {10 703 144 25} color 36 align 20 textcolor 32
  458. }
  459. Fl_Spinner phrase_number_spinner {
  460. callback {phrase *p = ((phrase *)phrase_c->grid())->by_number( o->value() );
  461. if ( p )
  462. phrase_c->grid( p );
  463. o->maximum( phrase::phrases() );}
  464. xywh {164 703 40 25} color 36 labeltype NO_LABEL when 1
  465. }
  466. Fl_Light_Button phrase_mute_button {
  467. label Mute
  468. xywh {10 740 88 23} color 37 hide
  469. }
  470. Fl_Light_Button phrase_solo_button {
  471. label Solo
  472. xywh {111 740 87 23} color 37 hide
  473. }
  474. Fl_Text_Editor phrase_notes_edit {
  475. label {Notes:}
  476. callback {phrase_c->grid()->notes( o->buffer()->text() );}
  477. xywh {211 713 653 46} selection_color 48 labelsize 12 textcolor 94 resizable
  478. code0 {o->buffer( phrase_notes_buffer = new Fl_Text_Buffer );}
  479. }
  480. }
  481. }
  482. Fl_Group pattern_tab {
  483. label Pattern open
  484. xywh {0 98 868 674} color 37
  485. code0 {update_pattern_widgets();}
  486. } {
  487. Fl_Box pattern_canvas_widget {
  488. label Pattern
  489. xywh {4 102 860 590} box FLAT_BOX color 37 labelsize 100 align 16 resizable
  490. code0 {\#include "draw.H"}
  491. code1 {o->set_canvas( pattern_c );}
  492. code2 {\#include "input.H"}
  493. code3 {o->box( FL_NO_BOX );}
  494. class O_Canvas
  495. }
  496. Fl_Group {} {open
  497. xywh {4 694 858 77}
  498. } {
  499. Fl_Input pattern_name_field {
  500. label {name:}
  501. callback {pattern_c->grid()->name( strdup( o->value() ) );}
  502. xywh {10 703 144 25} color 36 align 20 when 1 textcolor 32
  503. }
  504. Fl_Spinner pattern_number_spinner {
  505. callback {pattern *p = ((pattern *)pattern_c->grid())->by_number( o->value() );
  506. if ( p )
  507. pattern_c->grid( p );
  508. o->maximum( pattern::patterns() );}
  509. xywh {164 703 40 25} color 36 labeltype NO_LABEL when 1
  510. code0 {o->maximum( 1 );}
  511. code1 {// pattern::signal_create_destroy.connect( sigc::mem_fun( o, static_cast<void (Fl_Spinner::*)(double)>(&Fl_Spinner::maximum) ) );}
  512. }
  513. Fl_Light_Button pattern_mute_button {
  514. label Mute
  515. callback {Grid *g = pattern_c->grid();
  516. g->mode( g->mode() == MUTE ? PLAY : MUTE );
  517. o->value( g->mode() == MUTE );
  518. pattern_solo_button->value( 0 );}
  519. xywh {10 738 90 23} type Normal color 37
  520. code0 {// o->type(FL_RADIO_BUTTON);}
  521. }
  522. Fl_Light_Button pattern_solo_button {
  523. label Solo
  524. callback {Grid *g = pattern_c->grid();
  525. g->mode( g->mode() == SOLO ? PLAY : SOLO );
  526. o->value( g->mode() == SOLO );
  527. pattern_mute_button->value( 0 );}
  528. xywh {110 738 91 23} type Normal color 37
  529. code0 {// o->type( FL_RADIO_BUTTON );}
  530. }
  531. Fl_Text_Editor pattern_notes_edit {
  532. label {Notes:}
  533. callback {pattern_c->grid()->notes( o->buffer()->text() );}
  534. xywh {214 713 243 48} selection_color 48 labelsize 12 textcolor 94 resizable
  535. code0 {o->buffer( pattern_notes_buffer = new Fl_Text_Buffer );}
  536. }
  537. Fl_Group pattern_settings_group {open
  538. xywh {458 694 400 77}
  539. } {
  540. Fl_Spinner pattern_channel_spinner {
  541. label Channel
  542. callback {((pattern *)pattern_c->grid())->channel( o->value() - 1 );}
  543. xywh {815 700 40 24} color 36 when 1
  544. code0 {\#include "../pattern.H"}
  545. code1 {o->maximum( 16 );}
  546. }
  547. Fl_Spinner pattern_port_spinner {
  548. label Port
  549. callback {((pattern *)pattern_c->grid())->port( o->value() - 1 );}
  550. xywh {815 734 40 24} color 36 when 1
  551. code0 {o->maximum( 16 );}
  552. }
  553. Fl_Output mapping_text {
  554. label Mapping
  555. xywh {464 734 145 24} align 20
  556. }
  557. Fl_Menu_Button mapping_menu {
  558. label {@>}
  559. callback {mapping_text->value( o->text() );
  560. char picked[80];
  561. mapping_menu->item_pathname(picked, sizeof(picked)-1 );
  562. if ( 0 == strncmp( picked, "Instrument", strlen( "Instrument" ) ) )
  563. {
  564. ((pattern*)pattern_c->grid())->mapping.open( Mapping::INSTRUMENT, o->text() );
  565. pattern_c->changed_mapping();
  566. pattern_key_combo->deactivate();
  567. }
  568. else
  569. if ( 0 == strncmp( picked, "Scale", strlen( "Scale" ) ) )
  570. {
  571. ((pattern*)pattern_c->grid())->mapping.open( Mapping::SCALE, o->text() );
  572. pattern_c->changed_mapping();
  573. pattern_key_combo->activate();
  574. }} open
  575. xywh {609 734 30 24} labeltype NO_LABEL
  576. code0 {update_mapping_menu();}
  577. } {
  578. Submenu mapping_scale_menu {
  579. label Scale open
  580. xywh {25 25 74 25}
  581. } {}
  582. Submenu mapping_instrument_menu {
  583. label Instrument open
  584. xywh {10 10 74 25}
  585. } {}
  586. }
  587. Fl_Choice pattern_key_combo {
  588. label {&Key}
  589. callback {((pattern*)pattern_c->grid())->mapping.key( o->value() );
  590. pattern_c->changed_mapping();}
  591. xywh {674 734 75 24} down_box BORDER_BOX when 1
  592. } {
  593. MenuItem {} {
  594. label C
  595. xywh {30 30 40 25}
  596. }
  597. MenuItem {} {
  598. label {C\#/Db}
  599. xywh {40 40 40 25}
  600. }
  601. MenuItem {} {
  602. label D
  603. xywh {50 50 40 25}
  604. }
  605. MenuItem {} {
  606. label {D\#/Eb}
  607. xywh {60 60 40 25}
  608. }
  609. MenuItem {} {
  610. label E
  611. xywh {70 70 40 25}
  612. }
  613. MenuItem {} {
  614. label F
  615. xywh {80 80 40 25}
  616. }
  617. MenuItem {} {
  618. label {F\#/Gb}
  619. xywh {90 90 40 25}
  620. }
  621. MenuItem {} {
  622. label G
  623. xywh {100 100 40 25}
  624. }
  625. MenuItem {} {
  626. label {G\#}
  627. xywh {110 110 40 25}
  628. }
  629. MenuItem {} {
  630. label A
  631. xywh {0 0 40 25}
  632. }
  633. MenuItem {} {
  634. label {A\#/Bb}
  635. xywh {10 10 40 25}
  636. }
  637. MenuItem {} {
  638. label B
  639. xywh {20 20 40 25}
  640. }
  641. }
  642. Fl_Choice pattern_note_combo {
  643. label {&Note 1/}
  644. callback {((pattern*)pattern_c->grid())->note( atoi( o->menu()[ o->value() ].text ));}
  645. xywh {704 700 45 24} down_box BORDER_BOX when 1
  646. } {
  647. MenuItem {} {
  648. label 1
  649. xywh {0 0 40 25}
  650. }
  651. MenuItem {} {
  652. label 2
  653. xywh {10 10 40 25}
  654. }
  655. MenuItem {} {
  656. label 4
  657. xywh {20 20 40 25}
  658. }
  659. MenuItem {} {
  660. label 8
  661. xywh {30 30 40 25}
  662. }
  663. MenuItem {} {
  664. label 16
  665. xywh {40 40 40 25}
  666. }
  667. MenuItem {} {
  668. label 32
  669. xywh {50 50 40 25}
  670. }
  671. MenuItem {} {
  672. label 64
  673. xywh {60 60 40 25} divider
  674. }
  675. MenuItem {} {
  676. label 3
  677. xywh {60 60 40 25}
  678. }
  679. MenuItem {} {
  680. label 6
  681. xywh {70 70 40 25}
  682. }
  683. MenuItem {} {
  684. label 12
  685. xywh {80 80 40 25}
  686. }
  687. MenuItem {} {
  688. label 24
  689. xywh {90 90 40 25}
  690. }
  691. }
  692. Fl_Choice pattern_res_combo {
  693. label {&Resolution 1/}
  694. callback {pattern_c->grid()->resolution( atoi( o->menu()[ o->value() ].text ));}
  695. xywh {584 700 55 24} down_box BORDER_BOX when 1
  696. } {
  697. MenuItem {} {
  698. label 4
  699. xywh {30 30 40 25}
  700. }
  701. MenuItem {} {
  702. label 8
  703. xywh {40 40 40 25}
  704. }
  705. MenuItem {} {
  706. label 16
  707. xywh {50 50 40 25}
  708. }
  709. MenuItem {} {
  710. label 32
  711. xywh {60 60 40 25}
  712. }
  713. MenuItem {} {
  714. label 64
  715. xywh {80 80 40 25}
  716. }
  717. MenuItem {} {
  718. label 128
  719. xywh {90 90 40 25} divider
  720. }
  721. MenuItem {} {
  722. label 3
  723. xywh {70 70 40 25}
  724. }
  725. MenuItem {} {
  726. label 6
  727. xywh {80 80 40 25}
  728. }
  729. MenuItem {} {
  730. label 12
  731. xywh {90 90 40 25}
  732. }
  733. MenuItem {} {
  734. label 24
  735. xywh {100 100 40 25}
  736. }
  737. }
  738. }
  739. }
  740. }
  741. }
  742. Fl_Group {} {open
  743. xywh {5 33 853 52}
  744. } {
  745. Fl_Choice playback_mode_menu {
  746. label {Playback &Mode} open
  747. xywh {751 54 107 30} box PLASTIC_DOWN_BOX down_box BORDER_BOX color 37 align 1
  748. } {
  749. MenuItem {} {
  750. label Pattern
  751. callback {song.play_mode = PATTERN;}
  752. xywh {0 0 40 25}
  753. }
  754. MenuItem {} {
  755. label Sequence
  756. callback {song.play_mode = SEQUENCE;}
  757. xywh {10 10 40 25}
  758. }
  759. MenuItem {} {
  760. label Trigger
  761. callback {song.play_mode = TRIGGER;}
  762. xywh {20 20 40 25}
  763. }
  764. }
  765. Fl_Choice record_mode_menu {
  766. label {&Record Mode}
  767. callback {if ( ! transport.recording )
  768. config.record_mode = (record_mode_e)o->value();
  769. else
  770. o->value( config.record_mode );} open
  771. xywh {634 54 107 30} box PLASTIC_DOWN_BOX down_box BORDER_BOX color 37 align 1
  772. } {
  773. MenuItem {} {
  774. label Merge
  775. xywh {10 10 40 25}
  776. }
  777. MenuItem {} {
  778. label Overwrite
  779. xywh {20 20 40 25}
  780. }
  781. MenuItem {} {
  782. label Layer
  783. xywh {30 30 40 25}
  784. }
  785. MenuItem {} {
  786. label New
  787. xywh {40 40 40 25}
  788. }
  789. }
  790. Fl_Pack vmetro_widget {
  791. label Metronome open
  792. xywh {226 37 245 48} type HORIZONTAL box UP_BOX color 40 selection_color 48 labelsize 33 align 0 resizable
  793. code0 {\#include "widgets.H"}
  794. code1 {o->box( FL_NO_BOX );}
  795. class Visual_Metronome
  796. } {}
  797. Fl_Group transport_controls_group {
  798. xywh {481 37 143 48}
  799. } {
  800. Fl_Button play_button {
  801. label {@>}
  802. callback {transport.toggle();}
  803. xywh {531 43 34 35} shortcut 0x20 labeltype ENGRAVED_LABEL
  804. }
  805. Fl_Button rec_button {
  806. label {@circle}
  807. callback {transport.recording = o->value();
  808. if ( o->value() )
  809. {
  810. if ( config.record_mode == NEW )
  811. {
  812. pattern *p = new pattern;
  813. p->length( -1 );
  814. pattern_c->grid( p );
  815. }
  816. ((pattern*)pattern_c->grid())->record( 0 );
  817. o->labelcolor( FL_RED );
  818. }
  819. else
  820. {
  821. pattern::recording()->record_stop();
  822. o->labelcolor( FL_WHITE );
  823. }}
  824. xywh {575 43 49 35} type Toggle shortcut 0x80072 selection_color 47 labeltype ENGRAVED_LABEL when 1
  825. }
  826. Fl_Button home_button {
  827. label {@|<}
  828. callback {transport.locate( 0 );}
  829. xywh {481 43 40 35} shortcut 0xff50 labeltype ENGRAVED_LABEL
  830. }
  831. }
  832. Fl_Group {} {open
  833. xywh {5 33 208 38}
  834. } {
  835. Fl_Box {} {
  836. label {BPM:}
  837. xywh {5 37 35 34}
  838. }
  839. Fl_Counter {} {
  840. callback {transport.set_beats_per_minute( o->value() );}
  841. xywh {43 41 97 24} labeltype NO_LABEL align 4
  842. code1 {transport.signal_tempo_change.connect( sigc::mem_fun( o, static_cast<int (Fl_Counter::*)(double)>(&Fl_Counter::value) ) );}
  843. code2 {o->value( transport.beats_per_minute );}
  844. }
  845. Fl_Value_Input {} {
  846. callback {transport.set_beats_per_bar( o->value() );}
  847. xywh {149 41 26 24}
  848. code0 {transport.signal_bpb_change.connect( sigc::mem_fun( o, static_cast<int (Fl_Valuator::*)(double)>(&Fl_Valuator::value) ) );}
  849. code1 {o->value( transport.beats_per_bar );}
  850. }
  851. Fl_Value_Input {} {
  852. callback {transport.set_beat_type( o->value() );}
  853. xywh {189 41 24 24}
  854. code0 {transport.signal_beat_change.connect( sigc::mem_fun( o, static_cast<int (Fl_Valuator::*)(double)>(&Fl_Valuator::value) ) );}
  855. code1 {o->value( transport.beat_type );}
  856. }
  857. Fl_Box {} {
  858. label {/}
  859. xywh {170 41 19 24}
  860. }
  861. }
  862. }
  863. Fl_Output status {
  864. xywh {3 776 861 21} box NO_BOX color 32 labeltype NO_LABEL textcolor 55
  865. }
  866. }
  867. }
  868. Function {make_seq_window()} {} {
  869. Fl_Window seq_window {
  870. callback {sequence_tab->activate();
  871. o->hide();
  872. detach_button->value( 0 );}
  873. xywh {189 27 1278 1003} type Single hide resizable
  874. } {
  875. Fl_Group seq_detached_group {open
  876. xywh {0 0 1277 1003} resizable
  877. } {}
  878. }
  879. }
  880. Function {make_about_popup()} {} {
  881. Fl_Window about_popup {
  882. label About open
  883. xywh {944 405 539 608} type Single non_modal size_range {539 608 539 608} visible
  884. } {
  885. Fl_Box {} {
  886. label VERSION
  887. image {../logo.xpm} xywh {10 29 525 209}
  888. code0 {o->label( VERSION );}
  889. }
  890. Fl_Group {} {open
  891. xywh {26 272 488 272} box ROUNDED_BOX color 51
  892. } {
  893. Fl_Box {} {
  894. label {Copyright (C) 2007-2008 Jonathan Moore Liles}
  895. xywh {26 272 488 32} labeltype SHADOW_LABEL labelfont 1 labelsize 18
  896. }
  897. Fl_Box {} {
  898. label {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.
  899. 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.
  900. 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.}
  901. xywh {41 311 463 233} labelfont 1 labelsize 12 align 144
  902. }
  903. }
  904. Fl_Button {} {
  905. label {http://non.tuxfamily.org}
  906. callback {system( "x-www-browser http://non.tuxfamily.org &" );}
  907. xywh {178 554 188 30} color 14 labeltype SHADOW_LABEL labelcolor 6
  908. }
  909. Fl_Return_Button {} {
  910. label rock
  911. callback {about_popup->hide();}
  912. xywh {453 570 78 31}
  913. }
  914. }
  915. }
  916. Function {make_randomization_dialog()} {} {
  917. Fl_Window randomization_dialog {
  918. label {Randomization Settings} open
  919. xywh {656 39 342 98} type Double
  920. code0 {// feel->value( )}
  921. code1 {probability->value( song.random.probability );} non_modal visible
  922. } {
  923. Fl_Choice feel {
  924. label {Feel: 1/}
  925. callback {song.random.feel = atoi( o->menu()[ find_numeric_menu_item( o->menu(), o->value() ) ].text );} open
  926. xywh {67 55 50 24} down_box BORDER_BOX
  927. } {
  928. MenuItem {} {
  929. label 4
  930. xywh {10 10 40 25}
  931. }
  932. MenuItem {} {
  933. label 8
  934. xywh {0 0 40 25}
  935. }
  936. MenuItem {} {
  937. label 16
  938. xywh {10 10 40 25}
  939. }
  940. }
  941. Fl_Box {} {
  942. label {Randomization Settings}
  943. xywh {10 15 321 28} box ROUNDED_BOX color 94 labelsize 22 labelcolor 39
  944. }
  945. Fl_Counter probability {
  946. label Probability
  947. callback {song.random.probability = o->value();}
  948. xywh {216 53 112 26} type Simple align 4 when 4 minimum 0 maximum 1 step 0.01
  949. }
  950. }
  951. }
  952. Function {update_pattern_widgets()} {open
  953. } {
  954. code {if ( ! pattern_settings_group )
  955. return;
  956. pattern *g = (pattern *)pattern_c->grid();
  957. pattern_number_spinner->value( g->number() );
  958. pattern_name_field->value( g->name() );
  959. pattern_channel_spinner->value( 1 + g->channel() );
  960. pattern_port_spinner->value( 1 + g->port() );
  961. pattern_solo_button->value( g->mode() == SOLO );
  962. pattern_mute_button->value( g->mode() == MUTE );
  963. if ( g->mapping.key() == -1 )
  964. pattern_key_combo->deactivate();
  965. else
  966. {
  967. pattern_key_combo->activate();
  968. pattern_key_combo->value( g->mapping.key() );
  969. }
  970. mapping_text->value( g->mapping.name() );
  971. pattern_note_combo->value( find_numeric_menu_item( menu_pattern_note_combo, g->note() ));
  972. pattern_res_combo->value( find_numeric_menu_item( menu_pattern_res_combo, g->resolution() ));
  973. if ( g->notes() )
  974. pattern_notes_buffer->text( g->notes() );
  975. else
  976. pattern_notes_buffer->text( strdup( "" ) );} {}
  977. }
  978. Function {update_phrase_widgets()} {} {
  979. code {phrase *g = (phrase *)phrase_c->grid();
  980. if ( ! g )
  981. return;
  982. phrase_number_spinner->value( g->number() );
  983. phrase_name_field->value( g->name() );
  984. phrase_solo_button->value( g->mode() == SOLO );
  985. phrase_mute_button->value( g->mode() == MUTE );
  986. if ( g->notes() )
  987. phrase_notes_buffer->text( g->notes() );
  988. else
  989. phrase_notes_buffer->text( strdup( "" ) );} {}
  990. }
  991. Function {update_sequence_widgets()} {open
  992. } {
  993. code {if ( playlist->notes() )
  994. sequence_notes_buffer->text( playlist->notes() );
  995. else
  996. sequence_notes_buffer->text( strdup( "" ) );
  997. sequence_name_field->value( playlist->name() );
  998. sequence_phrase_choice->clear();
  999. for ( int i = 1; i <= phrase::phrases(); i++ )
  1000. {
  1001. phrase *p = phrase::phrase_by_number( i );
  1002. if ( p )
  1003. sequence_phrase_choice->add( p->name() );
  1004. }
  1005. Fl_Browser *o = playlist_browser;
  1006. int val = o->value();
  1007. o->clear();
  1008. char *s = playlist->dump();
  1009. char *l = strtok( s, "\\n" );
  1010. o->add( "@b@C2Bar\\t@b@C2\#\\t@b@C2Name" );
  1011. if ( ! l )
  1012. return;
  1013. o->add( l );
  1014. while ( ( l = strtok( NULL, "\\n" ) ) )
  1015. {
  1016. o->add( l );
  1017. }
  1018. o->value( val );
  1019. free( s );} {}
  1020. }
  1021. Function {update_mapping_menu()} {open
  1022. } {
  1023. code {char **sa = Instrument::listing();
  1024. if ( sa )
  1025. {
  1026. for ( int i = 0; sa[i]; i++ )
  1027. {
  1028. char pat[512];
  1029. snprintf( pat, 512, "Instrument/%s", sa[i] );
  1030. mapping_menu->add( pat, 0, 0, 0, 0 );
  1031. free( sa[i] );
  1032. }
  1033. free( sa );
  1034. }
  1035. sa = Scale::listing();
  1036. for ( int i = 0; sa[i]; i++ )
  1037. {
  1038. char pat[512];
  1039. snprintf( pat, 512, "Scale/%s", sa[i] );
  1040. mapping_menu->add( pat, 0, 0, 0, 0 );
  1041. free( sa[i] );
  1042. }
  1043. free( sa );} {}
  1044. }
  1045. Function {update_canvas_widgets()} {return_type {static void}
  1046. } {
  1047. code {if ( pattern_c->grid() )
  1048. ui->update_pattern_widgets();
  1049. if ( phrase_c->grid() )
  1050. ui->update_phrase_widgets();} {}
  1051. }
  1052. Function {find_numeric_menu_item( const Fl_Menu_Item *menu, int n )} {return_type {static int}
  1053. } {
  1054. code {for ( unsigned int i = 0; menu[i].text; i++ )
  1055. {
  1056. if ( atoi( menu[i].text ) == n )
  1057. return i;
  1058. }
  1059. return 0;} {}
  1060. }
  1061. Function {save_dialog( const char *name )} {return_type void
  1062. } {
  1063. code {if ( ! name )
  1064. {
  1065. Fl_File_Chooser *fc = new Fl_File_Chooser( ".", "Non Sequences (*.non)", Fl_File_Chooser::CREATE, "Save sequence" );
  1066. fc->show();
  1067. // wait for user to make a choice
  1068. while( fc->shown() )
  1069. Fl::wait();
  1070. if ( ! fc->value() )
  1071. return;
  1072. name = fc->value();
  1073. }
  1074. if ( ! save_song( name ) )
  1075. fl_alert( "Could not save song" );} {}
  1076. }
  1077. Function {show_help_dialog( const char *file )} {return_type void
  1078. } {
  1079. code {char pat[256];
  1080. snprintf( pat, 256, "%s%s.html", DOCUMENT_PATH, file );
  1081. Fl_Help_Dialog *help; // Help dialog
  1082. help = new Fl_Help_Dialog;
  1083. help->load( pat );
  1084. help->show();
  1085. // FIXME: need to delete it somehow.
  1086. // help->show(1, argv);} {}
  1087. }
  1088. Function {maybe_save_song()} {return_type bool
  1089. } {
  1090. code {if ( song.dirty )
  1091. {
  1092. int c = fl_choice( "Song has been modified since last save. What shall I do?", "Cancel", "Save", "Discard" );
  1093. switch ( c )
  1094. {
  1095. case 0:
  1096. return false;
  1097. case 1:
  1098. /* SAVE */
  1099. save_dialog( song.filename );
  1100. break;
  1101. case 2:
  1102. break;
  1103. }
  1104. }
  1105. return true;} {}
  1106. }
  1107. Function {switch_to_pattern( int n )} {return_type void
  1108. } {
  1109. code {pattern *p = pattern::pattern_by_number( n );
  1110. if ( p )
  1111. {
  1112. tabs->value( pattern_tab );
  1113. pattern_canvas_widget->take_focus();
  1114. pattern_c->grid( p );
  1115. // update_pattern_widgets();
  1116. }} {}
  1117. }
  1118. Function {edit_instrument_row( Instrument *i, int n )} {open return_type void
  1119. } {
  1120. code {Instrument_Editor ie;
  1121. ie.set( i, n );
  1122. ie.run();} {}
  1123. }
  1124. }
  1125. decl {\#include <Fl/Fl_Single_Window.H>} {public
  1126. }
  1127. class O_Canvas {open : {public Fl_Widget}
  1128. } {
  1129. decl {Canvas *_c;} {}
  1130. decl {bool _border_drawn;} {}
  1131. decl {uint _flags;} {}
  1132. Function {O_Canvas( int X, int Y, int W, int H, const char*L=0) : Fl_Widget(X,Y,W,H,L)} {open
  1133. } {
  1134. code {_c = NULL;
  1135. _border_drawn = false;
  1136. _flags = 0;} {}
  1137. }
  1138. Function {handle( int m )} {open return_type int
  1139. } {
  1140. code {// Accept focus if offered.
  1141. if ( m == FL_FOCUS || m == FL_UNFOCUS )
  1142. {
  1143. _border_drawn = false;
  1144. draw_playhead();
  1145. return 1;
  1146. }
  1147. // Hack in click-to-focus
  1148. if ( m == FL_PUSH )
  1149. if ( Fl::event_inside( this ) )
  1150. take_focus();
  1151. // Ignore events unless we have the focus.
  1152. if ( this != Fl::focus() )
  1153. return 0;
  1154. // MESSAGE( "got event %i for canvas %p", m, _c );
  1155. int p = 0;
  1156. if ( _c )
  1157. {
  1158. p = canvas_input_callback( this, _c, m );
  1159. }
  1160. return p;} {}
  1161. }
  1162. Function {resize( int x, int y, int w, int h )} {open
  1163. } {
  1164. code {if ( _c )
  1165. {
  1166. DEBUG( "Resizing canvas." );
  1167. _c->resize( x + 1, y + 1, w - 1, h - 1 );
  1168. }
  1169. Fl_Widget::resize( x, y, w, h );
  1170. // Fl_Window::resize( x, y, w, h );} {}
  1171. }
  1172. Function {draw()} {open return_type void
  1173. } {
  1174. code {draw_border();
  1175. if ( ! takesevents() )
  1176. return;
  1177. if ( _c )
  1178. {
  1179. damage( _flags );
  1180. _flags = 0;
  1181. /*
  1182. if ( damage() & FL_DAMAGE_ALL ) printf( " damage_all" );
  1183. if ( damage() & FL_DAMAGE_SCROLL ) printf( " damage_scroll" );
  1184. if ( damage() & FL_DAMAGE_USER1 ) printf( " damage_user1" );
  1185. if ( damage() & FL_DAMAGE_USER2 ) printf( " damage_user2" );
  1186. if ( damage() & FL_DAMAGE_EXPOSE ) printf( " damage_expose" );
  1187. printf("\\n");
  1188. */
  1189. if ( damage() & (FL_DAMAGE_ALL | FL_DAMAGE_USER2) )
  1190. {
  1191. _c->redraw();
  1192. }
  1193. if ( damage() & (FL_DAMAGE_ALL | FL_DAMAGE_SCROLL) )
  1194. {
  1195. // optimized draw
  1196. _c->draw();
  1197. }
  1198. else
  1199. if ( damage() & (FL_DAMAGE_ALL | FL_DAMAGE_USER1) )
  1200. {
  1201. // playhead
  1202. _c->draw_playhead();
  1203. }
  1204. else
  1205. if ( damage() & FL_DAMAGE_ALL )
  1206. {
  1207. _border_drawn = false;
  1208. draw_border();
  1209. _c->redraw();
  1210. }
  1211. }
  1212. else
  1213. {
  1214. WARNING( "No canvas set for widget." );
  1215. }} {}
  1216. }
  1217. Function {set_canvas( Canvas *c )} {open
  1218. } {
  1219. code {_c = c;
  1220. _c->resize( x(), y(), w(), h() );
  1221. _c->signal_draw.connect( sigc::mem_fun( this, &O_Canvas::draw_notes ) );
  1222. _c->signal_resize.connect( sigc::mem_fun( this, &O_Canvas::clear ) );
  1223. _c->signal_settings_change.connect( sigc::ptr_fun( &UI::update_canvas_widgets ) );} {}
  1224. }
  1225. Function {click_to_focus()} {open return_type bool
  1226. } {
  1227. code {return true;} {}
  1228. }
  1229. Function {clear( void )} {open return_type void
  1230. } {
  1231. code {parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );
  1232. damage( FL_DAMAGE_USER2 );
  1233. _flags |= FL_DAMAGE_USER2;} {}
  1234. }
  1235. Function {draw_notes( void )} {open return_type void
  1236. } {
  1237. code {damage( FL_DAMAGE_SCROLL );
  1238. // this might be called from within draw(), in which case the above does nothing.
  1239. _flags |= FL_DAMAGE_SCROLL;} {}
  1240. }
  1241. Function {draw_playhead( void )} {open return_type void
  1242. } {
  1243. code {damage( FL_DAMAGE_USER1 );} {}
  1244. }
  1245. Function {draw_border()} {open return_type void
  1246. } {
  1247. code {if ( _border_drawn )
  1248. return;
  1249. if ( this != Fl::focus() )
  1250. fl_color( FL_RED );
  1251. else
  1252. fl_color( FL_BLACK );
  1253. fl_line_style( FL_DASH );
  1254. fl_rect( x(), y(), w(), h() );
  1255. fl_line_style( FL_SOLID );
  1256. _border_drawn = true;} {}
  1257. }
  1258. }
  1259. Function {shortcut_handler( int e )} {open return_type int
  1260. } {
  1261. code {if ( e != FL_SHORTCUT )
  1262. return 0;
  1263. // this is for mainwindow shortcuts only, ignore all other windows.
  1264. if ( Fl::first_window() != ui->main_window )
  1265. return 0;
  1266. int processed = 0;
  1267. // shortcuts that don't fit anywhere else (widgets that don't take shortcuts, etc.)
  1268. \#define KEY(key) ((Fl::test_shortcut( (key) )))
  1269. processed = 1;
  1270. if KEY( FL_ALT + 's' )
  1271. {
  1272. ui->tabs->value( ui->sequence_tab );
  1273. }
  1274. else
  1275. if KEY( FL_ALT + 'a' )
  1276. {
  1277. ui->tabs->value( ui->phrase_tab );
  1278. ((Fl_Group*)ui->tabs->value())->child( 0 )->take_focus();
  1279. }
  1280. else
  1281. if KEY( FL_ALT + 'p' )
  1282. {
  1283. ui->tabs->value( ui->pattern_tab );
  1284. ((Fl_Group*)ui->tabs->value())->child( 0 )->take_focus();
  1285. }
  1286. else
  1287. if KEY( FL_ALT + 'c' )
  1288. ui->pattern_channel_spinner->take_focus();
  1289. else
  1290. if KEY( FL_ALT + 'o' )
  1291. ui->pattern_port_spinner->take_focus();
  1292. else
  1293. if KEY( FL_ALT + 'i' )
  1294. ui->mapping_menu->take_focus();
  1295. else
  1296. processed = 0;
  1297. return processed;} {}
  1298. }
  1299. class Trigger {open : {public Fl_Dial}
  1300. } {
  1301. Function {Trigger( int X, int Y, int W, int H, const char *L = 0 ) : Fl_Dial( X, Y, W, H, L )} {open
  1302. } {}
  1303. Function {handle( int m )} {open return_type int
  1304. } {
  1305. code {int r = 0;
  1306. switch ( m )
  1307. {
  1308. case FL_PUSH:
  1309. {
  1310. switch ( Fl::event_button() )
  1311. {
  1312. case 1:
  1313. {
  1314. pattern *p = pattern::pattern_by_number( atoi( label() ) );
  1315. if ( p )
  1316. {
  1317. if ( p->mode() == MUTE )
  1318. p->mode( PLAY );
  1319. else
  1320. p->mode( MUTE );
  1321. }
  1322. break;
  1323. }
  1324. case 2:
  1325. {
  1326. pattern *p = pattern::pattern_by_number( atoi( label() ) );
  1327. if ( p )
  1328. {
  1329. if ( p->mode() != SOLO )
  1330. p->mode( SOLO );
  1331. else
  1332. p->mode( PLAY );
  1333. }
  1334. break;
  1335. }
  1336. case 3:
  1337. {
  1338. ui->switch_to_pattern( atoi( label() ) );
  1339. }
  1340. break;
  1341. }
  1342. r = 1;
  1343. break;
  1344. }
  1345. case FL_RELEASE:
  1346. MESSAGE("doing callback");
  1347. do_callback();
  1348. r = 1;
  1349. break;
  1350. case FL_DRAG:
  1351. r = 1;
  1352. break;
  1353. default:
  1354. r = Fl_Widget::handle( m );
  1355. break;
  1356. }
  1357. return r;} {}
  1358. }
  1359. }
  1360. class Instrument_Editor {open
  1361. } {
  1362. Function {Instrument_Editor()} {open return_type void
  1363. } {
  1364. code {make_window();} {}
  1365. }
  1366. decl {Instrument *_inst;} {}
  1367. decl {int _note;} {}
  1368. Function {make_window()} {open
  1369. } {
  1370. Fl_Window window {
  1371. label {Instrument Editor}
  1372. callback {done->do_callback();} open
  1373. xywh {670 458 339 191} type Double visible
  1374. } {
  1375. Fl_Box {} {
  1376. label {Instrument Row}
  1377. xywh {8 15 321 28} box ROUNDED_BOX color 94 labelsize 22 labelcolor 39
  1378. }
  1379. Fl_Input name_field {
  1380. label Name
  1381. callback {_inst->note_name( _note, strdup( o->value() ) );}
  1382. xywh {10 70 321 25} selection_color 48 align 1 when 1 textcolor 32
  1383. }
  1384. Fl_Value_Slider volume_slider {
  1385. label {Volume %}
  1386. callback {_inst->velocity( _note, o->value() );}
  1387. xywh {10 112 321 27} type Horizontal align 1 maximum 100 step 1 textsize 14
  1388. }
  1389. Fl_Value_Output note_field {
  1390. label {Note:}
  1391. xywh {52 158 43 24}
  1392. }
  1393. Fl_Return_Button done {
  1394. label Done
  1395. callback {if ( _inst )
  1396. _inst->save();
  1397. window->hide();}
  1398. xywh {255 157 76 25}
  1399. }
  1400. }
  1401. }
  1402. Function {set( Instrument *i, int n )} {open return_type void
  1403. } {
  1404. code {_inst = i;
  1405. _note = n;
  1406. volume_slider->value( i->velocity( n ) );
  1407. name_field->value( i->note_name( n ) );
  1408. note_field->value( n );} {}
  1409. }
  1410. Function {run()} {open return_type void
  1411. } {
  1412. code {window->show();
  1413. while ( window->shown() )
  1414. Fl::wait();} {}
  1415. }
  1416. }
  1417. widget_class Triggers {
  1418. xywh {121 31 1278 1003} type Double hide resizable
  1419. code0 {populate();}
  1420. code1 {\#include <Fl/Fl_Dial.H>}
  1421. class Fl_Group
  1422. } {
  1423. Fl_Pack rows {open
  1424. xywh {25 25 15 15}
  1425. code0 {// o->position( x(), y() );}
  1426. } {}
  1427. Function {populate( void )} {open private return_type void
  1428. } {
  1429. code {int bw = (w() / 16);
  1430. int bh = h() / (128/ 16);
  1431. begin();
  1432. for ( int n = 0; n < 128 ; n += 16 )
  1433. {
  1434. Fl_Pack *p = new Fl_Pack( 0, 0, 25, 25 );
  1435. p->type( Fl_Pack::HORIZONTAL );
  1436. for ( int i = 0; i < 16; i++ )
  1437. {
  1438. Trigger *b = new Trigger( 0, 0, bw, 50, "Num" );
  1439. char pat[4];
  1440. sprintf( pat, "%d", n + i + 1 );
  1441. b->label( strdup( pat ) );
  1442. b->minimum( 0 );
  1443. b->maximum( 1 );
  1444. b->angles( 0, 360 );
  1445. b->type( FL_FILL_DIAL );
  1446. // b->box( FL_ROUNDED_BOX );
  1447. // b->down_box( FL_ROUNDED_BOX );
  1448. b->selection_color( FL_GREEN );
  1449. b->color( FL_BLACK );
  1450. b->align( FL_ALIGN_CENTER );
  1451. p->add( b );
  1452. }
  1453. p->end();
  1454. p->resize( 0, 0, w(), bh );
  1455. rows->add( p );
  1456. }
  1457. end();
  1458. rows->resize( x(), y(), w(), h() );
  1459. redraw();} {}
  1460. }
  1461. Function {update( void )} {open return_type void
  1462. } {
  1463. code {if ( ! takesevents() )
  1464. return;
  1465. int i;
  1466. for ( i = 0; i < MAX_PATTERN; i++ )
  1467. {
  1468. Trigger *b = (Trigger*)(((Fl_Pack*)rows->child( i / 16 ))->child( i % 16 ));
  1469. if ( i >= pattern::patterns() )
  1470. {
  1471. b->color( FL_BLACK );
  1472. b->value( 0 );
  1473. continue;
  1474. }
  1475. pattern *p = pattern::pattern_by_number( i + 1 );
  1476. if ( p->playing() )
  1477. {
  1478. b->color( fl_lighter( FL_GRAY ) );
  1479. Fl_Color c;
  1480. switch ( p->mode() )
  1481. {
  1482. case MUTE:
  1483. c = FL_GRAY;
  1484. break;
  1485. case SOLO:
  1486. c = FL_RED;
  1487. break;
  1488. case PLAY:
  1489. c = FL_GREEN;
  1490. break;
  1491. }
  1492. b->selection_color( c );
  1493. b->value( (double)p->index() / p->length() );
  1494. }
  1495. else
  1496. {
  1497. b->value( 0 );
  1498. }
  1499. }} {}
  1500. }
  1501. Function {resize( int X, int Y, int W, int H )} {open return_type void
  1502. } {
  1503. code {for ( int i = rows->children(); i--; )
  1504. {
  1505. Fl_Pack *p = (Fl_Pack*) rows->child( i );
  1506. for ( int j = p->children(); j--; )
  1507. {
  1508. int bw = W / p->children();
  1509. p->child( j )->resize( 0, 0, bw, 25 );;
  1510. }
  1511. p->resize( 0, 0, W, H / rows->children() );
  1512. p->redraw();
  1513. }
  1514. Fl_Group::resize( X, Y, W, H );} {}
  1515. }
  1516. }