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.

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