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.

1770 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 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. 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 {
  859. xywh {0 776 869 25} box UP_BOX color 32 labeltype NO_LABEL textcolor 55
  860. }
  861. }
  862. }
  863. Function {make_seq_window()} {open
  864. } {
  865. Fl_Window seq_window {
  866. label {Non Sequencer - Sequence}
  867. callback {sequence_tab->activate();
  868. o->hide();
  869. detach_button->value( 0 );} open
  870. xywh {681 189 876 675} type Double resizable visible
  871. } {
  872. Fl_Group seq_detached_group {open selected
  873. xywh {0 0 876 675} resizable
  874. } {}
  875. }
  876. }
  877. Function {make_about_popup()} {} {
  878. Fl_Window about_popup {
  879. label About open
  880. xywh {944 405 539 608} type Single non_modal size_range {539 608 539 608} visible
  881. } {
  882. Fl_Box {} {
  883. label VERSION
  884. image {../logo.xpm} xywh {10 29 525 209}
  885. code0 {o->label( VERSION );}
  886. }
  887. Fl_Group {} {open
  888. xywh {26 272 488 272} box ROUNDED_BOX color 51
  889. } {
  890. Fl_Box {} {
  891. label {Copyright (C) 2007-2008 Jonathan Moore Liles}
  892. xywh {26 272 488 32} labeltype SHADOW_LABEL labelfont 1 labelsize 18
  893. }
  894. Fl_Box {} {
  895. 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.
  896. 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.
  897. 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.}
  898. xywh {41 311 463 233} labelfont 1 labelsize 12 align 144
  899. }
  900. }
  901. Fl_Button {} {
  902. label {http://non.tuxfamily.org}
  903. callback {system( "x-www-browser http://non.tuxfamily.org &" );}
  904. xywh {178 554 188 30} color 14 labeltype SHADOW_LABEL labelcolor 6
  905. }
  906. Fl_Return_Button {} {
  907. label rock
  908. callback {about_popup->hide();}
  909. xywh {453 570 78 31}
  910. }
  911. }
  912. }
  913. Function {make_randomization_dialog()} {} {
  914. Fl_Window randomization_dialog {
  915. label {Randomization Settings} open
  916. xywh {656 39 342 98} type Double
  917. code0 {// feel->value( )}
  918. code1 {probability->value( song.random.probability );} non_modal visible
  919. } {
  920. Fl_Choice feel {
  921. label {Feel: 1/}
  922. callback {song.random.feel = atoi( o->menu()[ find_numeric_menu_item( o->menu(), o->value() ) ].text );} open
  923. xywh {67 55 50 24} down_box BORDER_BOX
  924. } {
  925. MenuItem {} {
  926. label 4
  927. xywh {10 10 40 25}
  928. }
  929. MenuItem {} {
  930. label 8
  931. xywh {0 0 40 25}
  932. }
  933. MenuItem {} {
  934. label 16
  935. xywh {10 10 40 25}
  936. }
  937. }
  938. Fl_Box {} {
  939. label {Randomization Settings}
  940. xywh {10 15 321 28} box ROUNDED_BOX color 94 labelsize 22 labelcolor 39
  941. }
  942. Fl_Counter probability {
  943. label Probability
  944. callback {song.random.probability = o->value();}
  945. xywh {216 53 112 26} type Simple align 4 when 4 minimum 0 maximum 1 step 0.01
  946. }
  947. }
  948. }
  949. Function {update_pattern_widgets()} {open
  950. } {
  951. code {if ( ! pattern_settings_group )
  952. return;
  953. pattern *g = (pattern *)pattern_c->grid();
  954. pattern_number_spinner->value( g->number() );
  955. pattern_name_field->value( g->name() );
  956. pattern_channel_spinner->value( 1 + g->channel() );
  957. pattern_port_spinner->value( 1 + g->port() );
  958. pattern_solo_button->value( g->mode() == SOLO );
  959. pattern_mute_button->value( g->mode() == MUTE );
  960. if ( g->mapping.key() == -1 )
  961. pattern_key_combo->deactivate();
  962. else
  963. {
  964. pattern_key_combo->activate();
  965. pattern_key_combo->value( g->mapping.key() );
  966. }
  967. mapping_text->value( g->mapping.name() );
  968. pattern_note_combo->value( find_numeric_menu_item( menu_pattern_note_combo, g->note() ));
  969. pattern_res_combo->value( find_numeric_menu_item( menu_pattern_res_combo, g->resolution() ));
  970. if ( g->notes() )
  971. pattern_notes_buffer->text( g->notes() );
  972. else
  973. pattern_notes_buffer->text( strdup( "" ) );} {}
  974. }
  975. Function {update_phrase_widgets()} {} {
  976. code {phrase *g = (phrase *)phrase_c->grid();
  977. if ( ! g )
  978. return;
  979. phrase_number_spinner->value( g->number() );
  980. phrase_name_field->value( g->name() );
  981. phrase_solo_button->value( g->mode() == SOLO );
  982. phrase_mute_button->value( g->mode() == MUTE );
  983. if ( g->notes() )
  984. phrase_notes_buffer->text( g->notes() );
  985. else
  986. phrase_notes_buffer->text( strdup( "" ) );} {}
  987. }
  988. Function {update_sequence_widgets()} {open
  989. } {
  990. code {if ( playlist->notes() )
  991. sequence_notes_buffer->text( playlist->notes() );
  992. else
  993. sequence_notes_buffer->text( strdup( "" ) );
  994. sequence_name_field->value( playlist->name() );
  995. sequence_phrase_choice->clear();
  996. for ( int i = 1; i <= phrase::phrases(); i++ )
  997. {
  998. phrase *p = phrase::phrase_by_number( i );
  999. if ( p )
  1000. sequence_phrase_choice->add( p->name() );
  1001. }
  1002. Fl_Browser *o = playlist_browser;
  1003. int val = o->value();
  1004. o->clear();
  1005. char *s = playlist->dump();
  1006. char *l = strtok( s, "\\n" );
  1007. o->add( "@b@C2Bar\\t@b@C2\#\\t@b@C2Name" );
  1008. if ( ! l )
  1009. return;
  1010. o->add( l );
  1011. while ( ( l = strtok( NULL, "\\n" ) ) )
  1012. {
  1013. o->add( l );
  1014. }
  1015. o->value( val );
  1016. free( s );
  1017. if ( playback_mode_menu )
  1018. playback_mode_menu->value( song.play_mode );} {}
  1019. }
  1020. Function {update_mapping_menu()} {open
  1021. } {
  1022. code {char **sa = Instrument::listing();
  1023. if ( sa )
  1024. {
  1025. for ( int i = 0; sa[i]; i++ )
  1026. {
  1027. char pat[512];
  1028. snprintf( pat, 512, "Instrument/%s", sa[i] );
  1029. mapping_menu->add( pat, 0, 0, 0, 0 );
  1030. free( sa[i] );
  1031. }
  1032. free( sa );
  1033. }
  1034. sa = Scale::listing();
  1035. for ( int i = 0; sa[i]; i++ )
  1036. {
  1037. char pat[512];
  1038. snprintf( pat, 512, "Scale/%s", sa[i] );
  1039. mapping_menu->add( pat, 0, 0, 0, 0 );
  1040. free( sa[i] );
  1041. }
  1042. free( sa );} {}
  1043. }
  1044. Function {update_canvas_widgets()} {return_type {static void}
  1045. } {
  1046. code {if ( pattern_c->grid() )
  1047. ui->update_pattern_widgets();
  1048. if ( phrase_c->grid() )
  1049. ui->update_phrase_widgets();} {}
  1050. }
  1051. Function {find_numeric_menu_item( const Fl_Menu_Item *menu, int n )} {return_type {static int}
  1052. } {
  1053. code {for ( unsigned int i = 0; menu[i].text; i++ )
  1054. {
  1055. if ( atoi( menu[i].text ) == n )
  1056. return i;
  1057. }
  1058. return 0;} {}
  1059. }
  1060. Function {save_dialog( const char *name )} {open return_type void
  1061. } {
  1062. code {if ( ! name )
  1063. {
  1064. Fl_File_Chooser *fc = new Fl_File_Chooser( ".", "Non Sequences (*.non)", Fl_File_Chooser::CREATE, "Save sequence" );
  1065. fc->show();
  1066. // wait for user to make a choice
  1067. while( fc->shown() )
  1068. Fl::wait();
  1069. if ( ! fc->value() )
  1070. return;
  1071. name = fc->value();
  1072. }
  1073. if ( ! save_song( name ) )
  1074. fl_alert( "Could not save song" );
  1075. else
  1076. gui_status( "Saved." );} {}
  1077. }
  1078. Function {show_help_dialog( const char *file )} {return_type void
  1079. } {
  1080. code {char pat[256];
  1081. snprintf( pat, 256, "%s%s.html", DOCUMENT_PATH, file );
  1082. Fl_Help_Dialog *help; // Help dialog
  1083. help = new Fl_Help_Dialog;
  1084. help->load( pat );
  1085. help->show();
  1086. // FIXME: need to delete it somehow.
  1087. // help->show(1, argv);} {}
  1088. }
  1089. Function {maybe_save_song()} {open return_type bool
  1090. } {
  1091. code {if ( song.dirty() )
  1092. {
  1093. int c = fl_choice( "Song has been modified since last save. What shall I do?", "Cancel", "Save", "Discard" );
  1094. switch ( c )
  1095. {
  1096. case 0:
  1097. return false;
  1098. case 1:
  1099. /* SAVE */
  1100. save_dialog( song.filename );
  1101. break;
  1102. case 2:
  1103. break;
  1104. }
  1105. }
  1106. return true;} {}
  1107. }
  1108. Function {switch_to_pattern( int n )} {return_type void
  1109. } {
  1110. code {pattern *p = pattern::pattern_by_number( n );
  1111. if ( p )
  1112. {
  1113. tabs->value( pattern_tab );
  1114. pattern_canvas_widget->take_focus();
  1115. pattern_c->grid( p );
  1116. // update_pattern_widgets();
  1117. }} {}
  1118. }
  1119. Function {edit_instrument_row( Instrument *i, int n )} {open return_type void
  1120. } {
  1121. code {Instrument_Editor ie;
  1122. ie.set( i, n );
  1123. ie.run();} {}
  1124. }
  1125. }
  1126. Function {shortcut_handler( int e )} {return_type int
  1127. } {
  1128. code {if ( e != FL_SHORTCUT )
  1129. return 0;
  1130. // this is for mainwindow shortcuts only, ignore all other windows.
  1131. if ( Fl::first_window() != ui->main_window )
  1132. return 0;
  1133. int processed = 0;
  1134. // shortcuts that don't fit anywhere else (widgets that don't take shortcuts, etc.)
  1135. \#define KEY(key) ((Fl::test_shortcut( (key) )))
  1136. processed = 1;
  1137. if KEY( FL_ALT + 's' )
  1138. {
  1139. ui->tabs->value( ui->sequence_tab );
  1140. ui->tabs->do_callback();
  1141. }
  1142. else
  1143. if KEY( FL_ALT + 'a' )
  1144. {
  1145. ui->tabs->value( ui->phrase_tab );
  1146. ui->tabs->do_callback();
  1147. }
  1148. else
  1149. if KEY( FL_ALT + 'p' )
  1150. {
  1151. ui->tabs->value( ui->pattern_tab );
  1152. ui->tabs->do_callback();
  1153. }
  1154. else
  1155. if KEY( FL_ALT + 'c' )
  1156. ui->pattern_channel_spinner->take_focus();
  1157. else
  1158. if KEY( FL_ALT + 'o' )
  1159. ui->pattern_port_spinner->take_focus();
  1160. else
  1161. if KEY( FL_ALT + 'i' )
  1162. ui->mapping_menu->take_focus();
  1163. else
  1164. processed = 0;
  1165. return processed;} {}
  1166. }
  1167. decl {\#include <FL/Fl_Single_Window.H>} {public
  1168. }
  1169. class O_Canvas {open : {public Fl_Double_Window}
  1170. } {
  1171. decl {Canvas *_c;} {}
  1172. decl {bool _border_drawn;} {}
  1173. decl {uint _flags;} {}
  1174. Function {O_Canvas( int X, int Y, int W, int H, const char*L=0) : Fl_Double_Window(X,Y,W,H,L)} {open
  1175. } {
  1176. code {_c = NULL;
  1177. _border_drawn = false;
  1178. _flags = 0;
  1179. end();} {}
  1180. }
  1181. Function {handle( int m )} {open return_type int
  1182. } {
  1183. code {// Accept focus if offered.
  1184. if ( m == FL_FOCUS || m == FL_UNFOCUS )
  1185. {
  1186. _border_drawn = false;
  1187. draw_playhead();
  1188. return 1;
  1189. }
  1190. // Hack in click-to-focus
  1191. if ( m == FL_PUSH )
  1192. if ( Fl::event_inside( this ) )
  1193. take_focus();
  1194. if ( Fl_Window::handle( m ) )
  1195. return 1;
  1196. // Ignore events unless we have the focus.
  1197. if ( this != Fl::focus() )
  1198. return 0;
  1199. // MESSAGE( "got event %i for canvas %p", m, _c );
  1200. int p = 0;
  1201. if ( _c )
  1202. {
  1203. p = canvas_input_callback( this, _c, m );
  1204. }
  1205. return p;} {}
  1206. }
  1207. Function {resize( int x, int y, int w, int h )} {open
  1208. } {
  1209. code {Fl_Double_Window::resize( x, y, w, h );
  1210. if ( _c )
  1211. {
  1212. DEBUG( "Resizing canvas." );
  1213. _c->resize( 0 + 1, 0 + 1, w - 1, h - 1 );
  1214. }
  1215. // Fl_Window::resize( x, y, w, h );} {}
  1216. }
  1217. Function {draw()} {open return_type void
  1218. } {
  1219. code {draw_border();
  1220. //if ( ! takesevents() )
  1221. // return;
  1222. if ( _c )
  1223. {
  1224. damage( _flags );
  1225. _flags = 0;
  1226. /*
  1227. if ( damage() & FL_DAMAGE_ALL ) printf( " damage_all" );
  1228. if ( damage() & FL_DAMAGE_SCROLL ) printf( " damage_scroll" );
  1229. if ( damage() & FL_DAMAGE_USER1 ) printf( " damage_user1" );
  1230. if ( damage() & FL_DAMAGE_USER2 ) printf( " damage_user2" );
  1231. if ( damage() & FL_DAMAGE_EXPOSE ) printf( " damage_expose" );
  1232. printf("\\n");
  1233. */
  1234. if ( damage() & FL_DAMAGE_EXPOSE )
  1235. {
  1236. draw_box( FL_FLAT_BOX, 0, 0, w(), h(), canvas_background_color );
  1237. _c->redraw();
  1238. return;
  1239. }
  1240. if ( damage() & (FL_DAMAGE_ALL | FL_DAMAGE_USER2) )
  1241. {
  1242. draw_box( FL_FLAT_BOX, 0, 0, w(), h(), canvas_background_color );
  1243. _c->redraw();
  1244. }
  1245. if ( damage() & (FL_DAMAGE_ALL | FL_DAMAGE_SCROLL) )
  1246. {
  1247. // optimized draw
  1248. _c->draw();
  1249. }
  1250. else
  1251. if ( damage() & (FL_DAMAGE_ALL | FL_DAMAGE_USER1) )
  1252. {
  1253. // playhead
  1254. _c->draw_playhead();
  1255. }
  1256. else
  1257. if ( damage() & FL_DAMAGE_ALL )
  1258. {
  1259. draw_box( FL_FLAT_BOX, 0, 0, w(), h(), canvas_background_color );
  1260. _border_drawn = false;
  1261. draw_border();
  1262. _c->redraw();
  1263. }
  1264. }
  1265. else
  1266. {
  1267. WARNING( "No canvas set for widget." );
  1268. }} {}
  1269. }
  1270. Function {set_canvas( Canvas *c )} {open
  1271. } {
  1272. code {_c = c;
  1273. _c->resize( x(), y(), w(), h() );
  1274. _c->signal_draw.connect( sigc::mem_fun( this, &O_Canvas::draw_notes ) );
  1275. _c->signal_resize.connect( sigc::mem_fun( this, &O_Canvas::clear ) );
  1276. _c->signal_settings_change.connect( sigc::ptr_fun( &UI::update_canvas_widgets ) );} {}
  1277. }
  1278. Function {click_to_focus()} {open return_type bool
  1279. } {
  1280. code {return true;} {}
  1281. }
  1282. Function {clear( void )} {open return_type void
  1283. } {
  1284. code {// parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );
  1285. damage( FL_DAMAGE_USER2 );
  1286. _flags |= FL_DAMAGE_USER2;} {}
  1287. }
  1288. Function {draw_notes( void )} {open return_type void
  1289. } {
  1290. code {damage( FL_DAMAGE_SCROLL );
  1291. // this might be called from within draw(), in which case the above does nothing.
  1292. _flags |= FL_DAMAGE_SCROLL;} {}
  1293. }
  1294. Function {draw_playhead( void )} {open return_type void
  1295. } {
  1296. code {damage( FL_DAMAGE_USER1 );} {}
  1297. }
  1298. Function {draw_border()} {open return_type void
  1299. } {
  1300. code {if ( _border_drawn )
  1301. return;
  1302. if ( this != Fl::focus() )
  1303. fl_color( FL_RED );
  1304. else
  1305. fl_color( FL_BLACK );
  1306. fl_line_style( FL_DASH );
  1307. fl_rect( 0, 0, w(), h() );
  1308. fl_line_style( FL_SOLID );
  1309. _border_drawn = true;} {}
  1310. }
  1311. }
  1312. class Instrument_Editor {} {
  1313. Function {Instrument_Editor()} {open return_type void
  1314. } {
  1315. code {make_window();} {}
  1316. }
  1317. decl {Instrument *_inst;} {}
  1318. decl {int _note;} {}
  1319. Function {make_window()} {open
  1320. } {
  1321. Fl_Window window {
  1322. label {Instrument Editor}
  1323. callback {done->do_callback();} open
  1324. xywh {670 458 339 191} type Double visible
  1325. } {
  1326. Fl_Box {} {
  1327. label {Instrument Row}
  1328. xywh {8 15 321 28} box ROUNDED_BOX color 94 labelsize 22 labelcolor 39
  1329. }
  1330. Fl_Input name_field {
  1331. label Name
  1332. callback {_inst->note_name( _note, strdup( o->value() ) );}
  1333. xywh {10 70 321 25} selection_color 48 align 1 when 1 textcolor 32
  1334. }
  1335. Fl_Value_Slider volume_slider {
  1336. label {Volume %}
  1337. callback {_inst->velocity( _note, o->value() );}
  1338. xywh {10 112 321 27} type Horizontal align 1 maximum 100 step 1 textsize 14
  1339. }
  1340. Fl_Value_Output note_field {
  1341. label {Note:}
  1342. xywh {52 158 43 24}
  1343. }
  1344. Fl_Return_Button done {
  1345. label Done
  1346. callback {if ( _inst )
  1347. _inst->save();
  1348. window->hide();}
  1349. xywh {255 157 76 25}
  1350. }
  1351. }
  1352. }
  1353. Function {set( Instrument *i, int n )} {open return_type void
  1354. } {
  1355. code {_inst = i;
  1356. _note = n;
  1357. volume_slider->value( i->velocity( n ) );
  1358. name_field->value( i->note_name( n ) );
  1359. note_field->value( n );} {}
  1360. }
  1361. Function {run()} {open return_type void
  1362. } {
  1363. code {window->show();
  1364. while ( window->shown() )
  1365. Fl::wait();} {}
  1366. }
  1367. }
  1368. class Trigger {: {public Fl_Dial}
  1369. } {
  1370. Function {Trigger( int X, int Y, int W, int H, const char *L = 0 ) : Fl_Dial( X, Y, W, H, L )} {open
  1371. } {}
  1372. Function {handle( int m )} {open return_type int
  1373. } {
  1374. code {int r = 0;
  1375. switch ( m )
  1376. {
  1377. case FL_PUSH:
  1378. {
  1379. switch ( Fl::event_button() )
  1380. {
  1381. case 1:
  1382. {
  1383. pattern *p = pattern::pattern_by_number( atoi( label() ) );
  1384. if ( p )
  1385. {
  1386. if ( p->mode() == MUTE )
  1387. p->mode( PLAY );
  1388. else
  1389. p->mode( MUTE );
  1390. }
  1391. break;
  1392. }
  1393. case 2:
  1394. {
  1395. pattern *p = pattern::pattern_by_number( atoi( label() ) );
  1396. if ( p )
  1397. {
  1398. if ( p->mode() != SOLO )
  1399. p->mode( SOLO );
  1400. else
  1401. p->mode( PLAY );
  1402. }
  1403. break;
  1404. }
  1405. case 3:
  1406. {
  1407. ui->switch_to_pattern( atoi( label() ) );
  1408. }
  1409. break;
  1410. }
  1411. r = 1;
  1412. break;
  1413. }
  1414. case FL_RELEASE:
  1415. MESSAGE("doing callback");
  1416. do_callback();
  1417. r = 1;
  1418. break;
  1419. case FL_DRAG:
  1420. r = 1;
  1421. break;
  1422. default:
  1423. r = Fl_Widget::handle( m );
  1424. break;
  1425. }
  1426. return r;} {}
  1427. }
  1428. }
  1429. widget_class Triggers {open
  1430. xywh {121 31 1278 1003} type Double hide resizable
  1431. code0 {populate();}
  1432. code1 {\#include <Fl/Fl_Dial.H>}
  1433. class Fl_Group
  1434. } {
  1435. Fl_Pack rows {open
  1436. xywh {25 25 15 15}
  1437. code0 {// o->position( x(), y() );}
  1438. } {}
  1439. Function {populate( void )} {open private return_type void
  1440. } {
  1441. code {int bw = (w() / 16);
  1442. int bh = h() / (128/ 16);
  1443. begin();
  1444. for ( int n = 0; n < 128 ; n += 16 )
  1445. {
  1446. Fl_Pack *p = new Fl_Pack( 0, 0, 25, 25 );
  1447. p->type( Fl_Pack::HORIZONTAL );
  1448. for ( int i = 0; i < 16; i++ )
  1449. {
  1450. Trigger *b = new Trigger( 0, 0, bw, 50, "Num" );
  1451. char pat[4];
  1452. sprintf( pat, "%d", n + i + 1 );
  1453. b->label( strdup( pat ) );
  1454. b->minimum( 0 );
  1455. b->maximum( 1 );
  1456. b->angles( 0, 360 );
  1457. b->type( FL_FILL_DIAL );
  1458. // b->box( FL_ROUNDED_BOX );
  1459. // b->down_box( FL_ROUNDED_BOX );
  1460. b->selection_color( FL_GREEN );
  1461. b->color( FL_BLACK );
  1462. b->align( FL_ALIGN_CENTER );
  1463. p->add( b );
  1464. }
  1465. p->end();
  1466. p->resize( 0, 0, w(), bh );
  1467. rows->add( p );
  1468. }
  1469. end();
  1470. rows->resize( x(), y(), w(), h() );
  1471. redraw();} {}
  1472. }
  1473. Function {update( void )} {open return_type void
  1474. } {
  1475. code {if ( ! takesevents() )
  1476. return;
  1477. int i;
  1478. for ( i = 0; i < MAX_PATTERN; i++ )
  1479. {
  1480. Trigger *b = (Trigger*)(((Fl_Pack*)rows->child( i / 16 ))->child( i % 16 ));
  1481. if ( i >= pattern::patterns() )
  1482. {
  1483. b->color( FL_BLACK );
  1484. b->value( 0 );
  1485. continue;
  1486. }
  1487. pattern *p = pattern::pattern_by_number( i + 1 );
  1488. if ( p->playing() )
  1489. {
  1490. b->color( fl_lighter( FL_GRAY ) );
  1491. Fl_Color c = FL_BLUE;
  1492. switch ( p->mode() )
  1493. {
  1494. case MUTE:
  1495. c = FL_GRAY;
  1496. break;
  1497. case SOLO:
  1498. c = FL_RED;
  1499. break;
  1500. case PLAY:
  1501. c = FL_GREEN;
  1502. break;
  1503. }
  1504. b->selection_color( c );
  1505. b->value( (double)p->index() / p->length() );
  1506. }
  1507. else
  1508. {
  1509. b->value( 0 );
  1510. }
  1511. }} {}
  1512. }
  1513. Function {resize( int X, int Y, int W, int H )} {open return_type void
  1514. } {
  1515. code {for ( int i = rows->children(); i--; )
  1516. {
  1517. Fl_Pack *p = (Fl_Pack*) rows->child( i );
  1518. for ( int j = p->children(); j--; )
  1519. {
  1520. int bw = W / p->children();
  1521. p->child( j )->resize( 0, 0, bw, 25 );;
  1522. }
  1523. p->resize( 0, 0, W, H / rows->children() );
  1524. p->redraw();
  1525. }
  1526. Fl_Group::resize( X, Y, W, H );} {}
  1527. }
  1528. }