void gMidiChannel::__cb_openMenu() { Fl_Menu_Item rclick_menu[] = { {"Edit actions..."}, // 0 {"Clear actions", 0, 0, 0, FL_SUBMENU}, // 1 {"All"}, // 2 {0}, // 3 {"Setup MIDI output..."}, // 4 {"Setup MIDI input..."}, // 5 {"Delete channel"}, // 6 {0} }; /* no 'clear actions' if there are no actions */ if (!ch->hasActions) rclick_menu[1].deactivate(); Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50); b->box(G_BOX); b->textsize(11); b->textcolor(COLOR_TEXT_0); b->color(COLOR_BG_0); const Fl_Menu_Item *m = rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b); if (!m) return; if (strcmp(m->label(), "Delete channel") == 0) { if (!gdConfirmWin("Warning", "Delete channel: are you sure?")) return; glue_deleteChannel(ch); return; } if (strcmp(m->label(), "All") == 0) { if (!gdConfirmWin("Warning", "Clear all actions: are you sure?")) return; recorder::clearChan(ch->index); gu_refreshActionEditor(); // refresh a.editor window, it could be open return; } if (strcmp(m->label(), "Edit actions...") == 0) { gu_openSubWindow(mainWin, new gdActionEditor(ch), WID_ACTION_EDITOR); return; } if (strcmp(m->label(), "Setup MIDI output...") == 0) { gu_openSubWindow(mainWin, new gdMidiInputSetup(ch), 0); return; } if (strcmp(m->label(), "Setup MIDI input...") == 0) { gu_openSubWindow(mainWin, new gdMidiGrabberChannel(ch), 0); return; } }
void gdMainWindow::__cb_open_edit_menu() { Fl_Menu_Item menu[] = { {"Clear all samples"}, {"Clear all actions"}, {"Reset to init state"}, {0} }; /* clear all actions disabled if no recs, clear all samples disabled * if no samples. */ menu[1].deactivate(); for (unsigned i=0; i<MAX_NUM_CHAN; i++) if (recorder::chanEvents[i]) { menu[1].activate(); break; } for (unsigned i=0; i<MAX_NUM_CHAN; i++) if (G_Mixer.chan[i] != NULL) { menu[0].activate(); break; } Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50); b->box(G_BOX); b->textsize(11); b->textcolor(COLOR_TEXT_0); b->color(COLOR_BG_0); const Fl_Menu_Item *m = menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b); if (!m) return; if (strcmp(m->label(), "Clear all samples") == 0) { if (!gdConfirmWin("Warning", "Clear all samples: are you sure?")) return; delSubWindow(WID_SAMPLE_EDITOR); glue_clearAllSamples(); return; } if (strcmp(m->label(), "Clear all actions") == 0) { if (!gdConfirmWin("Warning", "Clear all actions: are you sure?")) return; delSubWindow(WID_ACTION_EDITOR); glue_clearAllRecs(); return; } if (strcmp(m->label(), "Reset to init state") == 0) { if (!gdConfirmWin("Warning", "Reset to init state: are you sure?")) return; gu_closeAllSubwindows(); glue_resetToInitState(); return; } }
void gdBrowser::__cb_save_project() { if (strcmp(name->value(), "") == 0) { /// FIXME glue business gdAlert("Please choose a project name."); return; } /* check if name->value() contains ".gprj" */ char ext[6] = ".gprj"; if (strstr(name->value(), ".gprj") != NULL) ext[0] = '\0'; char fullpath[PATH_MAX]; #if defined(_WIN32) sprintf(fullpath, "%s\\%s%s", where->value(), name->value(), ext); #else sprintf(fullpath, "%s/%s%s", where->value(), name->value(), ext); #endif if (gIsProject(fullpath) && !gdConfirmWin("Warning", "Project exists: overwrite?")) return; if (glue_saveProject(fullpath, name->value())) do_callback(); else gdAlert("Unable to save the project!"); }
void gdMainWindow::__cb_endprogram() { if (!gdConfirmWin("Warning", "Quit Giada: are you sure?")) return; init_shutdown(); hide(); delete this; }
void gMenu::__cb_file() { /* An Fl_Menu_Button is made of many Fl_Menu_Item */ Fl_Menu_Item menu[] = { {"Open patch or project..."}, {"Save patch..."}, {"Save project..."}, {"Quit Giada"}, {0} }; Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50); b->box(G_BOX); b->textsize(11); b->textcolor(COLOR_TEXT_0); b->color(COLOR_BG_0); const Fl_Menu_Item *m = menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b); if (!m) return; if (strcmp(m->label(), "Open patch or project...") == 0) { gWindow *childWin = new gdBrowser("Load Patch", G_Conf.patchPath.c_str(), 0, BROWSER_LOAD_PATCH); gu_openSubWindow(mainWin, childWin, WID_FILE_BROWSER); return; } if (strcmp(m->label(), "Save patch...") == 0) { if (G_Mixer.hasLogicalSamples() || G_Mixer.hasEditedSamples()) if (!gdConfirmWin("Warning", "You should save a project in order to store\nyour takes and/or processed samples.")) return; gWindow *childWin = new gdBrowser("Save Patch", G_Conf.patchPath.c_str(), 0, BROWSER_SAVE_PATCH); gu_openSubWindow(mainWin, childWin, WID_FILE_BROWSER); return; } if (strcmp(m->label(), "Save project...") == 0) { gWindow *childWin = new gdBrowser("Save Project", G_Conf.patchPath.c_str(), 0, BROWSER_SAVE_PROJECT); gu_openSubWindow(mainWin, childWin, WID_FILE_BROWSER); return; } if (strcmp(m->label(), "Quit Giada") == 0) { mainWin->do_callback(); return; } }
void gdMainWindow::__cb_endprogram() { if (!gdConfirmWin("Warning", "Quit Giada: are you sure?")) return; G_quit = true; /* close any open subwindow, especially before cleaning PluginHost to * avoid mess */ puts("GUI closing..."); gu_closeAllSubwindows(); /* write configuration file */ if (!G_Conf.write()) puts("Error while saving configuration file!"); else puts("Configuration saved"); puts("Mixer cleanup..."); /* if G_audio_status we close the kernelAudio FIRST, THEN the mixer. * The opposite could cause random segfaults (even now with RtAudio?). */ if (G_audio_status) { kernelAudio::closeDevice(); G_Mixer.close(); } puts("Recorder cleanup..."); recorder::clearAll(); #ifdef WITH_VST puts("Plugin Host cleanup..."); G_PluginHost.freeAllStacks(); #endif puts("Giada "VERSIONE" closed."); hide(); delete this; }
void gdMainWindow::__cb_open_file_menu() { /* An Fl_Menu_Button is made of many Fl_Menu_Item */ Fl_Menu_Item menu[] = { {"Open patch or project..."}, {"Save patch..."}, {"Save project..."}, {"Quit Giada"}, {0} }; Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50); b->box(G_BOX); b->textsize(11); b->textcolor(COLOR_TEXT_0); b->color(COLOR_BG_0); const Fl_Menu_Item *m = menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b); if (!m) return; if (strcmp(m->label(), "Open patch or project...") == 0) { __cb_open_loadpatch_win(); return; } if (strcmp(m->label(), "Save patch...") == 0) { if (G_Mixer.hasLogicalSamples() || G_Mixer.hasEditedSamples()) if (!gdConfirmWin("Warning", "You should save a project in order to store\nyour takes and/or processed samples.")) return; __cb_open_savepatch_win(); return; } if (strcmp(m->label(), "Save project...") == 0) { __cb_open_saveproject_win(); return; } if (strcmp(m->label(), "Quit Giada") == 0) { __cb_endprogram(); return; } }
void gdEditor::__cb_reload() { if (!gdConfirmWin("Warning", "Reload sample: are you sure?")) return; /* no need for glue_loadChan, there's no gui to refresh */ ch->load(ch->wave->pathfile.c_str(), G_Conf.samplerate, G_Conf.rsmpQuality); glue_setBoost(this, ch, DEFAULT_BOOST, true); glue_setPitch(this, ch, gDEFAULT_PITCH, true); glue_setPanning(this, ch, 1.0f); pan->value(1.0f); // glue_setPanning doesn't do it pan->redraw(); // glue_setPanning doesn't do it waveTools->waveform->stretchToWindow(); waveTools->updateWaveform(); glue_setBeginEndChannel(this, ch, 0, ch->wave->size, true); redraw(); }
void gdBrowser::__cb_save_sample() { if (strcmp(name->value(), "") == 0) { /// FIXME glue business gdAlert("Please choose a file name."); return; } /* bruteforce check extension. */ std::string filename = gStripExt(name->value()); char fullpath[PATH_MAX]; sprintf(fullpath, "%s/%s.wav", where->value(), filename.c_str()); if (gFileExists(fullpath)) if (!gdConfirmWin("Warning", "File exists: overwrite?")) return; if (((SampleChannel*)ch)->save(fullpath)) do_callback(); else gdAlert("Unable to save this sample!"); }
void gdEditor::__cb_reload() { if (!gdConfirmWin("Warning", "Reload sample: are you sure?")) return; /* no need for glue_loadChan, there's no gui to refresh */ mh_loadChan(G_Mixer.chan[chan]->pathfile.c_str(), chan); glue_setBoost(this, chan, DEFAULT_BOOST, true); glue_setPitch(this, chan, gDEFAULT_PITCH, true); glue_setPanning(this, chan, 1.0f); pan->value(1.0f); // glue_setPanning doesn't do it pan->redraw(); // glue_setPanning doesn't do it wt->wave->calcZoom(); wt->wave->alloc(); wt->wave->redraw(); glue_setBeginEndChannel(this, chan, 0, G_Mixer.chan[chan]->size, true); redraw(); }
void gdBrowser::__cb_save_patch() { if (strcmp(name->value(), "") == 0) { /// FIXME glue business gdAlert("Please choose a file name."); return; } /* if name->value() contains ".gptc" */ char ext[6] = ".gptc"; if (strstr(name->value(), ".gptc") != NULL) ext[0] = '\0'; char fullpath[PATH_MAX]; sprintf(fullpath, "%s/%s%s", where->value(), name->value(), ext); if (gFileExists(fullpath)) if (!gdConfirmWin("Warning", "File exists: overwrite?")) return; if (glue_savePatch(fullpath, name->value(), false)) // false == not a project do_callback(); else gdAlert("Unable to save the patch!"); }
void gMenu::__cb_edit() { Fl_Menu_Item menu[] = { {"Clear all samples"}, {"Clear all actions"}, {"Remove empty columns"}, {"Reset to init state"}, {"Setup global MIDI input..."}, {0} }; /* clear all actions disabled if no recs, clear all samples disabled * if no samples. */ menu[1].deactivate(); for (unsigned i=0; i<G_Mixer.channels.size(); i++) if (G_Mixer.channels.at(i)->hasActions) { menu[1].activate(); break; } for (unsigned i=0; i<G_Mixer.channels.size(); i++) if (G_Mixer.channels.at(i)->type == CHANNEL_SAMPLE) if (((SampleChannel*)G_Mixer.channels.at(i))->wave != NULL) { menu[0].activate(); break; } Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50); b->box(G_BOX); b->textsize(11); b->textcolor(COLOR_TEXT_0); b->color(COLOR_BG_0); const Fl_Menu_Item *m = menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b); if (!m) return; if (strcmp(m->label(), "Clear all samples") == 0) { if (!gdConfirmWin("Warning", "Clear all samples: are you sure?")) return; mainWin->delSubWindow(WID_SAMPLE_EDITOR); glue_clearAllSamples(); return; } if (strcmp(m->label(), "Clear all actions") == 0) { if (!gdConfirmWin("Warning", "Clear all actions: are you sure?")) return; mainWin->delSubWindow(WID_ACTION_EDITOR); glue_clearAllRecs(); return; } if (strcmp(m->label(), "Reset to init state") == 0) { if (!gdConfirmWin("Warning", "Reset to init state: are you sure?")) return; gu_closeAllSubwindows(); glue_resetToInitState(); return; } if (strcmp(m->label(), "Remove empty columns") == 0) { mainWin->keyboard->organizeColumns(); return; } if (strcmp(m->label(), "Setup global MIDI input...") == 0) { gu_openSubWindow(mainWin, new gdMidiInputMaster(), 0); return; } }
void gSampleChannel::__cb_openMenu() { /* if you're recording (actions or input) no menu is allowed; you can't * do anything, especially deallocate the channel */ if (G_Mixer.chanInput == ch || recorder::active) return; /* the following is a trash workaround for a FLTK menu. We need a gMenu * widget asap */ Fl_Menu_Item rclick_menu[] = { {"Load new sample..."}, // 0 {"Export sample to file..."}, // 1 {"Set key..."}, // 2 {"Setup MIDI input..."}, // 3 {"Edit sample..."}, // 4 {"Edit actions..."}, // 5 {"Clear actions", 0, 0, 0, FL_SUBMENU}, // 6 {"All"}, // 7 {"Mute"}, // 8 {"Volume"}, // 9 {"Start/Stop"}, // 10 {0}, // 11 {"Free channel"}, // 12 {"Delete channel"}, // 13 {0} }; if (ch->status & (STATUS_EMPTY | STATUS_MISSING)) { rclick_menu[1].deactivate(); rclick_menu[4].deactivate(); rclick_menu[12].deactivate(); } /* no 'clear actions' if there are no actions */ if (!ch->hasActions) rclick_menu[6].deactivate(); /* no 'clear start/stop actions' for those channels in loop mode: * they cannot have start/stop actions. */ if (ch->mode & LOOP_ANY) rclick_menu[10].deactivate(); Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50); b->box(G_BOX); b->textsize(11); b->textcolor(COLOR_TEXT_0); b->color(COLOR_BG_0); const Fl_Menu_Item *m = rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b); if (!m) return; if (strcmp(m->label(), "Load new sample...") == 0) { openBrowser(BROWSER_LOAD_SAMPLE); return; } if (strcmp(m->label(), "Set key...") == 0) { new gdKeyGrabber(ch); /// FIXME - use gu_openSubWindow return; } if (strcmp(m->label(), "Setup MIDI input...") == 0) { gu_openSubWindow(mainWin, new gdMidiGrabberChannel(ch), 0); return; } if (strcmp(m->label(), "Edit sample...") == 0) { gu_openSubWindow(mainWin, new gdEditor(ch), WID_SAMPLE_EDITOR); /// FIXME title it's up to gdEditor return; } if (strcmp(m->label(), "Export sample to file...") == 0) { openBrowser(BROWSER_SAVE_SAMPLE); return; } if (strcmp(m->label(), "Delete channel") == 0) { if (!gdConfirmWin("Warning", "Delete channel: are you sure?")) return; glue_deleteChannel(ch); return; } if (strcmp(m->label(), "Free channel") == 0) { if (ch->status == STATUS_PLAY) { if (!gdConfirmWin("Warning", "This action will stop the channel: are you sure?")) return; } else if (!gdConfirmWin("Warning", "Free channel: are you sure?")) return; glue_freeChannel(ch); /* delete any related subwindow */ /** FIXME - use gu_closeAllSubwindows() */ mainWin->delSubWindow(WID_FILE_BROWSER); mainWin->delSubWindow(WID_ACTION_EDITOR); mainWin->delSubWindow(WID_SAMPLE_EDITOR); mainWin->delSubWindow(WID_FX_LIST); return; } if (strcmp(m->label(), "Mute") == 0) { if (!gdConfirmWin("Warning", "Clear all mute actions: are you sure?")) return; recorder::clearAction(ch->index, ACTION_MUTEON | ACTION_MUTEOFF); if (!ch->hasActions) delActionButton(); /* TODO - set mute=false */ gu_refreshActionEditor(); // refresh a.editor window, it could be open return; } if (strcmp(m->label(), "Start/Stop") == 0) { if (!gdConfirmWin("Warning", "Clear all start/stop actions: are you sure?")) return; recorder::clearAction(ch->index, ACTION_KEYPRESS | ACTION_KEYREL | ACTION_KILLCHAN); if (!ch->hasActions) delActionButton(); gu_refreshActionEditor(); // refresh a.editor window, it could be open return; } if (strcmp(m->label(), "Volume") == 0) { if (!gdConfirmWin("Warning", "Clear all volume actions: are you sure?")) return; recorder::clearAction(ch->index, ACTION_VOLUME); if (!ch->hasActions) delActionButton(); gu_refreshActionEditor(); // refresh a.editor window, it could be open return; } if (strcmp(m->label(), "All") == 0) { if (!gdConfirmWin("Warning", "Clear all actions: are you sure?")) return; recorder::clearChan(ch->index); delActionButton(); gu_refreshActionEditor(); // refresh a.editor window, it could be open return; } if (strcmp(m->label(), "Edit actions...") == 0) { gu_openSubWindow(mainWin, new gdActionEditor(ch), WID_ACTION_EDITOR); return; } }
void geMidiChannel::__cb_openMenu() { Fl_Menu_Item rclick_menu[] = { {"Edit actions..."}, // 0 {"Clear actions", 0, 0, 0, FL_SUBMENU}, // 1 {"All"}, // 2 {0}, // 3 {"Setup keyboard input..."}, // 5 {"Setup MIDI input..."}, // 6 {"Setup MIDI output..."}, // 7 {"Clone channel"}, // 8 {"Delete channel"}, // 9 {0} }; /* no 'clear actions' if there are no actions */ if (!ch->hasActions) rclick_menu[1].deactivate(); Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50); b->box(G_CUSTOM_BORDER_BOX); b->textsize(GUI_FONT_SIZE_BASE); b->textcolor(COLOR_TEXT_0); b->color(COLOR_BG_0); const Fl_Menu_Item *m = rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b); if (!m) return; if (strcmp(m->label(), "Delete channel") == 0) { if (!gdConfirmWin("Warning", "Delete channel: are you sure?")) return; glue_deleteChannel(ch); return; } if (strcmp(m->label(), "Clone channel") == 0) { glue_cloneChannel(ch); return; } if (strcmp(m->label(), "Setup keyboard input...") == 0) { gu_openSubWindow(G_MainWin, new gdKeyGrabber(ch), 0); //new gdKeyGrabber(ch); return; } if (strcmp(m->label(), "All") == 0) { if (!gdConfirmWin("Warning", "Clear all actions: are you sure?")) return; G_Recorder.clearChan(ch->index); ch->hasActions = false; gu_refreshActionEditor(); // refresh a.editor window, it could be open return; } if (strcmp(m->label(), "Edit actions...") == 0) { gu_openSubWindow(G_MainWin, new gdActionEditor(ch), WID_ACTION_EDITOR); return; } if (strcmp(m->label(), "Setup MIDI input...") == 0) { gu_openSubWindow(G_MainWin, new gdMidiInputChannel(ch), 0); return; } if (strcmp(m->label(), "Setup MIDI output...") == 0) { //gu_openSubWindow(G_MainWin, new gdMidiGrabberChannel(ch, GrabForOutput), 0); gu_openSubWindow(G_MainWin, new gdMidiOutputMidiCh((MidiChannel*) ch), 0); return; } }
void gSampleChannel::__cb_openMenu() { if (G_Mixer.chanInput == ch || recorder::active) return; Fl_Menu_Item rclick_menu[] = { {"Load new sample..."}, {"Export sample to file..."}, {"Setup keyboard input..."}, {"Setup MIDI input..."}, {"Setup MIDI output..."}, {"Edit sample..."}, {"Edit actions..."}, {"Clear actions", 0, 0, 0, FL_SUBMENU}, {"All"}, {"Mute"}, {"Volume"}, {"Start/Stop"}, {0}, {"Clone channel"}, {"Free channel"}, {"Delete channel"}, {0} }; if (ch->status & (STATUS_EMPTY | STATUS_MISSING)) { rclick_menu[1].deactivate(); rclick_menu[5].deactivate(); rclick_menu[14].deactivate(); } if (!ch->hasActions) rclick_menu[7].deactivate(); if (ch->mode & LOOP_ANY) rclick_menu[11].deactivate(); Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50); b->box(G_BOX); b->textsize(GUI_FONT_SIZE_BASE); b->textcolor(COLOR_TEXT_0); b->color(COLOR_BG_0); const Fl_Menu_Item *m = rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b); if (!m) return; if (strcmp(m->label(), "Load new sample...") == 0) { openBrowser(BROWSER_LOAD_SAMPLE); return; } if (strcmp(m->label(), "Setup keyboard input...") == 0) { new gdKeyGrabber(ch); return; } if (strcmp(m->label(), "Setup MIDI input...") == 0) { gu_openSubWindow(mainWin, new gdMidiInputChannel(ch), 0); return; } if (strcmp(m->label(), "Setup MIDI output...") == 0) { gu_openSubWindow(mainWin, new gdMidiOutputSampleCh(ch), 0); return; } if (strcmp(m->label(), "Edit sample...") == 0) { gu_openSubWindow(mainWin, new gdEditor(ch), WID_SAMPLE_EDITOR); return; } if (strcmp(m->label(), "Export sample to file...") == 0) { openBrowser(BROWSER_SAVE_SAMPLE); return; } if (strcmp(m->label(), "Delete channel") == 0) { if (!gdConfirmWin("Warning", "Delete channel: are you sure?")) return; glue_deleteChannel(ch); return; } if (strcmp(m->label(), "Free channel") == 0) { if (ch->status == STATUS_PLAY) { if (!gdConfirmWin("Warning", "This action will stop the channel: are you sure?")) return; } else if (!gdConfirmWin("Warning", "Free channel: are you sure?")) return; glue_freeChannel(ch); mainWin->delSubWindow(WID_FILE_BROWSER); mainWin->delSubWindow(WID_ACTION_EDITOR); mainWin->delSubWindow(WID_SAMPLE_EDITOR); mainWin->delSubWindow(WID_FX_LIST); return; } if (strcmp(m->label(), "Clone channel") == 0) { glue_cloneChannel(ch); return; } if (strcmp(m->label(), "Mute") == 0) { if (!gdConfirmWin("Warning", "Clear all mute actions: are you sure?")) return; recorder::clearAction(ch->index, ACTION_MUTEON | ACTION_MUTEOFF); if (!ch->hasActions) delActionButton(); gu_refreshActionEditor(); return; } if (strcmp(m->label(), "Start/Stop") == 0) { if (!gdConfirmWin("Warning", "Clear all start/stop actions: are you sure?")) return; recorder::clearAction(ch->index, ACTION_KEYPRESS | ACTION_KEYREL | ACTION_KILLCHAN); if (!ch->hasActions) delActionButton(); gu_refreshActionEditor(); return; } if (strcmp(m->label(), "Volume") == 0) { if (!gdConfirmWin("Warning", "Clear all volume actions: are you sure?")) return; recorder::clearAction(ch->index, ACTION_VOLUME); if (!ch->hasActions) delActionButton(); gu_refreshActionEditor(); return; } if (strcmp(m->label(), "All") == 0) { if (!gdConfirmWin("Warning", "Clear all actions: are you sure?")) return; recorder::clearChan(ch->index); delActionButton(); gu_refreshActionEditor(); return; } if (strcmp(m->label(), "Edit actions...") == 0) { gu_openSubWindow(mainWin, new gdActionEditor(ch), WID_ACTION_EDITOR); return; } }