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.

1275 lines
44KB

  1. /*
  2. * DISTRHO Cardinal Plugin
  3. * Copyright (C) 2021-2023 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 3 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the LICENSE file.
  16. */
  17. #include <app/MenuBar.hpp>
  18. #include <app/Scene.hpp>
  19. #include <asset.hpp>
  20. #include <context.hpp>
  21. #include <engine/Engine.hpp>
  22. #include <helpers.hpp>
  23. #include <patch.hpp>
  24. #include <settings.hpp>
  25. #include <string.hpp>
  26. #include <system.hpp>
  27. #include <ui/Button.hpp>
  28. #include <ui/MenuItem.hpp>
  29. #include <ui/MenuSeparator.hpp>
  30. #include <window/Window.hpp>
  31. #ifdef DPF_RUNTIME_TESTING
  32. # include <plugin.hpp>
  33. #endif
  34. #ifdef DISTRHO_OS_WASM
  35. # include <ui/Button.hpp>
  36. # include <ui/Label.hpp>
  37. # include <ui/MenuOverlay.hpp>
  38. # include <ui/SequentialLayout.hpp>
  39. # include <emscripten/emscripten.h>
  40. #endif
  41. #ifdef NDEBUG
  42. # undef DEBUG
  43. #endif
  44. #include "Application.hpp"
  45. #include "AsyncDialog.hpp"
  46. #include "CardinalCommon.hpp"
  47. #include "PluginContext.hpp"
  48. #include "WindowParameters.hpp"
  49. #include "extra/Base64.hpp"
  50. #ifndef DISTRHO_OS_WASM
  51. # include "extra/SharedResourcePointer.hpp"
  52. #endif
  53. #ifndef HEADLESS
  54. # include "extra/ScopedValueSetter.hpp"
  55. #endif
  56. namespace rack {
  57. #ifdef DISTRHO_OS_WASM
  58. namespace asset {
  59. std::string patchesPath();
  60. }
  61. #endif
  62. namespace engine {
  63. void Engine_setAboutToClose(Engine*);
  64. void Engine_setRemoteDetails(Engine*, remoteUtils::RemoteDetails*);
  65. }
  66. namespace window {
  67. void WindowSetPluginUI(Window* window, DISTRHO_NAMESPACE::UI* ui);
  68. void WindowSetMods(Window* window, int mods);
  69. void WindowSetInternalSize(rack::window::Window* window, math::Vec size);
  70. }
  71. }
  72. START_NAMESPACE_DISTRHO
  73. // --------------------------------------------------------------------------------------------------------------------
  74. #if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  75. uint32_t Plugin::getBufferSize() const noexcept { return 0; }
  76. double Plugin::getSampleRate() const noexcept { return 0.0; }
  77. const char* Plugin::getBundlePath() const noexcept { return nullptr; }
  78. bool Plugin::isSelfTestInstance() const noexcept { return false; }
  79. bool Plugin::writeMidiEvent(const MidiEvent&) noexcept { return false; }
  80. #endif
  81. // --------------------------------------------------------------------------------------------------------------------
  82. #if defined(DISTRHO_OS_WASM) && ! CARDINAL_VARIANT_MINI
  83. struct WasmWelcomeDialog : rack::widget::OpaqueWidget
  84. {
  85. static const constexpr float margin = 10;
  86. static const constexpr float buttonWidth = 110;
  87. WasmWelcomeDialog()
  88. {
  89. using rack::ui::Button;
  90. using rack::ui::Label;
  91. using rack::ui::MenuOverlay;
  92. using rack::ui::SequentialLayout;
  93. box.size = rack::math::Vec(550, 310);
  94. SequentialLayout* const layout = new SequentialLayout;
  95. layout->box.pos = rack::math::Vec(0, 0);
  96. layout->box.size = box.size;
  97. layout->orientation = SequentialLayout::VERTICAL_ORIENTATION;
  98. layout->margin = rack::math::Vec(margin, margin);
  99. layout->spacing = rack::math::Vec(margin, margin);
  100. layout->wrap = false;
  101. addChild(layout);
  102. SequentialLayout* const contentLayout = new SequentialLayout;
  103. contentLayout->spacing = rack::math::Vec(margin, margin);
  104. layout->addChild(contentLayout);
  105. SequentialLayout* const buttonLayout = new SequentialLayout;
  106. buttonLayout->alignment = SequentialLayout::CENTER_ALIGNMENT;
  107. buttonLayout->box.size = box.size;
  108. buttonLayout->spacing = rack::math::Vec(margin, margin);
  109. layout->addChild(buttonLayout);
  110. Label* const label = new Label;
  111. label->box.size.x = box.size.x - 2*margin;
  112. label->box.size.y = box.size.y - 2*margin - 40;
  113. label->fontSize = 20;
  114. label->text = ""
  115. "Welcome to Cardinal on the Web!\n"
  116. "\n"
  117. "If using mobile/touch devices, please note:\n"
  118. " - Single quick press does simple mouse click\n"
  119. " - Press & move does click & drag action\n"
  120. " - Press & hold does right-click (and opens module browser)\n"
  121. "\n"
  122. "Still a bit experimental, so proceed with caution.\n"
  123. "Have fun!";
  124. contentLayout->addChild(label);
  125. struct JoinDiscussionButton : Button {
  126. WasmWelcomeDialog* dialog;
  127. void onAction(const ActionEvent& e) override {
  128. patchUtils::openBrowser("https://github.com/DISTRHO/Cardinal/issues/287");
  129. dialog->getParent()->requestDelete();
  130. }
  131. };
  132. JoinDiscussionButton* const discussionButton = new JoinDiscussionButton;
  133. discussionButton->box.size.x = buttonWidth;
  134. discussionButton->text = "Join discussion";
  135. discussionButton->dialog = this;
  136. buttonLayout->addChild(discussionButton);
  137. struct DismissButton : Button {
  138. WasmWelcomeDialog* dialog;
  139. void onAction(const ActionEvent& e) override {
  140. dialog->getParent()->requestDelete();
  141. }
  142. };
  143. DismissButton* const dismissButton = new DismissButton;
  144. dismissButton->box.size.x = buttonWidth;
  145. dismissButton->text = "Dismiss";
  146. dismissButton->dialog = this;
  147. buttonLayout->addChild(dismissButton);
  148. MenuOverlay* const overlay = new MenuOverlay;
  149. overlay->bgColor = nvgRGBAf(0, 0, 0, 0.33);
  150. overlay->addChild(this);
  151. APP->scene->addChild(overlay);
  152. }
  153. void step() override
  154. {
  155. OpaqueWidget::step();
  156. box.pos = parent->box.size.minus(box.size).div(2).round();
  157. }
  158. void draw(const DrawArgs& args) override
  159. {
  160. bndMenuBackground(args.vg, 0.0, 0.0, box.size.x, box.size.y, 0);
  161. Widget::draw(args);
  162. }
  163. };
  164. struct WasmRemotePatchLoadingDialog : rack::widget::OpaqueWidget
  165. {
  166. static const constexpr float margin = 10;
  167. rack::ui::MenuOverlay* overlay;
  168. WasmRemotePatchLoadingDialog(const bool isFromPatchStorage)
  169. {
  170. using rack::ui::Label;
  171. using rack::ui::MenuOverlay;
  172. using rack::ui::SequentialLayout;
  173. box.size = rack::math::Vec(300, 40);
  174. SequentialLayout* const layout = new SequentialLayout;
  175. layout->box.pos = rack::math::Vec(0, 0);
  176. layout->box.size = box.size;
  177. layout->alignment = SequentialLayout::CENTER_ALIGNMENT;
  178. layout->margin = rack::math::Vec(margin, margin);
  179. layout->spacing = rack::math::Vec(margin, margin);
  180. layout->wrap = false;
  181. addChild(layout);
  182. Label* const label = new Label;
  183. label->box.size.x = box.size.x - 2*margin;
  184. label->box.size.y = box.size.y - 2*margin;
  185. label->fontSize = 16;
  186. label->text = isFromPatchStorage
  187. ? "Loading patch from PatchStorage...\n"
  188. : "Loading remote patch...\n";
  189. layout->addChild(label);
  190. overlay = new MenuOverlay;
  191. overlay->bgColor = nvgRGBAf(0, 0, 0, 0.33);
  192. overlay->addChild(this);
  193. APP->scene->addChild(overlay);
  194. }
  195. void step() override
  196. {
  197. OpaqueWidget::step();
  198. box.pos = parent->box.size.minus(box.size).div(2).round();
  199. }
  200. void draw(const DrawArgs& args) override
  201. {
  202. bndMenuBackground(args.vg, 0.0, 0.0, box.size.x, box.size.y, 0);
  203. Widget::draw(args);
  204. }
  205. };
  206. static void downloadRemotePatchFailed(const char* const filename)
  207. {
  208. d_stdout("downloadRemotePatchFailed %s", filename);
  209. CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
  210. CardinalBaseUI* const ui = static_cast<CardinalBaseUI*>(context->ui);
  211. if (ui->psDialog != nullptr)
  212. {
  213. ui->psDialog->overlay->requestDelete();
  214. ui->psDialog = nullptr;
  215. asyncDialog::create("Failed to fetch remote patch");
  216. }
  217. using namespace rack;
  218. context->patch->templatePath = rack::system::join(asset::patchesPath(), "templates/main.vcv");
  219. context->patch->loadTemplate();
  220. context->scene->rackScroll->reset();
  221. }
  222. static void downloadRemotePatchSucceeded(const char* const filename)
  223. {
  224. d_stdout("downloadRemotePatchSucceeded %s | %s", filename, APP->patch->templatePath.c_str());
  225. CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
  226. CardinalBaseUI* const ui = static_cast<CardinalBaseUI*>(context->ui);
  227. ui->psDialog->overlay->requestDelete();
  228. ui->psDialog = nullptr;
  229. if (FILE* f = fopen(filename, "r"))
  230. {
  231. uint8_t buf[8] = {};
  232. fread(buf, 8, 1, f);
  233. d_stdout("read patch %x %x %x %x %x %x %x %x",
  234. buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7]);
  235. fclose(f);
  236. }
  237. try {
  238. context->patch->load(filename);
  239. } catch (rack::Exception& e) {
  240. const std::string message = rack::string::f("Could not load patch: %s", e.what());
  241. asyncDialog::create(message.c_str());
  242. return;
  243. }
  244. context->patch->path.clear();
  245. context->scene->rackScroll->reset();
  246. context->history->setSaved();
  247. }
  248. #endif
  249. // -----------------------------------------------------------------------------------------------------------
  250. class CardinalUI : public CardinalBaseUI,
  251. public WindowParametersCallback
  252. {
  253. #if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  254. #ifdef DISTRHO_OS_WASM
  255. ScopedPointer<Initializer> fInitializer;
  256. #else
  257. SharedResourcePointer<Initializer> fInitializer;
  258. #endif
  259. std::string fAutosavePath;
  260. #endif
  261. rack::math::Vec lastMousePos;
  262. WindowParameters windowParameters;
  263. int rateLimitStep = 0;
  264. #if defined(DISTRHO_OS_WASM) && ! CARDINAL_VARIANT_MINI
  265. int8_t counterForFirstIdlePoint = 0;
  266. #endif
  267. #ifdef DPF_RUNTIME_TESTING
  268. bool inSelfTest = false;
  269. #endif
  270. struct ScopedContext {
  271. CardinalPluginContext* const context;
  272. ScopedContext(CardinalUI* const ui)
  273. : context(ui->context)
  274. {
  275. rack::contextSet(context);
  276. WindowParametersRestore(context->window);
  277. }
  278. ScopedContext(CardinalUI* const ui, const int mods)
  279. : context(ui->context)
  280. {
  281. rack::contextSet(context);
  282. rack::window::WindowSetMods(context->window, mods);
  283. WindowParametersRestore(context->window);
  284. }
  285. ~ScopedContext()
  286. {
  287. if (context->window != nullptr)
  288. WindowParametersSave(context->window);
  289. }
  290. };
  291. public:
  292. CardinalUI()
  293. : CardinalBaseUI(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT),
  294. #if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  295. #ifdef DISTRHO_OS_WASM
  296. fInitializer(new Initializer(static_cast<const CardinalBasePlugin*>(nullptr), this)),
  297. #else
  298. fInitializer(static_cast<const CardinalBasePlugin*>(nullptr), this),
  299. #endif
  300. #endif
  301. lastMousePos()
  302. {
  303. rack::contextSet(context);
  304. #if CARDINAL_VARIANT_MINI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  305. // create unique temporary path for this instance
  306. try {
  307. char uidBuf[24];
  308. const std::string tmp = rack::system::getTempDirectory();
  309. for (int i=1;; ++i)
  310. {
  311. std::snprintf(uidBuf, sizeof(uidBuf), "Cardinal.%04d", i);
  312. const std::string trypath = rack::system::join(tmp, uidBuf);
  313. if (! rack::system::exists(trypath))
  314. {
  315. if (rack::system::createDirectories(trypath))
  316. fAutosavePath = trypath;
  317. break;
  318. }
  319. }
  320. } DISTRHO_SAFE_EXCEPTION("create unique temporary path");
  321. const float sampleRate = 60; // fake audio running at 60 fps
  322. rack::settings::sampleRate = sampleRate;
  323. context->dataIns = new const float*[DISTRHO_PLUGIN_NUM_INPUTS];
  324. context->dataOuts = new float*[DISTRHO_PLUGIN_NUM_OUTPUTS];
  325. for (uint32_t i=0; i<DISTRHO_PLUGIN_NUM_INPUTS;++i)
  326. {
  327. float** const bufferptr = const_cast<float**>(&context->dataIns[i]);
  328. *bufferptr = new float[1];
  329. (*bufferptr)[0] = 0.f;
  330. }
  331. for (uint32_t i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS;++i)
  332. context->dataOuts[i] = new float[1];
  333. context->bufferSize = 1;
  334. context->sampleRate = sampleRate;
  335. context->engine = new rack::engine::Engine;
  336. context->engine->setSampleRate(sampleRate);
  337. context->history = new rack::history::State;
  338. context->patch = new rack::patch::Manager;
  339. context->patch->autosavePath = fAutosavePath;
  340. context->patch->templatePath = context->patch->factoryTemplatePath = fInitializer->factoryTemplatePath;
  341. context->event = new rack::widget::EventState;
  342. context->scene = new rack::app::Scene;
  343. context->event->rootWidget = context->scene;
  344. context->window = new rack::window::Window;
  345. context->patch->loadTemplate();
  346. context->scene->rackScroll->reset();
  347. DISTRHO_SAFE_ASSERT(remoteUtils::connectToRemote(CARDINAL_DEFAULT_REMOTE_URL));
  348. Engine_setRemoteDetails(context->engine, remoteDetails);
  349. #endif
  350. Window& window(getWindow());
  351. window.setIgnoringKeyRepeat(true);
  352. context->nativeWindowId = window.getNativeWindowHandle();
  353. const double scaleFactor = getScaleFactor();
  354. setGeometryConstraints(648 * scaleFactor, 538 * scaleFactor);
  355. if (rack::isStandalone() && rack::system::exists(rack::settings::settingsPath))
  356. {
  357. const double width = std::max(648.f, rack::settings::windowSize.x) * scaleFactor;
  358. const double height = std::max(538.f, rack::settings::windowSize.y) * scaleFactor;
  359. setSize(width, height);
  360. }
  361. else if (scaleFactor != 1.0)
  362. {
  363. setSize(DISTRHO_UI_DEFAULT_WIDTH * scaleFactor, DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor);
  364. }
  365. rack::window::WindowSetPluginUI(context->window, this);
  366. // hide "Browse VCV Library" button
  367. rack::widget::Widget* const browser = context->scene->browser->children.back();
  368. rack::widget::Widget* const headerLayout = browser->children.front();
  369. rack::widget::Widget* const libraryButton = headerLayout->children.back();
  370. libraryButton->hide();
  371. // Report to user if something is wrong with the installation
  372. std::string errorMessage;
  373. if (rack::asset::systemDir.empty())
  374. {
  375. errorMessage = "Failed to locate Cardinal plugin bundle.\n"
  376. "Install Cardinal with its plugin bundle folder intact and try again.";
  377. }
  378. else if (! rack::system::exists(rack::asset::systemDir))
  379. {
  380. errorMessage = rack::string::f("System directory \"%s\" does not exist. "
  381. "Make sure Cardinal was downloaded and installed correctly.",
  382. rack::asset::systemDir.c_str());
  383. }
  384. if (! errorMessage.empty())
  385. {
  386. static bool shown = false;
  387. if (! shown)
  388. {
  389. shown = true;
  390. asyncDialog::create(errorMessage.c_str());
  391. }
  392. }
  393. #if defined(DISTRHO_OS_WASM) && ! CARDINAL_VARIANT_MINI
  394. if (rack::patchStorageSlug != nullptr)
  395. {
  396. psDialog = new WasmRemotePatchLoadingDialog(true);
  397. }
  398. else if (rack::patchRemoteURL != nullptr)
  399. {
  400. psDialog = new WasmRemotePatchLoadingDialog(false);
  401. }
  402. else if (rack::patchFromURL != nullptr)
  403. {
  404. static_cast<CardinalBasePlugin*>(context->plugin)->setState("patch", rack::patchFromURL);
  405. rack::contextSet(context);
  406. }
  407. else
  408. {
  409. new WasmWelcomeDialog();
  410. }
  411. #endif
  412. context->window->step();
  413. rack::contextSet(nullptr);
  414. WindowParametersSetCallback(context->window, this);
  415. }
  416. ~CardinalUI() override
  417. {
  418. rack::contextSet(context);
  419. context->nativeWindowId = 0;
  420. rack::window::WindowSetPluginUI(context->window, nullptr);
  421. context->tlw = nullptr;
  422. context->ui = nullptr;
  423. #if CARDINAL_VARIANT_MINI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  424. {
  425. const ScopedContext sc(this);
  426. context->patch->clear();
  427. // do a little dance to prevent context scene deletion from saving to temp dir
  428. const ScopedValueSetter<bool> svs(rack::settings::headless, true);
  429. Engine_setAboutToClose(context->engine);
  430. delete context;
  431. }
  432. if (! fAutosavePath.empty())
  433. rack::system::removeRecursively(fAutosavePath);
  434. #endif
  435. rack::contextSet(nullptr);
  436. }
  437. void onNanoDisplay() override
  438. {
  439. const ScopedContext sc(this);
  440. context->window->step();
  441. }
  442. void uiIdle() override
  443. {
  444. #ifdef DPF_RUNTIME_TESTING
  445. if (inSelfTest)
  446. {
  447. context->window->step();
  448. return;
  449. }
  450. if (context->plugin->isSelfTestInstance())
  451. {
  452. inSelfTest = true;
  453. Application& app(getApp());
  454. const ScopedContext sc(this);
  455. context->patch->clear();
  456. app.idle();
  457. const rack::math::Vec mousePos(getWidth()/2,getHeight()/2);
  458. context->event->handleButton(mousePos, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, 0x0);
  459. context->event->handleHover(mousePos, rack::math::Vec(0,0));
  460. app.idle();
  461. for (rack::plugin::Plugin* p : rack::plugin::plugins)
  462. {
  463. for (rack::plugin::Model* m : p->models)
  464. {
  465. d_stdout(">>>>>>>>>>>>>>>>> LOADING module %s : %s", p->slug.c_str(), m->slug.c_str());
  466. rack::engine::Module* const module = m->createModule();
  467. DISTRHO_SAFE_ASSERT_CONTINUE(module != nullptr);
  468. rack::CardinalPluginModelHelper* const helper = dynamic_cast<rack::CardinalPluginModelHelper*>(m);
  469. DISTRHO_SAFE_ASSERT_CONTINUE(helper != nullptr);
  470. d_stdout(">>>>>>>>>>>>>>>>> LOADING moduleWidget %s : %s", p->slug.c_str(), m->slug.c_str());
  471. rack::app::ModuleWidget* const moduleWidget = helper->createModuleWidget(module);
  472. DISTRHO_SAFE_ASSERT_CONTINUE(moduleWidget != nullptr);
  473. d_stdout(">>>>>>>>>>>>>>>>> ADDING TO ENGINE %s : %s", p->slug.c_str(), m->slug.c_str());
  474. context->engine->addModule(module);
  475. d_stdout(">>>>>>>>>>>>>>>>> ADDING TO RACK VIEW %s : %s", p->slug.c_str(), m->slug.c_str());
  476. context->scene->rack->addModuleAtMouse(moduleWidget);
  477. for (int i=5; --i>=0;)
  478. app.idle();
  479. d_stdout(">>>>>>>>>>>>>>>>> REMOVING FROM RACK VIEW %s : %s", p->slug.c_str(), m->slug.c_str());
  480. context->scene->rack->removeModule(moduleWidget);
  481. app.idle();
  482. d_stdout(">>>>>>>>>>>>>>>>> DELETING module + moduleWidget %s : %s", p->slug.c_str(), m->slug.c_str());
  483. delete moduleWidget;
  484. app.idle();
  485. }
  486. }
  487. inSelfTest = false;
  488. }
  489. #endif
  490. #if defined(DISTRHO_OS_WASM) && ! CARDINAL_VARIANT_MINI
  491. if (counterForFirstIdlePoint >= 0 && ++counterForFirstIdlePoint == 30)
  492. {
  493. counterForFirstIdlePoint = -1;
  494. if (rack::patchStorageSlug != nullptr)
  495. {
  496. std::string url("/patchstorage.php?slug=");
  497. url += rack::patchStorageSlug;
  498. std::free(rack::patchStorageSlug);
  499. rack::patchStorageSlug = nullptr;
  500. emscripten_async_wget(url.c_str(), context->patch->templatePath.c_str(),
  501. downloadRemotePatchSucceeded, downloadRemotePatchFailed);
  502. }
  503. else if (rack::patchRemoteURL != nullptr)
  504. {
  505. std::string url("/patchurl.php?url=");
  506. url += rack::patchRemoteURL;
  507. std::free(rack::patchRemoteURL);
  508. rack::patchRemoteURL = nullptr;
  509. emscripten_async_wget(url.c_str(), context->patch->templatePath.c_str(),
  510. downloadRemotePatchSucceeded, downloadRemotePatchFailed);
  511. }
  512. }
  513. #endif
  514. if (filebrowserhandle != nullptr && fileBrowserIdle(filebrowserhandle))
  515. {
  516. {
  517. const char* const path = fileBrowserGetPath(filebrowserhandle);
  518. const ScopedContext sc(this);
  519. filebrowseraction(path != nullptr ? strdup(path) : nullptr);
  520. }
  521. fileBrowserClose(filebrowserhandle);
  522. filebrowseraction = nullptr;
  523. filebrowserhandle = nullptr;
  524. }
  525. #if CARDINAL_VARIANT_MINI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  526. {
  527. const ScopedContext sc(this);
  528. for (uint32_t i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS;++i)
  529. context->dataOuts[i][0] = 0.f;
  530. ++context->processCounter;
  531. context->engine->stepBlock(1);
  532. }
  533. #endif
  534. if (windowParameters.rateLimit != 0 && ++rateLimitStep % (windowParameters.rateLimit * 2))
  535. return;
  536. rateLimitStep = 0;
  537. repaint();
  538. }
  539. void WindowParametersChanged(const WindowParameterList param, float value) override
  540. {
  541. float mult = 1.0f;
  542. switch (param)
  543. {
  544. case kWindowParameterShowTooltips:
  545. windowParameters.tooltips = value > 0.5f;
  546. break;
  547. case kWindowParameterCableOpacity:
  548. mult = 100.0f;
  549. windowParameters.cableOpacity = value;
  550. break;
  551. case kWindowParameterCableTension:
  552. mult = 100.0f;
  553. windowParameters.cableTension = value;
  554. break;
  555. case kWindowParameterRackBrightness:
  556. mult = 100.0f;
  557. windowParameters.rackBrightness = value;
  558. break;
  559. case kWindowParameterHaloBrightness:
  560. mult = 100.0f;
  561. windowParameters.haloBrightness = value;
  562. break;
  563. case kWindowParameterKnobMode:
  564. switch (static_cast<int>(value + 0.5f))
  565. {
  566. case rack::settings::KNOB_MODE_LINEAR:
  567. value = 0;
  568. windowParameters.knobMode = rack::settings::KNOB_MODE_LINEAR;
  569. break;
  570. case rack::settings::KNOB_MODE_ROTARY_ABSOLUTE:
  571. value = 1;
  572. windowParameters.knobMode = rack::settings::KNOB_MODE_ROTARY_ABSOLUTE;
  573. break;
  574. case rack::settings::KNOB_MODE_ROTARY_RELATIVE:
  575. value = 2;
  576. windowParameters.knobMode = rack::settings::KNOB_MODE_ROTARY_RELATIVE;
  577. break;
  578. }
  579. break;
  580. case kWindowParameterWheelKnobControl:
  581. windowParameters.knobScroll = value > 0.5f;
  582. break;
  583. case kWindowParameterWheelSensitivity:
  584. mult = 1000.0f;
  585. windowParameters.knobScrollSensitivity = value;
  586. break;
  587. case kWindowParameterLockModulePositions:
  588. windowParameters.lockModules = value > 0.5f;
  589. break;
  590. case kWindowParameterUpdateRateLimit:
  591. windowParameters.rateLimit = static_cast<int>(value + 0.5f);
  592. rateLimitStep = 0;
  593. break;
  594. case kWindowParameterBrowserSort:
  595. windowParameters.browserSort = static_cast<int>(value + 0.5f);
  596. break;
  597. case kWindowParameterBrowserZoom:
  598. windowParameters.browserZoom = value;
  599. value = std::pow(2.f, value) * 100.0f;
  600. break;
  601. case kWindowParameterInvertZoom:
  602. windowParameters.invertZoom = value > 0.5f;
  603. break;
  604. case kWindowParameterSqueezeModulePositions:
  605. windowParameters.squeezeModules = value > 0.5f;
  606. break;
  607. default:
  608. return;
  609. }
  610. setParameterValue(kCardinalParameterStartWindow + param, value * mult);
  611. }
  612. protected:
  613. /* --------------------------------------------------------------------------------------------------------
  614. * DSP/Plugin Callbacks */
  615. /**
  616. A parameter has changed on the plugin side.
  617. This is called by the host to inform the UI about parameter changes.
  618. */
  619. void parameterChanged(const uint32_t index, const float value) override
  620. {
  621. // host mapped parameters
  622. if (index < kCardinalParameterCountAtModules)
  623. {
  624. #if CARDINAL_VARIANT_MINI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  625. context->parameters[index] = value;
  626. #endif
  627. return;
  628. }
  629. // bypass
  630. if (index == kCardinalParameterBypass)
  631. {
  632. #if CARDINAL_VARIANT_MINI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  633. context->bypassed = value > 0.5f;
  634. #endif
  635. return;
  636. }
  637. if (index < kCardinalParameterCountAtWindow)
  638. {
  639. switch (index - kCardinalParameterStartWindow)
  640. {
  641. case kWindowParameterShowTooltips:
  642. windowParameters.tooltips = value > 0.5f;
  643. break;
  644. case kWindowParameterCableOpacity:
  645. windowParameters.cableOpacity = value / 100.0f;
  646. break;
  647. case kWindowParameterCableTension:
  648. windowParameters.cableTension = value / 100.0f;
  649. break;
  650. case kWindowParameterRackBrightness:
  651. windowParameters.rackBrightness = value / 100.0f;
  652. break;
  653. case kWindowParameterHaloBrightness:
  654. windowParameters.haloBrightness = value / 100.0f;
  655. break;
  656. case kWindowParameterKnobMode:
  657. switch (static_cast<int>(value + 0.5f))
  658. {
  659. case 0:
  660. windowParameters.knobMode = rack::settings::KNOB_MODE_LINEAR;
  661. break;
  662. case 1:
  663. windowParameters.knobMode = rack::settings::KNOB_MODE_ROTARY_ABSOLUTE;
  664. break;
  665. case 2:
  666. windowParameters.knobMode = rack::settings::KNOB_MODE_ROTARY_RELATIVE;
  667. break;
  668. }
  669. break;
  670. case kWindowParameterWheelKnobControl:
  671. windowParameters.knobScroll = value > 0.5f;
  672. break;
  673. case kWindowParameterWheelSensitivity:
  674. windowParameters.knobScrollSensitivity = value / 1000.0f;
  675. break;
  676. case kWindowParameterLockModulePositions:
  677. windowParameters.lockModules = value > 0.5f;
  678. break;
  679. case kWindowParameterUpdateRateLimit:
  680. windowParameters.rateLimit = static_cast<int>(value + 0.5f);
  681. rateLimitStep = 0;
  682. break;
  683. case kWindowParameterBrowserSort:
  684. windowParameters.browserSort = static_cast<int>(value + 0.5f);
  685. break;
  686. case kWindowParameterBrowserZoom:
  687. // round up to nearest valid value
  688. {
  689. float rvalue = value - 1.0f;
  690. if (rvalue <= 25.0f)
  691. rvalue = -2.0f;
  692. else if (rvalue <= 35.0f)
  693. rvalue = -1.5f;
  694. else if (rvalue <= 50.0f)
  695. rvalue = -1.0f;
  696. else if (rvalue <= 71.0f)
  697. rvalue = -0.5f;
  698. else if (rvalue <= 100.0f)
  699. rvalue = 0.0f;
  700. else if (rvalue <= 141.0f)
  701. rvalue = 0.5f;
  702. else if (rvalue <= 200.0f)
  703. rvalue = 1.0f;
  704. else
  705. rvalue = 0.0f;
  706. windowParameters.browserZoom = rvalue;
  707. }
  708. break;
  709. case kWindowParameterInvertZoom:
  710. windowParameters.invertZoom = value > 0.5f;
  711. break;
  712. case kWindowParameterSqueezeModulePositions:
  713. windowParameters.squeezeModules = value > 0.5f;
  714. break;
  715. default:
  716. return;
  717. }
  718. WindowParametersSetValues(context->window, windowParameters);
  719. return;
  720. }
  721. #if CARDINAL_VARIANT_MINI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  722. if (index < kCardinalParameterCountAtMiniBuffers)
  723. {
  724. float* const buffer = *const_cast<float**>(&context->dataIns[index - kCardinalParameterStartMiniBuffers]);
  725. buffer[0] = value;
  726. return;
  727. }
  728. switch (index)
  729. {
  730. case kCardinalParameterMiniTimeFlags: {
  731. const int32_t flags = static_cast<int32_t>(value + 0.5f);
  732. context->playing = flags & 0x1;
  733. context->bbtValid = flags & 0x2;
  734. context->reset = flags & 0x4;
  735. return;
  736. }
  737. case kCardinalParameterMiniTimeBar:
  738. context->bar = static_cast<int32_t>(value + 0.5f);
  739. return;
  740. case kCardinalParameterMiniTimeBeat:
  741. context->beat = static_cast<int32_t>(value + 0.5f);
  742. return;
  743. case kCardinalParameterMiniTimeBeatsPerBar:
  744. context->beatsPerBar = static_cast<int32_t>(value + 0.5f);
  745. return;
  746. case kCardinalParameterMiniTimeBeatType:
  747. context->beatType = static_cast<int32_t>(value + 0.5f);
  748. context->ticksPerClock = context->ticksPerBeat / context->beatType;
  749. context->tickClock = std::fmod(context->tick, context->ticksPerClock);
  750. return;
  751. case kCardinalParameterMiniTimeFrame:
  752. context->frame = static_cast<uint64_t>(value * context->sampleRate + 0.5f);
  753. return;
  754. case kCardinalParameterMiniTimeBarStartTick:
  755. context->barStartTick = value;
  756. return;
  757. case kCardinalParameterMiniTimeBeatsPerMinute:
  758. context->beatsPerMinute = value;
  759. context->ticksPerFrame = 1.0 / (60.0 * context->sampleRate / context->beatsPerMinute / context->ticksPerBeat);
  760. return;
  761. case kCardinalParameterMiniTimeTick:
  762. context->tick = value;
  763. context->tickClock = std::fmod(context->tick, context->ticksPerClock);
  764. return;
  765. case kCardinalParameterMiniTimeTicksPerBeat:
  766. context->ticksPerBeat = value;
  767. context->ticksPerClock = context->ticksPerBeat / context->beatType;
  768. context->ticksPerFrame = 1.0 / (60.0 * context->sampleRate / context->beatsPerMinute / context->ticksPerBeat);
  769. context->tickClock = std::fmod(context->tick, context->ticksPerClock);
  770. return;
  771. }
  772. #endif
  773. }
  774. void stateChanged(const char* const key, const char* const value) override
  775. {
  776. #if CARDINAL_VARIANT_MINI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
  777. if (std::strcmp(key, "patch") == 0)
  778. {
  779. if (fAutosavePath.empty())
  780. return;
  781. rack::system::removeRecursively(fAutosavePath);
  782. rack::system::createDirectories(fAutosavePath);
  783. FILE* const f = std::fopen(rack::system::join(fAutosavePath, "patch.json").c_str(), "w");
  784. DISTRHO_SAFE_ASSERT_RETURN(f != nullptr,);
  785. std::fwrite(value, std::strlen(value), 1, f);
  786. std::fclose(f);
  787. const ScopedContext sc(this);
  788. try {
  789. context->patch->loadAutosave();
  790. } catch(const rack::Exception& e) {
  791. d_stderr(e.what());
  792. } DISTRHO_SAFE_EXCEPTION_RETURN("setState loadAutosave",);
  793. return;
  794. }
  795. #endif
  796. if (std::strcmp(key, "windowSize") == 0)
  797. {
  798. int width = 0;
  799. int height = 0;
  800. std::sscanf(value, "%d:%d", &width, &height);
  801. if (width > 0 && height > 0)
  802. {
  803. const double scaleFactor = getScaleFactor();
  804. setSize(width * scaleFactor, height * scaleFactor);
  805. }
  806. return;
  807. }
  808. }
  809. // -------------------------------------------------------------------------------------------------------
  810. static int glfwMods(const uint mod) noexcept
  811. {
  812. int mods = 0;
  813. if (mod & kModifierControl)
  814. mods |= GLFW_MOD_CONTROL;
  815. if (mod & kModifierShift)
  816. mods |= GLFW_MOD_SHIFT;
  817. if (mod & kModifierAlt)
  818. mods |= GLFW_MOD_ALT;
  819. if (mod & kModifierSuper)
  820. mods |= GLFW_MOD_SUPER;
  821. /*
  822. if (glfwGetKey(win, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS)
  823. mods |= GLFW_MOD_SHIFT;
  824. if (glfwGetKey(win, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS)
  825. mods |= GLFW_MOD_CONTROL;
  826. if (glfwGetKey(win, GLFW_KEY_LEFT_ALT) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS)
  827. mods |= GLFW_MOD_ALT;
  828. if (glfwGetKey(win, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS)
  829. mods |= GLFW_MOD_SUPER;
  830. */
  831. return mods;
  832. }
  833. bool onMouse(const MouseEvent& ev) override
  834. {
  835. #ifdef DPF_RUNTIME_TESTING
  836. if (inSelfTest) return false;
  837. #endif
  838. if (ev.press)
  839. getWindow().focus();
  840. const int action = ev.press ? GLFW_PRESS : GLFW_RELEASE;
  841. int mods = glfwMods(ev.mod);
  842. int button;
  843. switch (ev.button)
  844. {
  845. case kMouseButtonLeft: button = GLFW_MOUSE_BUTTON_LEFT; break;
  846. case kMouseButtonRight: button = GLFW_MOUSE_BUTTON_RIGHT; break;
  847. case kMouseButtonMiddle: button = GLFW_MOUSE_BUTTON_MIDDLE; break;
  848. default:
  849. button = ev.button;
  850. break;
  851. }
  852. #ifdef DISTRHO_OS_MAC
  853. // Remap Ctrl-left click to right click on macOS
  854. if (button == GLFW_MOUSE_BUTTON_LEFT && (mods & RACK_MOD_MASK) == GLFW_MOD_CONTROL) {
  855. button = GLFW_MOUSE_BUTTON_RIGHT;
  856. mods &= ~GLFW_MOD_CONTROL;
  857. }
  858. // Remap Ctrl-shift-left click to middle click on macOS
  859. if (button == GLFW_MOUSE_BUTTON_LEFT && (mods & RACK_MOD_MASK) == (GLFW_MOD_CONTROL | GLFW_MOD_SHIFT)) {
  860. button = GLFW_MOUSE_BUTTON_MIDDLE;
  861. mods &= ~(GLFW_MOD_CONTROL | GLFW_MOD_SHIFT);
  862. }
  863. #endif
  864. const ScopedContext sc(this, mods);
  865. return context->event->handleButton(lastMousePos, button, action, mods);
  866. }
  867. bool onMotion(const MotionEvent& ev) override
  868. {
  869. #ifdef DPF_RUNTIME_TESTING
  870. if (inSelfTest) return false;
  871. #endif
  872. const rack::math::Vec mousePos = rack::math::Vec(ev.pos.getX(), ev.pos.getY()).div(getScaleFactor()).round();
  873. const rack::math::Vec mouseDelta = mousePos.minus(lastMousePos);
  874. lastMousePos = mousePos;
  875. const ScopedContext sc(this, glfwMods(ev.mod));
  876. return context->event->handleHover(mousePos, mouseDelta);
  877. }
  878. bool onScroll(const ScrollEvent& ev) override
  879. {
  880. #ifdef DPF_RUNTIME_TESTING
  881. if (inSelfTest) return false;
  882. #endif
  883. rack::math::Vec scrollDelta = rack::math::Vec(-ev.delta.getX(), ev.delta.getY());
  884. #ifndef DISTRHO_OS_MAC
  885. scrollDelta = scrollDelta.mult(50.0);
  886. #endif
  887. const int mods = glfwMods(ev.mod);
  888. const ScopedContext sc(this, mods);
  889. return context->event->handleScroll(lastMousePos, scrollDelta);
  890. }
  891. bool onCharacterInput(const CharacterInputEvent& ev) override
  892. {
  893. #ifdef DPF_RUNTIME_TESTING
  894. if (inSelfTest) return false;
  895. #endif
  896. if (ev.character < ' ' || ev.character >= kKeyDelete)
  897. return false;
  898. const int mods = glfwMods(ev.mod);
  899. const ScopedContext sc(this, mods);
  900. return context->event->handleText(lastMousePos, ev.character);
  901. }
  902. bool onKeyboard(const KeyboardEvent& ev) override
  903. {
  904. #ifdef DPF_RUNTIME_TESTING
  905. if (inSelfTest) return false;
  906. #endif
  907. const int action = ev.press ? GLFW_PRESS : GLFW_RELEASE;
  908. const int mods = glfwMods(ev.mod);
  909. /* These are unsupported in pugl right now
  910. #define GLFW_KEY_KP_0 320
  911. #define GLFW_KEY_KP_1 321
  912. #define GLFW_KEY_KP_2 322
  913. #define GLFW_KEY_KP_3 323
  914. #define GLFW_KEY_KP_4 324
  915. #define GLFW_KEY_KP_5 325
  916. #define GLFW_KEY_KP_6 326
  917. #define GLFW_KEY_KP_7 327
  918. #define GLFW_KEY_KP_8 328
  919. #define GLFW_KEY_KP_9 329
  920. #define GLFW_KEY_KP_DECIMAL 330
  921. #define GLFW_KEY_KP_DIVIDE 331
  922. #define GLFW_KEY_KP_MULTIPLY 332
  923. #define GLFW_KEY_KP_SUBTRACT 333
  924. #define GLFW_KEY_KP_ADD 334
  925. #define GLFW_KEY_KP_ENTER 335
  926. #define GLFW_KEY_KP_EQUAL 336
  927. */
  928. int key;
  929. switch (ev.key)
  930. {
  931. case '\r': key = GLFW_KEY_ENTER; break;
  932. case '\t': key = GLFW_KEY_TAB; break;
  933. case kKeyBackspace: key = GLFW_KEY_BACKSPACE; break;
  934. case kKeyEscape: key = GLFW_KEY_ESCAPE; break;
  935. case kKeyDelete: key = GLFW_KEY_DELETE; break;
  936. case kKeyF1: key = GLFW_KEY_F1; break;
  937. case kKeyF2: key = GLFW_KEY_F2; break;
  938. case kKeyF3: key = GLFW_KEY_F3; break;
  939. case kKeyF4: key = GLFW_KEY_F4; break;
  940. case kKeyF5: key = GLFW_KEY_F5; break;
  941. case kKeyF6: key = GLFW_KEY_F6; break;
  942. case kKeyF7: key = GLFW_KEY_F7; break;
  943. case kKeyF8: key = GLFW_KEY_F8; break;
  944. case kKeyF9: key = GLFW_KEY_F9; break;
  945. case kKeyF10: key = GLFW_KEY_F10; break;
  946. case kKeyF11: key = GLFW_KEY_F11; break;
  947. case kKeyF12: key = GLFW_KEY_F12; break;
  948. case kKeyLeft: key = GLFW_KEY_LEFT; break;
  949. case kKeyUp: key = GLFW_KEY_UP; break;
  950. case kKeyRight: key = GLFW_KEY_RIGHT; break;
  951. case kKeyDown: key = GLFW_KEY_DOWN; break;
  952. case kKeyPageUp: key = GLFW_KEY_PAGE_UP; break;
  953. case kKeyPageDown: key = GLFW_KEY_PAGE_DOWN; break;
  954. case kKeyHome: key = GLFW_KEY_HOME; break;
  955. case kKeyEnd: key = GLFW_KEY_END; break;
  956. case kKeyInsert: key = GLFW_KEY_INSERT; break;
  957. case kKeyShiftL: key = GLFW_KEY_LEFT_SHIFT; break;
  958. case kKeyShiftR: key = GLFW_KEY_RIGHT_SHIFT; break;
  959. case kKeyControlL: key = GLFW_KEY_LEFT_CONTROL; break;
  960. case kKeyControlR: key = GLFW_KEY_RIGHT_CONTROL; break;
  961. case kKeyAltL: key = GLFW_KEY_LEFT_ALT; break;
  962. case kKeyAltR: key = GLFW_KEY_RIGHT_ALT; break;
  963. case kKeySuperL: key = GLFW_KEY_LEFT_SUPER; break;
  964. case kKeySuperR: key = GLFW_KEY_RIGHT_SUPER; break;
  965. case kKeyMenu: key = GLFW_KEY_MENU; break;
  966. case kKeyCapsLock: key = GLFW_KEY_CAPS_LOCK; break;
  967. case kKeyScrollLock: key = GLFW_KEY_SCROLL_LOCK; break;
  968. case kKeyNumLock: key = GLFW_KEY_NUM_LOCK; break;
  969. case kKeyPrintScreen: key = GLFW_KEY_PRINT_SCREEN; break;
  970. case kKeyPause: key = GLFW_KEY_PAUSE; break;
  971. default:
  972. // glfw expects uppercase
  973. if (ev.key >= 'a' && ev.key <= 'z')
  974. key = ev.key - ('a' - 'A');
  975. else
  976. key = ev.key;
  977. break;
  978. }
  979. const ScopedContext sc(this, mods);
  980. return context->event->handleKey(lastMousePos, key, ev.keycode, action, mods);
  981. }
  982. void onResize(const ResizeEvent& ev) override
  983. {
  984. UI::onResize(ev);
  985. if (context->window != nullptr)
  986. WindowSetInternalSize(context->window, rack::math::Vec(ev.size.getWidth(), ev.size.getHeight()));
  987. const double scaleFactor = getScaleFactor();
  988. const int width = static_cast<int>(ev.size.getWidth() / scaleFactor + 0.5);
  989. const int height = static_cast<int>(ev.size.getHeight() / scaleFactor + 0.5);
  990. char sizeString[64] = {};
  991. std::snprintf(sizeString, sizeof(sizeString), "%d:%d", width, height);
  992. setState("windowSize", sizeString);
  993. if (rack::isStandalone())
  994. rack::settings::windowSize = rack::math::Vec(width, height);
  995. }
  996. void uiFocus(const bool focus, CrossingMode) override
  997. {
  998. #ifdef DPF_RUNTIME_TESTING
  999. if (inSelfTest) return;
  1000. #endif
  1001. if (!focus)
  1002. {
  1003. const ScopedContext sc(this, 0);
  1004. context->event->handleLeave();
  1005. }
  1006. }
  1007. void uiFileBrowserSelected(const char* const filename) override
  1008. {
  1009. if (filename == nullptr)
  1010. return;
  1011. rack::contextSet(context);
  1012. WindowParametersRestore(context->window);
  1013. std::string sfilename = filename;
  1014. if (saving)
  1015. {
  1016. const bool uncompressed = savingUncompressed;
  1017. savingUncompressed = false;
  1018. if (rack::system::getExtension(sfilename) != ".vcv")
  1019. sfilename += ".vcv";
  1020. try {
  1021. if (uncompressed)
  1022. {
  1023. context->engine->prepareSave();
  1024. if (json_t* const rootJ = context->patch->toJson())
  1025. {
  1026. if (FILE* const file = std::fopen(sfilename.c_str(), "w"))
  1027. {
  1028. json_dumpf(rootJ, file, JSON_INDENT(2));
  1029. std::fclose(file);
  1030. }
  1031. json_decref(rootJ);
  1032. }
  1033. }
  1034. else
  1035. {
  1036. context->patch->save(sfilename);
  1037. }
  1038. }
  1039. catch (rack::Exception& e) {
  1040. std::string message = rack::string::f("Could not save patch: %s", e.what());
  1041. asyncDialog::create(message.c_str());
  1042. return;
  1043. }
  1044. }
  1045. else
  1046. {
  1047. try {
  1048. context->patch->load(sfilename);
  1049. } catch (rack::Exception& e) {
  1050. std::string message = rack::string::f("Could not load patch: %s", e.what());
  1051. asyncDialog::create(message.c_str());
  1052. return;
  1053. }
  1054. }
  1055. context->patch->path = sfilename;
  1056. context->patch->pushRecentPath(sfilename);
  1057. context->history->setSaved();
  1058. #ifdef DISTRHO_OS_WASM
  1059. rack::syncfs();
  1060. #else
  1061. rack::settings::save();
  1062. #endif
  1063. }
  1064. #if 0
  1065. void uiReshape(const uint width, const uint height) override
  1066. {
  1067. glEnable(GL_BLEND);
  1068. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  1069. glMatrixMode(GL_PROJECTION);
  1070. glLoadIdentity();
  1071. glOrtho(0.0, width, 0.0, height, -1.0, 1.0);
  1072. glViewport(0, 0, width, height);
  1073. glMatrixMode(GL_MODELVIEW);
  1074. glLoadIdentity();
  1075. }
  1076. #endif
  1077. private:
  1078. /**
  1079. Set our UI class as non-copyable and add a leak detector just in case.
  1080. */
  1081. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CardinalUI)
  1082. };
  1083. /* ------------------------------------------------------------------------------------------------------------
  1084. * UI entry point, called by DPF to create a new UI instance. */
  1085. UI* createUI()
  1086. {
  1087. return new CardinalUI();
  1088. }
  1089. // -----------------------------------------------------------------------------------------------------------
  1090. END_NAMESPACE_DISTRHO