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.

CarlaBridgeToolkitPlugin.cpp 3.7KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Carla Bridge Toolkit, Plugin version
  3. * Copyright (C) 2011-2013 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 GPL.txt file
  16. */
  17. #include "CarlaBridgeClient.hpp"
  18. #include "CarlaBridgeToolkit.hpp"
  19. #include "CarlaPlugin.hpp"
  20. CARLA_BRIDGE_START_NAMESPACE
  21. static int qargc = 0;
  22. static char* qargv[0] = {};
  23. // -------------------------------------------------------------------------
  24. class CarlaBridgeToolkitPlugin : public CarlaBridgeToolkit/*,
  25. public CarlaBackend::CarlaPluginGUI::Callback*/
  26. {
  27. public:
  28. CarlaBridgeToolkitPlugin(CarlaBridgeClient* const client, const char* const uiTitle)
  29. : CarlaBridgeToolkit(client, uiTitle)
  30. {
  31. carla_debug("CarlaBridgeToolkitPlugin::CarlaBridgeToolkitPlugin(%p, \"%s\")", client, uiTitle);
  32. app = nullptr;
  33. gui = nullptr;
  34. m_uiQuit = false;
  35. init();
  36. }
  37. ~CarlaBridgeToolkitPlugin()
  38. {
  39. carla_debug("CarlaBridgeToolkitPlugin::~CarlaBridgeToolkitPlugin()");
  40. CARLA_ASSERT(! app);
  41. CARLA_ASSERT(! gui);
  42. }
  43. void init()
  44. {
  45. carla_debug("CarlaBridgeToolkitPlugin::init()");
  46. CARLA_ASSERT(! app);
  47. CARLA_ASSERT(! gui);
  48. app = new QApplication(qargc, qargv);
  49. gui = new CarlaBackend::CarlaPluginGUI(nullptr, this);
  50. }
  51. void exec(const bool showGui)
  52. {
  53. carla_debug("CarlaBridgeToolkitPlugin::exec(%s)", bool2str(showGui));
  54. CARLA_ASSERT(app);
  55. CARLA_ASSERT(gui);
  56. CARLA_ASSERT(client);
  57. if (showGui)
  58. {
  59. show();
  60. }
  61. else
  62. {
  63. app->setQuitOnLastWindowClosed(false);
  64. client->sendOscUpdate();
  65. client->sendOscBridgeUpdate();
  66. }
  67. m_uiQuit = showGui;
  68. // Main loop
  69. app->exec();
  70. }
  71. void quit()
  72. {
  73. carla_debug("CarlaBridgeToolkitPlugin::quit()");
  74. CARLA_ASSERT(app);
  75. if (gui)
  76. {
  77. gui->close();
  78. delete gui;
  79. gui = nullptr;
  80. }
  81. if (app)
  82. {
  83. if (! app->closingDown())
  84. app->quit();
  85. delete app;
  86. app = nullptr;
  87. }
  88. }
  89. void show()
  90. {
  91. carla_debug("CarlaBridgeToolkitPlugin::show()");
  92. CARLA_ASSERT(gui);
  93. if (gui && m_uiShow)
  94. gui->setVisible(true);
  95. }
  96. void hide()
  97. {
  98. carla_debug("CarlaBridgeToolkitPlugin::hide()");
  99. CARLA_ASSERT(gui);
  100. if (gui && m_uiShow)
  101. gui->setVisible(false);
  102. }
  103. void resize(const int width, const int height)
  104. {
  105. carla_debug("CarlaBridgeToolkitPlugin::resize(%i, %i)", width, height);
  106. CARLA_ASSERT(gui);
  107. if (gui)
  108. gui->setNewSize(width, height);
  109. }
  110. private:
  111. QApplication* fApp;
  112. bool fQuit;
  113. //CarlaBackend::CarlaPluginGUI* gui;
  114. //void guiClosedCallback();
  115. };
  116. // -------------------------------------------------------------------------
  117. CarlaBridgeToolkit* CarlaBridgeToolkit::createNew(CarlaBridgeClient* const client, const char* const uiTitle)
  118. {
  119. return new CarlaBridgeToolkitPlugin(client, uiTitle);
  120. }
  121. CARLA_BRIDGE_END_NAMESPACE