3 * Copyright (C) 2011-2021 Filipe Coelho <falktx@falktx.com>
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.
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.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #ifndef CARLA_BRIDGE_FORMAT_HPP_INCLUDED
19 #define CARLA_BRIDGE_FORMAT_HPP_INCLUDED
21 #include "CarlaBridgeUI.hpp"
23 #include "CarlaLibUtils.hpp"
24 #include "CarlaPipeUtils.hpp"
25 #include "CarlaString.hpp"
32 CARLA_BRIDGE_UI_START_NAMESPACE
35 * @defgroup CarlaBridgeUIAPI Carla UI Bridge API
37 * The Carla UI Bridge API.
41 // -----------------------------------------------------------------------
43 class CarlaBridgeFormat
: public CarlaPipeClient
49 CarlaBridgeFormat() noexcept
;
54 virtual ~CarlaBridgeFormat() /*noexcept*/;
56 // ---------------------------------------------------------------------
58 bool libOpen(const char* filename
) noexcept
;
59 void* libSymbol(const char* symbol
) const noexcept
;
60 const char* libError() const noexcept
;
62 // ---------------------------------------------------------------------
65 virtual void dspParameterChanged(uint32_t index
, float value
) = 0;
66 virtual void dspParameterChanged(const char* uri
, float value
) = 0;
67 virtual void dspProgramChanged(uint32_t index
) = 0;
68 virtual void dspMidiProgramChanged(uint32_t bank
, uint32_t program
) = 0;
69 virtual void dspStateChanged(const char* key
, const char* value
) = 0;
70 virtual void dspNoteReceived(bool onOff
, uint8_t channel
, uint8_t note
, uint8_t velocity
) = 0;
72 virtual void dspAtomReceived(uint32_t index
, const LV2_Atom
* atom
) = 0;
73 virtual void dspURIDReceived(LV2_URID urid
, const char* uri
) = 0;
75 struct BridgeFormatOptions
{
83 const char* windowTitle
;
84 uintptr_t transientWindowId
;
87 virtual void uiOptionsChanged(const BridgeFormatOptions
& opts
) = 0;
90 // ---------------------------------------------------------------------
93 virtual bool init(int argc
, const char* argv
[]);
94 virtual void exec(bool showUI
);
95 virtual void idleUI() {}
97 // ---------------------------------------------------------------------
101 * Get the widget associated with this UI.
102 * This can be a Gtk widget, Qt widget or a native Window handle depending on the compile target.
104 virtual void* getWidget() const noexcept
= 0;
110 virtual void setScaleFactor(double scaleFactor
) = 0;
116 virtual void uiResized(uint width
, uint height
) = 0;
123 * UI is standalone, not controlled by another application.
128 * UI is resizable by the user.
129 * The UI can still sometimes resize itself internally if this is false.
134 * Use the Carla PRO theme if possible.
139 * Use the Carla PRO theme colors if possible.
140 * This implies useTheme to be true.
147 CarlaString windowTitle
;
150 * Transient window id (parent), zero if unset.
152 uintptr_t transientWindowId
;
155 * Constructor for default options.
158 : isStandalone(true),
161 useThemeColors(true),
162 windowTitle("TestUI"),
163 transientWindowId(0) {}
167 * Get options associated with this UI.
169 virtual const Options
& getOptions() const noexcept
= 0;
171 // ---------------------------------------------------------------------
177 CarlaBridgeToolkit
* fToolkit
;
180 CarlaString fLibFilename
;
181 std::vector
<uint8_t> fBase64ReservedChunk
;
184 bool msgReceived(const char* msg
) noexcept override
;
186 CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaBridgeFormat
)
191 // -----------------------------------------------------------------------
193 CARLA_BRIDGE_UI_END_NAMESPACE
195 #endif // CARLA_BRIDGE_FORMAT_HPP_INCLUDED