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.

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