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.

166 lines
4.6KB

  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. #include "lv2/atom.h"
  24. #include "lv2/urid.h"
  25. CARLA_BRIDGE_START_NAMESPACE
  26. /*!
  27. * @defgroup CarlaBridgeUIAPI Carla UI Bridge API
  28. *
  29. * The Carla UI Bridge API.
  30. * @{
  31. */
  32. // -----------------------------------------------------------------------
  33. class CarlaBridgeUI : public CarlaPipeClient
  34. {
  35. protected:
  36. /*!
  37. * Constructor.
  38. */
  39. CarlaBridgeUI() noexcept;
  40. /*!
  41. * Destructor.
  42. */
  43. virtual ~CarlaBridgeUI() /*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. virtual void uiOptionsChanged(const double sampleRate, const bool useTheme, const bool useThemeColors, const char* const windowTitle, uintptr_t transientWindowId) = 0;
  58. public:
  59. // ---------------------------------------------------------------------
  60. // UI initialization
  61. virtual bool init(const int argc, const char* argv[]);
  62. virtual void exec(const bool showUI);
  63. virtual void idleUI() {}
  64. // ---------------------------------------------------------------------
  65. // UI management
  66. /*!
  67. * Get the widget associated with this UI.
  68. * This can be a Gtk widget, Qt widget or a native Window handle depending on the compile target.
  69. */
  70. virtual void* getWidget() const noexcept = 0;
  71. /*!
  72. * TESTING
  73. */
  74. virtual void uiResized(const uint width, const uint height) = 0;
  75. /*!
  76. * Options.
  77. */
  78. struct Options {
  79. /*!
  80. * UI is resizable by the user.
  81. * The UI can still sometimes resize itself internally if this is false.
  82. */
  83. bool isResizable;
  84. /*!
  85. * Use the Carla PRO theme if possible.
  86. */
  87. bool useTheme;
  88. /*!
  89. * Use the Carla PRO theme colors if possible.
  90. * This implies useTheme to be true.
  91. */
  92. bool useThemeColors;
  93. /*!
  94. * Window title.
  95. */
  96. CarlaString windowTitle;
  97. /*!
  98. * Transient window id (parent), null if zero.
  99. */
  100. uintptr_t transientWindowId;
  101. /*!
  102. * Constructor for default options.
  103. */
  104. Options() noexcept
  105. : isResizable(true),
  106. useTheme(true),
  107. useThemeColors(true),
  108. windowTitle("TestUI"),
  109. transientWindowId(0) {}
  110. };
  111. /*!
  112. * Get options associated with this UI.
  113. */
  114. virtual const Options& getOptions() const noexcept = 0;
  115. // ---------------------------------------------------------------------
  116. protected:
  117. bool fQuitReceived;
  118. bool fGotOptions;
  119. int fLastMsgTimer;
  120. CarlaBridgeToolkit* fToolkit;
  121. lib_t fLib;
  122. CarlaString fLibFilename;
  123. /*! @internal */
  124. bool msgReceived(const char* const msg) noexcept override;
  125. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaBridgeUI)
  126. };
  127. /**@}*/
  128. // -----------------------------------------------------------------------
  129. CARLA_BRIDGE_END_NAMESPACE
  130. #endif // CARLA_BRIDGE_UI_HPP_INCLUDED