Skip to content

Commit 7d781cd

Browse files
committed
UI: Add new API: _createHiddenButton()
This function creates a hidden clickable area on the editor UI, based on a dedicated transparent PNG image as the button image of DGL::ImageButton.
1 parent eaffe5f commit 7d781cd

File tree

6 files changed

+21734
-18593
lines changed

6 files changed

+21734
-18593
lines changed

src/CetoneUI.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ CCetoneUI::CCetoneUI()
1313
, fImgKnob(Art::knobData, Art::knobWidth, Art::knobHeight, kImageFormatBGRA)
1414
, fImgSwitchButton_ON(Art::buttons_onData, Art::buttons_onWidth, Art::buttons_onHeight, kImageFormatBGR)
1515
, fImgSwitchButton_OFF(Art::buttons_offData, Art::buttons_offWidth, Art::buttons_offHeight, kImageFormatBGR)
16+
, fImgTransparent(Art::transparentData, Art::transparentWidth, Art::transparentHeight, kImageFormatBGRA)
1617
{
1718
/* Initialize NanoVG font and text buffer */
1819
NanoVG::FontId font = fNanoText.createFontFromMemory("Source Sans Regular", Fonts::SourceSans3_RegularData, Fonts::SourceSans3_RegularDataSize, false);

src/CetoneUI.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class CCetoneUI : public DISTRHO::UI,
6161
Image fImgBackground;
6262
Image fImgKnob;
6363
Image fImgSwitchButton_ON, fImgSwitchButton_OFF;
64+
Image fImgTransparent;
6465

6566
// -------------------------------------------------------------------
6667
// Widgets
@@ -99,6 +100,7 @@ class CCetoneUI : public DISTRHO::UI,
99100
void _createSlider(ScopedPointer<ImageSlider>& slider, uint32_t paramId, uint startPosX, uint startPosY, uint endPosX, uint endPosY, float step, bool inverted = false);
100101
void _createSwitchButton(ScopedPointer<ImageSwitch>& switchButton, uint32_t paramId, uint absolutePosX, uint absolutePosY);
101102
void _createButton(ScopedPointer<ImageButton>& button, uint id, Image& imageNormal, Image& imagePressed, uint absolutePosX, uint absolutePosY);
103+
void _createHiddenButton(ScopedPointer<ImageButton>& button, uint id, Size<uint> size, Point<int> absolutePos);
102104

103105
const char* _wave2Str(int wave);
104106
const char* _OscWave2Str(int wave);

src/CetoneUIHelper.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ void CCetoneUI::_createButton(ScopedPointer<ImageButton>& button, uint id, Image
5050
button->setCallback(this);
5151
}
5252

53+
void CCetoneUI::_createHiddenButton(ScopedPointer<ImageButton>& button, uint id, Size<uint> size, Point<int> absolutePos)
54+
{
55+
button = new ImageButton(this, fImgTransparent, fImgTransparent);
56+
button->setId(id);
57+
button->setAbsolutePos(absolutePos);
58+
button->setSize(size);
59+
button->setCallback(this);
60+
}
61+
5362
const char* CCetoneUI::_wave2Str(int wave)
5463
{
5564
switch (wave) {

0 commit comments

Comments
 (0)