11#include "IPlugAPP_host.h"
19#include "win32_utf8.h"
20extern float GetScaleForHWND(HWND hWnd);
21#define GET_MENU() GetMenu(gHWND)
22extern bool SaveWindowScreenshot(HWND hwnd,
const char* path);
24#define GET_MENU() SWELL_GetCurrentMenu()
25extern "C" bool SaveWindowScreenshot(
void* hwnd,
const char* path);
30#if !defined NO_IGRAPHICS
32using namespace igraphics;
35#define IDT_SCREENSHOT_TIMER 1001
39void IPlugAPPHost::PopulateSampleRateList(HWND hwndDlg, RtAudio::DeviceInfo* inputDevInfo, RtAudio::DeviceInfo* outputDevInfo)
43 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_SR,CB_RESETCONTENT,0,0);
45 std::vector<int> matchedSRs;
47 for (
int i=0; i<inputDevInfo->sampleRates.size(); i++)
49 for (
int j=0; j<outputDevInfo->sampleRates.size(); j++)
51 if (inputDevInfo->sampleRates[i] == outputDevInfo->sampleRates[j])
52 matchedSRs.push_back(inputDevInfo->sampleRates[i]);
56 for (
int k=0; k<matchedSRs.size(); k++)
58 buf.SetFormatted(20,
"%i", matchedSRs[k]);
59 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_SR,CB_ADDSTRING,0,(LPARAM)buf.Get());
60 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_SR,CB_SETITEMDATA,k,(LPARAM)matchedSRs[k]);
64 str.SetFormatted(32,
"%i", mState.mAudioSR);
66 LRESULT sridx = SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_SR, CB_FINDSTRINGEXACT, -1, (LPARAM) str.Get());
67 SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_SR, CB_SETCURSEL, sridx, 0);
70void IPlugAPPHost::PopulateAudioInputList(HWND hwndDlg, RtAudio::DeviceInfo* info)
74 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_L,CB_RESETCONTENT,0,0);
75 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_RESETCONTENT,0,0);
79 for (i=0; i<info->inputChannels -1; i++)
81 buf.SetFormatted(20,
"%i", i+1);
82 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_L,CB_ADDSTRING,0,(LPARAM)buf.Get());
83 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_ADDSTRING,0,(LPARAM)buf.Get());
87 buf.SetFormatted(20,
"%i", i+1);
88 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_ADDSTRING,0,(LPARAM)buf.Get());
90 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_L,CB_SETCURSEL, mState.mAudioInChanL - 1, 0);
91 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_SETCURSEL, mState.mAudioInChanR - 1, 0);
94void IPlugAPPHost::PopulateAudioOutputList(HWND hwndDlg, RtAudio::DeviceInfo* info)
98 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_L,CB_RESETCONTENT,0,0);
99 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_RESETCONTENT,0,0);
103 for (i=0; i<info->outputChannels -1; i++)
105 buf.SetFormatted(20,
"%i", i+1);
106 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_L,CB_ADDSTRING,0,(LPARAM)buf.Get());
107 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_ADDSTRING,0,(LPARAM)buf.Get());
111 buf.SetFormatted(20,
"%i", i+1);
112 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_ADDSTRING,0,(LPARAM)buf.Get());
114 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_L,CB_SETCURSEL, mState.mAudioOutChanL - 1, 0);
115 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_SETCURSEL, mState.mAudioOutChanR - 1, 0);
119void IPlugAPPHost::PopulateDriverSpecificControls(HWND hwndDlg)
122 int driverType = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_DRIVER, CB_GETCURSEL, 0, 0);
123 if (driverType == kDeviceASIO)
125 ComboBox_Enable(GetDlgItem(hwndDlg, IDC_COMBO_AUDIO_IN_DEV), FALSE);
126 Button_Enable(GetDlgItem(hwndDlg, IDC_BUTTON_OS_DEV_SETTINGS), TRUE);
130 ComboBox_Enable(GetDlgItem(hwndDlg, IDC_COMBO_AUDIO_IN_DEV), TRUE);
131 Button_Enable(GetDlgItem(hwndDlg, IDC_BUTTON_OS_DEV_SETTINGS), FALSE);
138 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_DEV,CB_RESETCONTENT,0,0);
139 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_DEV,CB_RESETCONTENT,0,0);
141 for (
int i = 0; i<mAudioInputDevIDs.size(); i++)
143 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_DEV,CB_ADDSTRING,0,(LPARAM)
GetAudioDeviceName(mAudioInputDevIDs[i]).c_str());
145 if (std::string_view(
GetAudioDeviceName(mAudioInputDevIDs[i])) == mState.mAudioInDev.Get())
149 for (
int i = 0; i<mAudioOutputDevIDs.size(); i++)
151 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_DEV,CB_ADDSTRING,0,(LPARAM)
GetAudioDeviceName(mAudioOutputDevIDs[i]).c_str());
153 if (std::string_view(
GetAudioDeviceName(mAudioOutputDevIDs[i])) == mState.mAudioOutDev.Get())
158 if (driverType == kDeviceASIO)
159 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_DEV,CB_SETCURSEL, outdevidx, 0);
162 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_DEV,CB_SETCURSEL, indevidx, 0);
164 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_DEV,CB_SETCURSEL, outdevidx, 0);
166 RtAudio::DeviceInfo inputDevInfo;
167 RtAudio::DeviceInfo outputDevInfo;
169 if (mAudioInputDevIDs.size())
171 inputDevInfo = mDAC->getDeviceInfo(mAudioInputDevIDs[indevidx]);
172 PopulateAudioInputList(hwndDlg, &inputDevInfo);
175 if (mAudioOutputDevIDs.size())
177 outputDevInfo = mDAC->getDeviceInfo(mAudioOutputDevIDs[outdevidx]);
178 PopulateAudioOutputList(hwndDlg, &outputDevInfo);
181 PopulateSampleRateList(hwndDlg, &inputDevInfo, &outputDevInfo);
184void IPlugAPPHost::PopulateAudioDialogs(HWND hwndDlg)
186 PopulateDriverSpecificControls(hwndDlg);
198 for (
int i = 0; i< kNumBufferSizeOptions; i++)
200 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_BUF_SIZE,CB_ADDSTRING,0,(LPARAM)kBufferSizeOptions[i].c_str());
204 str.SetFormatted(32,
"%i", mState.mBufferSize);
206 LRESULT iovsidx = SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_BUF_SIZE, CB_FINDSTRINGEXACT, -1, (LPARAM) str.Get());
207 SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_BUF_SIZE, CB_SETCURSEL, iovsidx, 0);
210bool IPlugAPPHost::PopulateMidiDialogs(HWND hwndDlg)
212 if ( !mMidiIn || !mMidiOut )
216 for (
int i=0; i<mMidiInputDevNames.size(); i++)
218 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_DEV,CB_ADDSTRING,0,(LPARAM)mMidiInputDevNames[i].c_str());
221 LRESULT indevidx = SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_DEV,CB_FINDSTRINGEXACT, -1, (LPARAM)mState.mMidiInDev.Get());
226 mState.mMidiInDev.Set(
"off");
231 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_DEV,CB_SETCURSEL, indevidx, 0);
233 for (
int i=0; i<mMidiOutputDevNames.size(); i++)
235 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_DEV,CB_ADDSTRING,0,(LPARAM)mMidiOutputDevNames[i].c_str());
238 LRESULT outdevidx = SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_DEV,CB_FINDSTRINGEXACT, -1, (LPARAM)mState.mMidiOutDev.Get());
243 mState.mMidiOutDev.Set(
"off");
248 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_DEV,CB_SETCURSEL, outdevidx, 0);
252 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_CHAN,CB_ADDSTRING,0,(LPARAM)
"all");
253 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_CHAN,CB_ADDSTRING,0,(LPARAM)
"all");
257 for (
int i=0; i<16; i++)
259 buf.SetFormatted(20,
"%i", i+1);
260 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_CHAN,CB_ADDSTRING,0,(LPARAM)buf.Get());
261 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_CHAN,CB_ADDSTRING,0,(LPARAM)buf.Get());
264 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_IN_CHAN,CB_SETCURSEL, (LPARAM)mState.mMidiInChan, 0);
265 SendDlgItemMessage(hwndDlg,IDC_COMBO_MIDI_OUT_CHAN,CB_SETCURSEL, (LPARAM)mState.mMidiOutChan, 0);
272void IPlugAPPHost::PopulatePreferencesDialog(HWND hwndDlg)
274 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_DRIVER,CB_ADDSTRING,0,(LPARAM)
"DirectSound");
275 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_DRIVER,CB_ADDSTRING,0,(LPARAM)
"ASIO");
276 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_DRIVER,CB_SETCURSEL, mState.mAudioDriverType, 0);
278 PopulateAudioDialogs(hwndDlg);
279 PopulateMidiDialogs(hwndDlg);
283void IPlugAPPHost::PopulatePreferencesDialog(HWND hwndDlg)
285 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_DRIVER,CB_ADDSTRING,0,(LPARAM)
"CoreAudio");
287 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_DRIVER,CB_SETCURSEL, mState.mAudioDriverType, 0);
289 PopulateAudioDialogs(hwndDlg);
290 PopulateMidiDialogs(hwndDlg);
293 #error NOT IMPLEMENTED
296WDL_DLGRET IPlugAPPHost::PreferencesDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
299 AppState& mState = _this->mState;
300 AppState& mTempState = _this->mTempState;
301 AppState& mActiveState = _this->mActiveState;
303 auto getComboString = [&](WDL_String& str,
int item, WPARAM idx) {
304 std::string tempString;
305 long len = (long) SendDlgItemMessage(hwndDlg, item, CB_GETLBTEXTLEN, idx, 0) + 1;
306 tempString.reserve(len);
307 SendDlgItemMessage(hwndDlg, item, CB_GETLBTEXT, idx, (LPARAM) tempString.data());
308 str.Set(tempString.c_str());
316 WDL_UTF8_HookComboBox(GetDlgItem(hwndDlg, IDC_COMBO_AUDIO_IN_DEV));
317 WDL_UTF8_HookComboBox(GetDlgItem(hwndDlg, IDC_COMBO_AUDIO_OUT_DEV));
318 WDL_UTF8_HookComboBox(GetDlgItem(hwndDlg, IDC_COMBO_MIDI_IN_DEV));
319 WDL_UTF8_HookComboBox(GetDlgItem(hwndDlg, IDC_COMBO_MIDI_OUT_DEV));
321 _this->PopulatePreferencesDialog(hwndDlg);
327 switch (LOWORD(wParam))
330 if (mActiveState != mState)
331 _this->TryToChangeAudio();
333 EndDialog(hwndDlg, IDOK);
336 _this->TryToChangeAudio();
339 EndDialog(hwndDlg, IDCANCEL);
342 if (!_this->AudioSettingsInStateAreEqual(mState, mTempState)
343 || !_this->MIDISettingsInStateAreEqual(mState, mTempState))
347 _this->TryToChangeAudioDriverType();
348 _this->ProbeAudioIO();
349 _this->TryToChangeAudio();
354 case IDC_COMBO_AUDIO_DRIVER:
355 if (HIWORD(wParam) == CBN_SELCHANGE)
357 v = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_DRIVER, CB_GETCURSEL, 0, 0);
359 if (v != mState.mAudioDriverType)
361 mState.mAudioDriverType = v;
363 _this->TryToChangeAudioDriverType();
364 _this->ProbeAudioIO();
366 if (_this->mAudioInputDevIDs.size())
367 mState.mAudioInDev.Set(_this->
GetAudioDeviceName(_this->mAudioInputDevIDs[0]).c_str());
369 if (_this->mAudioOutputDevIDs.size())
370 mState.mAudioOutDev.Set(_this->
GetAudioDeviceName(_this->mAudioOutputDevIDs[0]).c_str());
373 mState.mAudioOutChanL = 1;
374 mState.mAudioOutChanR = 2;
376 _this->PopulateAudioDialogs(hwndDlg);
381 case IDC_COMBO_AUDIO_IN_DEV:
382 if (HIWORD(wParam) == CBN_SELCHANGE)
384 int idx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IN_DEV, CB_GETCURSEL, 0, 0);
385 getComboString(mState.mAudioInDev, IDC_COMBO_AUDIO_IN_DEV, idx);
388 mState.mAudioInChanL = 1;
389 mState.mAudioInChanR = 2;
391 _this->PopulateDriverSpecificControls(hwndDlg);
395 case IDC_COMBO_AUDIO_OUT_DEV:
396 if (HIWORD(wParam) == CBN_SELCHANGE)
398 int idx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_OUT_DEV, CB_GETCURSEL, 0, 0);
399 getComboString(mState.mAudioOutDev, IDC_COMBO_AUDIO_OUT_DEV, idx);
402 mState.mAudioOutChanL = 1;
403 mState.mAudioOutChanR = 2;
405 _this->PopulateDriverSpecificControls(hwndDlg);
409 case IDC_COMBO_AUDIO_IN_L:
410 if (HIWORD(wParam) == CBN_SELCHANGE)
412 mState.mAudioInChanL = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IN_L, CB_GETCURSEL, 0, 0) + 1;
415 mState.mAudioInChanR = mState.mAudioInChanL + 1;
416 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_SETCURSEL, mState.mAudioInChanR - 1, 0);
421 case IDC_COMBO_AUDIO_IN_R:
422 if (HIWORD(wParam) == CBN_SELCHANGE)
423 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_IN_R,CB_SETCURSEL, mState.mAudioInChanR - 1, 0);
424 mState.mAudioInChanR = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_IN_R, CB_GETCURSEL, 0, 0);
427 case IDC_COMBO_AUDIO_OUT_L:
428 if (HIWORD(wParam) == CBN_SELCHANGE)
430 mState.mAudioOutChanL = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_OUT_L, CB_GETCURSEL, 0, 0) + 1;
433 mState.mAudioOutChanR = mState.mAudioOutChanL + 1;
434 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_SETCURSEL, mState.mAudioOutChanR - 1, 0);
439 case IDC_COMBO_AUDIO_OUT_R:
440 if (HIWORD(wParam) == CBN_SELCHANGE)
441 SendDlgItemMessage(hwndDlg,IDC_COMBO_AUDIO_OUT_R,CB_SETCURSEL, mState.mAudioOutChanR - 1, 0);
442 mState.mAudioOutChanR = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_OUT_R, CB_GETCURSEL, 0, 0);
452 case IDC_COMBO_AUDIO_BUF_SIZE:
453 if (HIWORD(wParam) == CBN_SELCHANGE)
455 int iovsidx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_BUF_SIZE, CB_GETCURSEL, 0, 0);
456 mState.mBufferSize = atoi(kBufferSizeOptions[iovsidx].c_str());
459 case IDC_COMBO_AUDIO_SR:
460 if (HIWORD(wParam) == CBN_SELCHANGE)
462 int idx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_SR, CB_GETCURSEL, 0, 0);
463 mState.mAudioSR = (uint32_t) SendDlgItemMessage(hwndDlg, IDC_COMBO_AUDIO_SR, CB_GETITEMDATA, idx, 0);
467 case IDC_BUTTON_OS_DEV_SETTINGS:
468 if (HIWORD(wParam) == BN_CLICKED)
471 if ( (_this->mState.mAudioDriverType == kDeviceASIO) && (_this->mDAC->isStreamRunning() ==
true))
474 if (SWELL_GetOSXVersion() >= 0x1200)
476 system(
"open \"/System/Applications/Utilities/Audio MIDI Setup.app\"");
480 system(
"open \"/Applications/Utilities/Audio MIDI Setup.app\"");
483 #error NOT IMPLEMENTED
488 case IDC_COMBO_MIDI_IN_DEV:
489 if (HIWORD(wParam) == CBN_SELCHANGE)
491 int idx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_MIDI_IN_DEV, CB_GETCURSEL, 0, 0);
492 getComboString(mState.mMidiInDev, IDC_COMBO_MIDI_IN_DEV, idx);
493 _this->SelectMIDIDevice(ERoute::kInput, mState.mMidiInDev.Get());
497 case IDC_COMBO_MIDI_OUT_DEV:
498 if (HIWORD(wParam) == CBN_SELCHANGE)
500 int idx = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_MIDI_OUT_DEV, CB_GETCURSEL, 0, 0);
501 getComboString(mState.mMidiOutDev, IDC_COMBO_MIDI_OUT_DEV, idx);
502 _this->SelectMIDIDevice(ERoute::kOutput, mState.mMidiOutDev.Get());
506 case IDC_COMBO_MIDI_IN_CHAN:
507 if (HIWORD(wParam) == CBN_SELCHANGE)
508 mState.mMidiInChan = (int) SendDlgItemMessage(hwndDlg, IDC_COMBO_MIDI_IN_CHAN, CB_GETCURSEL, 0, 0);
511 case IDC_COMBO_MIDI_OUT_CHAN:
512 if (HIWORD(wParam) == CBN_SELCHANGE)
513 mState.mMidiOutChan = (
int) SendDlgItemMessage(hwndDlg, IDC_COMBO_MIDI_OUT_CHAN, CB_GETCURSEL, 0, 0);
526static void ClientResize(HWND hWnd,
int width,
int height)
528 RECT rcClient, rcWindow;
530 int screenwidth, screenheight;
533 screenwidth = GetSystemMetrics(SM_CXSCREEN);
534 screenheight = GetSystemMetrics(SM_CYSCREEN);
535 x = (screenwidth / 2) - (width / 2);
536 y = (screenheight / 2) - (height / 2);
538 GetClientRect(hWnd, &rcClient);
539 GetWindowRect(hWnd, &rcWindow);
541 ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
542 ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
544 SetWindowPos(hWnd, 0, x, y, width + ptDiff.x, height + ptDiff.y, 0);
548WDL_DLGRET IPlugAPPHost::MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
557 IPlugAPP* pPlug = pAppHost->GetPlug();
559 if (!pAppHost->OpenWindow(gHWND))
561 DBGMSG(
"couldn't attach gui\n");
564 ClientResize(hwndDlg, pPlug->GetEditorWidth(), pPlug->GetEditorHeight());
566 ShowWindow(hwndDlg, SW_SHOW);
571 SetTimer(hwndDlg, IDT_SCREENSHOT_TIMER, 500,
nullptr);
578 if (wParam == IDT_SCREENSHOT_TIMER)
580 KillTimer(hwndDlg, IDT_SCREENSHOT_TIMER);
585 DestroyWindow(hwndDlg);
591 pAppHost->CloseWindow();
593 IPlugAPPHost::sInstance =
nullptr;
598 SWELL_PostQuitMessage(hwndDlg);
603 DestroyWindow(hwndDlg);
606 switch (LOWORD(wParam))
610 DestroyWindow(hwndDlg);
615 IPlugAPP* pPlug = pAppHost->GetPlug();
617 bool pluginOpensAboutBox = pPlug->OnHostRequestingAboutBox();
619 if (pluginOpensAboutBox ==
false)
622 info.Append(PLUG_COPYRIGHT_STR
"\nBuilt on " __DATE__);
623 MessageBox(hwndDlg, info.Get(), PLUG_NAME, MB_OK);
630 IPlugAPP* pPlug = pAppHost->GetPlug();
632 bool pluginOpensHelp = pPlug->OnHostRequestingProductHelp();
634 if (pluginOpensHelp ==
false)
636 MessageBox(hwndDlg,
"See the manual", PLUG_NAME, MB_OK);
642 INT_PTR ret = DialogBox(gHINSTANCE, MAKEINTRESOURCE(IDD_DIALOG_PREF), hwndDlg, IPlugAPPHost::PreferencesDlgProc);
645 pAppHost->UpdateINI();
655 time_t now = time(
nullptr);
656 strftime(timestamp,
sizeof(timestamp),
"%Y%m%d_%H%M%S", localtime(&now));
660 char tempPath[MAX_PATH];
661 GetTempPathA(MAX_PATH, tempPath);
662 path.SetFormatted(512,
"%s%s_screenshot_%s.png",
667 const char* tmpDir = getenv(
"TMPDIR");
668 path.SetFormatted(512,
"%s%s_screenshot_%s.png",
669 tmpDir ? tmpDir :
"/tmp/",
674 if (SaveWindowScreenshot(gHWND, path.Get()))
677 msg.SetFormatted(512,
"Screenshot saved to:\n%s\n\nOpen it?", path.Get());
678 int result = MessageBox(hwndDlg, msg.Get(),
"Screenshot Saved", MB_YESNO);
683 ShellExecuteA(NULL,
"open", path.Get(), NULL, NULL, SW_SHOWNORMAL);
686 cmd.SetFormatted(1024,
"open \"%s\"", path.Get());
693 MessageBox(hwndDlg,
"Failed to save screenshot",
"Error", MB_OK);
699#if defined _DEBUG && !defined NO_IGRAPHICS
712 CheckMenuItem(GET_MENU(), ID_LIVE_EDIT, (MF_BYCOMMAND | enabled) ? MF_UNCHECKED : MF_CHECKED);
730 CheckMenuItem(GET_MENU(), ID_SHOW_DRAWN, (MF_BYCOMMAND | enabled) ? MF_UNCHECKED : MF_CHECKED);
748 CheckMenuItem(GET_MENU(), ID_SHOW_BOUNDS, (MF_BYCOMMAND | enabled) ? MF_UNCHECKED : MF_CHECKED);
766 CheckMenuItem(GET_MENU(), ID_SHOW_FPS, (MF_BYCOMMAND | enabled) ? MF_UNCHECKED : MF_CHECKED);
775 case WM_GETMINMAXINFO:
780 IPlugAPP* pPlug = pAppHost->GetPlug();
782 MINMAXINFO* mmi = (MINMAXINFO*) lParam;
783 mmi->ptMinTrackSize.x = pPlug->GetMinWidth();
784 mmi->ptMinTrackSize.y = pPlug->GetMinHeight();
785 mmi->ptMaxTrackSize.x = pPlug->GetMaxWidth();
786 mmi->ptMaxTrackSize.y = pPlug->GetMaxHeight();
789 float scale = GetScaleForHWND(hwndDlg);
790 mmi->ptMinTrackSize.x =
static_cast<LONG
>(
static_cast<float>(mmi->ptMinTrackSize.x) * scale);
791 mmi->ptMinTrackSize.y =
static_cast<LONG
>(
static_cast<float>(mmi->ptMinTrackSize.y) * scale);
792 mmi->ptMaxTrackSize.x =
static_cast<LONG
>(
static_cast<float>(mmi->ptMaxTrackSize.x) * scale);
793 mmi->ptMaxTrackSize.y =
static_cast<LONG
>(
static_cast<float>(mmi->ptMaxTrackSize.y) * scale);
801 WORD dpi = HIWORD(wParam);
802 RECT* rect = (RECT*)lParam;
803 float scale = GetScaleForHWND(hwndDlg);
809 GetClientRect(hwndDlg, &rcClient);
810 GetWindowRect(hwndDlg, &rcWindow);
812 ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
813 ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
834 SetWindowPos(hwndDlg, 0, rect->left, rect->top, w + ptDiff.x, h + ptDiff.y, 0);
841 IPlugAPP* pPlug = pAppHost->GetPlug();
843 switch (LOWORD(wParam))
851 GetClientRect(hwndDlg, &r);
852 pPlug->OnParentWindowResize(
static_cast<int>(r.right),
static_cast<int>(r.bottom));
This pure virtual interface delegates communication in both directions between a UI editor and someth...
int GetEditorHeight() const
int GetEditorWidth() const
An editor delegate base class that uses IGraphics for the UI.
IGraphics * GetUI()
Get a pointer to the IGraphics context.
The lowest level base class of an IGraphics context.
void ShowControlBounds(bool enable)
void EnableLiveEdit(bool enable)
Live edit mode allows you to relocate controls at runtime in debug builds.
bool ShowAreaDrawnEnabled() const
bool LiveEditEnabled() const
bool ShowControlBoundsEnabled() const
void ShowFPSDisplay(bool enable)
Shows a control to display the frame rate of drawing.
void ShowAreaDrawn(bool enable)
void SetScreenScale(float scale)
Called by the platform IGraphics class when moving to a new screen to set DPI.
A class that hosts an IPlug as a standalone app and provides Audio/Midi I/O.
const char * GetScreenshotPath() const
Get screenshot path (empty if not in screenshot mode)
std::string GetAudioDeviceName(uint32_t deviceID) const
Returns the name of the audio device with a given RTAudio device ID.
bool IsScreenshotMode() const
Check if in screenshot mode.
Standalone application base class for an IPlug plug-in.
bool GetHostResizeEnabled() const