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.

178 lines
4.8KB

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