Skip to content

Commit 8bda37f

Browse files
committed
More Breeze setup, WIP
Signed-off-by: falkTX <[email protected]>
1 parent 889a273 commit 8bda37f

File tree

2 files changed

+138
-0
lines changed

2 files changed

+138
-0
lines changed

opengl/DarkBreeze.cpp

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,93 @@ bool DarkBreezeButton::onMotion(const MotionEvent& ev)
139139

140140
// --------------------------------------------------------------------------------------------------------------------
141141

142+
DarkBreezeCheckBox::DarkBreezeCheckBox(DarkBreeze* const parent)
143+
: NanoSubWidget(parent),
144+
ButtonEventHandler(this)
145+
{
146+
loadSharedResources();
147+
148+
constexpr uint size = kSizeButton + kSizePadding * 2;
149+
setSize(size, size);
150+
151+
setCheckable(true);
152+
}
153+
154+
DarkBreezeCheckBox::~DarkBreezeCheckBox()
155+
{
156+
std::free(label);
157+
}
158+
159+
void DarkBreezeCheckBox::setLabel(const char* const label2)
160+
{
161+
std::free(label);
162+
label = label2 != nullptr ? strdup(label2) : nullptr;
163+
164+
if (label != nullptr && label[0] != '\0')
165+
{
166+
Rectangle<float> bounds;
167+
// fontSize(theme.fontSize);
168+
textBounds(0, 0, label, nullptr, bounds);
169+
170+
const uint width = std::max(getWidth(), d_roundToUnsignedInt(bounds.getWidth()) + kSizePadding * 8);
171+
const uint height = std::max(getHeight(), d_roundToUnsignedInt(bounds.getHeight()) + kSizePadding * 2);
172+
setSize(width, height);
173+
}
174+
}
175+
176+
void DarkBreezeCheckBox::onNanoDisplay()
177+
{
178+
beginPath();
179+
roundedRect(kSizePadding * 4,
180+
kSizePadding * 4,
181+
kSizeButton - kSizePadding * 8,
182+
kSizeButton - kSizePadding * 8,
183+
kSizeRadius);
184+
185+
d_stdout("state %d", getState());
186+
switch (getState())
187+
{
188+
case kButtonStateActive:
189+
fillColor(Color::fromHTML(kColorButtonFillActive));
190+
strokeColor(Color::fromHTML(kColorButtonStrokeActive));
191+
break;
192+
case kButtonStateActiveHover:
193+
fillColor(Color::fromHTML(kColorButtonFillActiveHover));
194+
strokeColor(Color::fromHTML(kColorButtonStrokeActiveHover));
195+
break;
196+
case kButtonStateHover:
197+
fillColor(Color::fromHTML(kColorButtonFillHover));
198+
strokeColor(Color::fromHTML(kColorButtonStrokeHover));
199+
break;
200+
case kButtonStateDefault:
201+
fillColor(Color::fromHTML(kColorButtonFillDefault));
202+
strokeColor(Color::fromHTML(kColorButtonStrokeDefault));
203+
break;
204+
}
205+
206+
fill();
207+
strokeWidth(1);
208+
stroke();
209+
210+
if (label != nullptr && label[0] != '\0')
211+
{
212+
fillColor(Color::fromHTML(kColorText));
213+
// fontSize(theme.fontSize);
214+
textAlign(ALIGN_LEFT|ALIGN_MIDDLE);
215+
text(kSizeButton + kSizePadding, getHeight() / 2, label, nullptr);
216+
}
217+
}
218+
219+
bool DarkBreezeCheckBox::onMouse(const MouseEvent& ev)
220+
{
221+
return mouseEvent(ev);
222+
}
223+
224+
bool DarkBreezeCheckBox::onMotion(const MotionEvent& ev)
225+
{
226+
return motionEvent(ev);
227+
}
228+
229+
// --------------------------------------------------------------------------------------------------------------------
230+
142231
END_NAMESPACE_DGL

opengl/DarkBreeze.hpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,53 @@ class DarkBreezeButton : public NanoSubWidget,
6262

6363
// --------------------------------------------------------------------------------------------------------------------
6464

65+
class DarkBreezeCheckBox : public NanoSubWidget,
66+
public ButtonEventHandler
67+
{
68+
char* label = nullptr;
69+
70+
public:
71+
explicit DarkBreezeCheckBox(DarkBreeze* parent);
72+
~DarkBreezeCheckBox() override;
73+
74+
inline const char* getLabel() const noexcept
75+
{
76+
return label;
77+
}
78+
79+
void setLabel(const char* label);
80+
81+
protected:
82+
void onNanoDisplay() override;
83+
bool onMouse(const MouseEvent& ev) override;
84+
bool onMotion(const MotionEvent& ev) override;
85+
86+
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DarkBreezeCheckBox)
87+
};
88+
89+
// --------------------------------------------------------------------------------------------------------------------
90+
91+
class DarkBreezeLabel : public NanoSubWidget
92+
{
93+
char* label = nullptr;
94+
95+
public:
96+
explicit DarkBreezeLabel(DarkBreeze* parent);
97+
~DarkBreezeLabel() override;
98+
99+
inline const char* getLabel() const noexcept
100+
{
101+
return label;
102+
}
103+
104+
void setLabel(const char* label);
105+
106+
protected:
107+
void onNanoDisplay() override;
108+
109+
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DarkBreezeLabel)
110+
};
111+
112+
// --------------------------------------------------------------------------------------------------------------------
113+
65114
END_NAMESPACE_DGL

0 commit comments

Comments
 (0)