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.

CarlaBridgeUI.hpp 4.5KB

10 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. * Options.
  73. */
  74. struct Options {
  75. /*!
  76. * UI is resizable by the user.
  77. * The UI can still sometimes resize itself internally if this is false.
  78. */
  79. bool isResizable;
  80. /*!
  81. * Use the Carla PRO theme if possible.
  82. */
  83. bool useTheme;
  84. /*!
  85. * Use the Carla PRO theme colors if possible.
  86. * This implies useTheme to be true.
  87. */
  88. bool useThemeColors;
  89. /*!
  90. * Window title.
  91. */
  92. CarlaString windowTitle;
  93. /*!
  94. * Transient window id (parent), null if zero.
  95. */
  96. uintptr_t transientWindowId;
  97. /*!
  98. * Constructor for default options.
  99. */
  100. Options() noexcept
  101. : isResizable(true),
  102. useTheme(true),
  103. useThemeColors(true),
  104. windowTitle("TestUI"),
  105. transientWindowId(0) {}
  106. };
  107. /*!
  108. * Get options associated with this UI.
  109. */
  110. virtual const Options& getOptions() const noexcept = 0;
  111. // ---------------------------------------------------------------------
  112. protected:
  113. bool fQuitReceived;
  114. bool fGotOptions;
  115. int fLastMsgTimer;
  116. CarlaBridgeToolkit* fToolkit;
  117. lib_t fLib;
  118. CarlaString fLibFilename;
  119. /*! @internal */
  120. bool msgReceived(const char* const msg) noexcept override;
  121. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaBridgeUI)
  122. };
  123. /**@}*/
  124. // -----------------------------------------------------------------------
  125. CARLA_BRIDGE_END_NAMESPACE
  126. #endif // CARLA_BRIDGE_UI_HPP_INCLUDED