void doPopupMenu() { IPopupMenu menu; IGraphics* gui = mPlug->GetGUI(); menu.AddItem("Save Program..."); menu.AddItem("Save Bank..."); menu.AddSeparator(); menu.AddItem("Load Program..."); menu.AddItem("Load Bank..."); if(gui->CreateIPopupMenu(&menu, &mRECT)) { int itemChosen = menu.GetChosenItemIdx(); //printf("chosen %i /n", itemChosen); switch (itemChosen) { case 0: //Save Program char disp[MAX_PRESET_NAME_LEN]; strcpy(disp, mPlug->GetPresetName(mPlug->GetCurrentPresetIdx())); mPlug->SaveProgramAsFXP(disp); break; case 1: //Save Bank mPlug->SaveBankAsFXB("IPlugChunks Bank"); break; case 3: //Load Preset mPlug->LoadProgramFromFXP(); break; case 4: // Load Bank mPlug->LoadBankFromFXB(); break; default: break; } } }
void IGraphics::PromptUserInput(IControl* pControl, IParam* pParam, IRECT* pTextRect) { if (!pControl || !pParam || !pTextRect) return; IParam::EParamType type = pParam->Type(); int n = pParam->GetNDisplayTexts(); char currentText[MAX_PARAM_LEN]; if ( type == IParam::kTypeEnum || (type == IParam::kTypeBool && n)) { pParam->GetDisplayForHost(currentText); IPopupMenu menu; // Fill the menu for (int i = 0; i < n; ++i) { const char* str = pParam->GetDisplayText(i); // TODO: what if two parameters have the same text? if (!strcmp(str, currentText)) // strings are equal menu.AddItem( new IPopupMenuItem(str, IPopupMenuItem::kChecked), -1 ); else // not equal menu.AddItem( new IPopupMenuItem(str), -1 ); } if(CreateIPopupMenu(&menu, pTextRect)) { pControl->SetValueFromUserInput(pParam->GetNormalized( (double) menu.GetChosenItemIdx() )); } } // TODO: what if there are Int/Double Params with a display text e.g. -96db = "mute" else // type == IParam::kTypeInt || type == IParam::kTypeDouble { pParam->GetDisplayForHostNoDisplayText(currentText); CreateTextEntry(pControl, pControl->GetText(), pTextRect, currentText, pParam ); } }