Audio plugin host https://kx.studio/carla
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.

101 lines
2.9KB

  1. /*
  2. * Carla Native Plugin UI launcher
  3. * Copyright (C) 2018 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 2 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 doc/GPL.txt file.
  16. */
  17. #include "dgl/Application.hpp"
  18. #include "dgl/ImageWidgets.hpp"
  19. #include "CarlaNative.h"
  20. #include "ui_launcher_res.hpp"
  21. // --------------------------------------------------------------------------------------------------------------------
  22. START_NAMESPACE_DGL
  23. class CarlaButtonWidget : public Widget,
  24. private ImageButton::Callback
  25. {
  26. public:
  27. CarlaButtonWidget(Window& parent, const NativePluginDescriptor* const d, const NativePluginHandle h)
  28. : Widget(parent),
  29. startButtonImage(ui_launcher_res::carla_uiData,
  30. ui_launcher_res::carla_uiWidth,
  31. ui_launcher_res::carla_uiHeight,
  32. GL_BGR),
  33. startButton(this, startButtonImage),
  34. descriptor(d),
  35. handle(h)
  36. {
  37. startButton.setCallback(this);
  38. setSize(startButtonImage.getSize());
  39. parent.setSize(startButtonImage.getSize());
  40. }
  41. protected:
  42. void onDisplay() override
  43. {
  44. }
  45. void imageButtonClicked(ImageButton* imageButton, int) override
  46. {
  47. if (imageButton != &startButton)
  48. return;
  49. if (descriptor->ui_show != nullptr)
  50. descriptor->ui_show(handle, true);
  51. }
  52. private:
  53. Image startButtonImage;
  54. ImageButton startButton;
  55. const NativePluginDescriptor* const descriptor;
  56. const NativePluginHandle handle;
  57. };
  58. END_NAMESPACE_DGL
  59. // --------------------------------------------------------------------------------------------------------------------
  60. struct CarlaUILauncher {
  61. DGL_NAMESPACE::Application app;
  62. DGL_NAMESPACE::Window window;
  63. CarlaButtonWidget widget;
  64. CarlaUILauncher(const intptr_t winId, const NativePluginDescriptor* const d, const NativePluginHandle h)
  65. : app(),
  66. window(app, winId),
  67. widget(window, d, h) {}
  68. };
  69. CarlaUILauncher* createUILauncher(const intptr_t winId,
  70. const NativePluginDescriptor* const d,
  71. const NativePluginHandle h)
  72. {
  73. return new CarlaUILauncher(winId, d, h);
  74. }
  75. void idleUILauncher(CarlaUILauncher* const ui)
  76. {
  77. ui->app.idle();
  78. }
  79. void destoryUILauncher(CarlaUILauncher* const ui)
  80. {
  81. delete ui;
  82. }
  83. // --------------------------------------------------------------------------------------------------------------------