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.

163 lines
4.5KB

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