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.

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