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.

167 lines
4.4KB

  1. /*
  2. * Carla Bridge UI
  3. * Copyright (C) 2011-2014 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. #ifndef CARLA_BRIDGE_UI_HPP_INCLUDED
  18. #define CARLA_BRIDGE_UI_HPP_INCLUDED
  19. #include "CarlaBridgeToolkit.hpp"
  20. #include "CarlaLibUtils.hpp"
  21. #include "CarlaPipeUtils.hpp"
  22. #include "CarlaString.hpp"
  23. #ifdef BRIDGE_LV2
  24. # include "lv2/atom.h"
  25. # include "lv2/urid.h"
  26. #endif
  27. //#include "CarlaBridgeToolkit.hpp"
  28. //#include "CarlaLibUtils.hpp"
  29. CARLA_BRIDGE_START_NAMESPACE
  30. /*!
  31. * @defgroup CarlaBridgeUIAPI Carla UI Bridge API
  32. *
  33. * The Carla UI Bridge API.
  34. * @{
  35. */
  36. // -----------------------------------------------------------------------
  37. class CarlaBridgeUI : public CarlaPipeClient
  38. {
  39. protected:
  40. /*!
  41. * Constructor.
  42. */
  43. CarlaBridgeUI() noexcept;
  44. /*!
  45. * Destructor.
  46. */
  47. virtual ~CarlaBridgeUI() /*noexcept*/;
  48. // ---------------------------------------------------------------------
  49. bool libOpen(const char* const filename) noexcept;
  50. void* libSymbol(const char* const symbol) const noexcept;
  51. const char* libError() const noexcept;
  52. // ---------------------------------------------------------------------
  53. // DSP Callbacks
  54. virtual void dspParameterChanged(const uint32_t index, const float value) = 0;
  55. virtual void dspProgramChanged(const uint32_t index) = 0;
  56. virtual void dspMidiProgramChanged(const uint32_t bank, const uint32_t program) = 0;
  57. virtual void dspStateChanged(const char* const key, const char* const value) = 0;
  58. virtual void dspNoteReceived(const bool onOff, const uint8_t channel, const uint8_t note, const uint8_t velocity) = 0;
  59. #ifdef BRIDGE_LV2
  60. virtual void dspAtomReceived(const uint32_t index, const LV2_Atom* const atom) = 0;
  61. virtual void dspURIDReceived(const LV2_URID urid, const char* const uri) = 0;
  62. #endif
  63. public:
  64. // ---------------------------------------------------------------------
  65. // UI initialization
  66. virtual bool init(const int argc, const char* argv[]);
  67. virtual void exec(const bool showUI);
  68. virtual void idleUI() {}
  69. // ---------------------------------------------------------------------
  70. // UI management
  71. /*!
  72. * Get the widget associated with this UI.
  73. * This can be a Gtk widget, Qt widget or a native Window handle depending on the compile target.
  74. */
  75. virtual void* getWidget() const noexcept = 0;
  76. /*!
  77. * Options.
  78. */
  79. struct Options {
  80. /*!
  81. * UI is resizable by the user.
  82. * The UI can still sometimes resize itself internally if this is false.
  83. */
  84. bool isResizable;
  85. /*!
  86. * Use the Carla PRO theme if possible.
  87. */
  88. bool useTheme;
  89. /*!
  90. * Use the Carla PRO theme colors if possible.
  91. * This implies useTheme to be true.
  92. */
  93. bool useThemeColors;
  94. /*!
  95. * Window title.
  96. */
  97. CarlaString windowTitle;
  98. /*!
  99. * Transient window id (parent), null if zero.
  100. */
  101. uintptr_t transientWindowId;
  102. /*!
  103. * Constructor for default options.
  104. */
  105. Options() noexcept
  106. : isResizable(true),
  107. useTheme(true),
  108. useThemeColors(true),
  109. windowTitle("TestUI"),
  110. transientWindowId(0) {}
  111. };
  112. /*!
  113. * Get options associated with this UI.
  114. */
  115. virtual const Options& getOptions() const noexcept = 0;
  116. // ---------------------------------------------------------------------
  117. protected:
  118. bool fQuitReceived;
  119. #ifdef BRIDGE_LV2
  120. bool fUridMapComplete;
  121. #endif
  122. CarlaBridgeToolkit* fToolkit;
  123. lib_t fLib;
  124. CarlaString fLibFilename;
  125. /*! @internal */
  126. bool msgReceived(const char* const msg) noexcept override;
  127. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaBridgeUI)
  128. };
  129. /**@}*/
  130. // -----------------------------------------------------------------------
  131. CARLA_BRIDGE_END_NAMESPACE
  132. #endif // CARLA_BRIDGE_UI_HPP_INCLUDED