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.

CarlaBridgeFormat.hpp 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. virtual void uiOptionsChanged(const double sampleRate, const float uiScale,
  58. const bool useTheme, const bool useThemeColors,
  59. const char* const windowTitle, const 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. * TESTING
  75. */
  76. virtual void uiResized(const uint width, const uint height) = 0;
  77. /*!
  78. * Options.
  79. */
  80. struct Options {
  81. /*!
  82. * UI is resizable by the user.
  83. * The UI can still sometimes resize itself internally if this is false.
  84. */
  85. bool isResizable;
  86. /*!
  87. * Use the Carla PRO theme if possible.
  88. */
  89. bool useTheme;
  90. /*!
  91. * Use the Carla PRO theme colors if possible.
  92. * This implies useTheme to be true.
  93. */
  94. bool useThemeColors;
  95. /*!
  96. * Window title.
  97. */
  98. CarlaString windowTitle;
  99. /*!
  100. * Transient window id (parent), zero if unset.
  101. */
  102. uintptr_t transientWindowId;
  103. /*!
  104. * Constructor for default options.
  105. */
  106. Options() noexcept
  107. : isResizable(true),
  108. useTheme(true),
  109. useThemeColors(true),
  110. windowTitle("TestUI"),
  111. transientWindowId(0) {}
  112. };
  113. /*!
  114. * Get options associated with this UI.
  115. */
  116. virtual const Options& getOptions() const noexcept = 0;
  117. // ---------------------------------------------------------------------
  118. protected:
  119. bool fQuitReceived;
  120. bool fGotOptions;
  121. int fLastMsgTimer;
  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(CarlaBridgeFormat)
  128. };
  129. /**@}*/
  130. // -----------------------------------------------------------------------
  131. CARLA_BRIDGE_UI_END_NAMESPACE
  132. #endif // CARLA_BRIDGE_FORMAT_HPP_INCLUDED