Skip to content

Commit 4889ed3

Browse files
committed
UI redesign: first draft
1 parent e487c69 commit 4889ed3

22 files changed

+2297
-2336
lines changed

Resources/Fonts/IconFont.ttf

312 Bytes
Binary file not shown.

Source/Components/Buttons.cpp

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -83,60 +83,6 @@ void MainToolbarButton::mouseExit(MouseEvent const& e)
8383
}
8484
#endif
8585

86-
void ToolbarRadioButton::paint(Graphics& g)
87-
{
88-
bool const mouseOver = isOver();
89-
bool const active = mouseOver || isDown() || getToggleState();
90-
91-
auto const flatOnLeft = isConnectedOnLeft();
92-
auto const flatOnRight = isConnectedOnRight();
93-
auto const flatOnTop = isConnectedOnTop();
94-
auto const flatOnBottom = isConnectedOnBottom();
95-
96-
auto const backgroundColour = (active ? PlugDataColours::toolbarHoverColour : PlugDataColours::toolbarBackgroundColour).contrasting(mouseOver && !getToggleState() ? 0.0f : 0.035f);
97-
98-
auto bounds = getLocalBounds().toFloat();
99-
bounds = bounds.reduced(0.0f, bounds.proportionOfHeight(0.17f));
100-
101-
g.setColour(backgroundColour);
102-
Path p;
103-
p.addRoundedRectangle(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), Corners::defaultCornerRadius, Corners::defaultCornerRadius,
104-
!(flatOnLeft || flatOnTop),
105-
!(flatOnRight || flatOnTop),
106-
!(flatOnLeft || flatOnBottom),
107-
!(flatOnRight || flatOnBottom));
108-
g.fillPath(p);
109-
110-
auto const textColour = PlugDataColours::toolbarTextColour.withMultipliedAlpha(isEnabled() ? 1.0f : 0.5f);
111-
112-
g.setFont(Fonts::getIconFont().withHeight(getHeight() / 2.8));
113-
g.setColour(textColour);
114-
g.drawText(getButtonText(), getLocalBounds(), Justification::centred);
115-
}
116-
117-
// On macOS, we need to make sure that dragging any of these buttons doesn't drag the whole titlebar
118-
#if JUCE_MAC
119-
void ToolbarRadioButton::mouseEnter(MouseEvent const& e)
120-
{
121-
if (auto const* topLevel = getTopLevelComponent()) {
122-
if (auto* peer = topLevel->getPeer()) {
123-
OSUtils::setWindowMovable(peer, false);
124-
}
125-
}
126-
TextButton::mouseEnter(e);
127-
}
128-
129-
void ToolbarRadioButton::mouseExit(MouseEvent const& e)
130-
{
131-
if (auto const* topLevel = getTopLevelComponent()) {
132-
if (auto* peer = topLevel->getPeer()) {
133-
OSUtils::setWindowMovable(peer, true);
134-
}
135-
}
136-
TextButton::mouseExit(e);
137-
}
138-
#endif
139-
14086
bool SmallIconButton::hitTest(int const x, int const y)
14187
{
14288
if (getLocalBounds().reduced(2).contains(x, y))

Source/Components/Buttons.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ class MainToolbarButton final : public TextButton {
2828
#endif
2929
};
3030

31-
class ToolbarRadioButton final : public TextButton {
32-
33-
public:
34-
using TextButton::TextButton;
35-
36-
void paint(Graphics& g) override;
37-
38-
// On macOS, we need to make sure that dragging any of these buttons doesn't drag the whole titlebar
39-
#if JUCE_MAC
40-
void mouseEnter(MouseEvent const& e) override;
41-
void mouseExit(MouseEvent const& e) override;
42-
#endif
43-
};
44-
4531
class SmallIconButton : public TextButton {
4632
using TextButton::TextButton;
4733

Source/Constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ struct Icons {
6666
static inline String const DevTools = "{";
6767
static inline String const Help = "\\";
6868
static inline String const Checkmark = "_";
69+
static inline String const Palette = CharPointer_UTF8 ("\xc3\x8b");
6970

7071
static inline String const SavePatch = "Z";
7172
static inline String const ClosePatch = "[";
@@ -379,7 +380,6 @@ enum CommandIDs {
379380
ShowHelp,
380381
OpenObjectBrowser,
381382
ToggleDSP,
382-
ShowCommandInput,
383383
NumItems // <-- the total number of items in this enum
384384
};
385385

Source/Dialogs/AudioOutputSettings.h

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -122,84 +122,85 @@ class LimiterSettings final : public Component {
122122
TextButton four = TextButton("3db");
123123
};
124124

125-
class AudioOutputSettings final : public Component {
126-
125+
class AudioSettingsCallout final : public Component {
127126
public:
128-
enum Type {
129-
Limiter,
130-
Oversampling
131-
};
132-
133-
AudioOutputSettings(PluginProcessor* pd, AudioOutputSettings::Type const typeToShow, std::function<void()> const& changeCallback)
134-
: limiterSettings(SettingsFile::getInstance()->getProperty<int>("limiter_threshold"))
127+
explicit AudioSettingsCallout(PluginEditor* editor)
128+
: pd(editor->pd)
129+
, limiterSettings(SettingsFile::getInstance()->getProperty<int>("limiter_threshold"))
135130
, oversampleSettings(std::clamp(SettingsFile::getInstance()->getProperty<int>("oversampling"), 0, 3))
136-
, type(typeToShow)
137-
, onChange(changeCallback)
138-
{
139-
if (type == Limiter) {
140-
addAndMakeVisible(limiterSettings);
141-
limiterSettings.onChange = [this, pd](int const value) {
142-
pd->setLimiterThreshold(value);
143-
onChange();
144-
};
145-
} else {
146-
addAndMakeVisible(oversampleSettings);
147-
oversampleSettings.onChange = [this, pd](int const value) {
148-
pd->setOversampling(value);
149-
onChange();
150-
};
151-
}
152-
153-
setSize(170, 60);
154-
}
155-
156-
~AudioOutputSettings() override
157131
{
158-
isShowing = false;
132+
limiterLabel.setText("Limiter", dontSendNotification);
133+
limiterLabel.setFont(Fonts::getSemiBoldFont().withHeight(13.5f));
134+
addAndMakeVisible(limiterLabel);
135+
136+
limiterSettings.onChange = [this](int const value) {
137+
pd->setLimiterThreshold(value);
138+
};
139+
addAndMakeVisible(limiterSettings);
140+
141+
oversamplingLabel.setText("Oversampling", dontSendNotification);
142+
oversamplingLabel.setFont(Fonts::getSemiBoldFont().withHeight(13.5f));
143+
addAndMakeVisible(oversamplingLabel);
144+
145+
oversampleSettings.onChange = [this, editor](int const value) {
146+
pd->setOversampling(value);
147+
editor->audioToolbar->updateOversampling();
148+
};
149+
addAndMakeVisible(oversampleSettings);
150+
151+
audioSettingsButton.setButtonText("Audio Settings...");
152+
audioSettingsButton.onClick = [this, editor] {
153+
Dialogs::showSettingsDialog(editor);
154+
closeCalloutBox();
155+
};
156+
157+
audioSettingsButton.setColour(TextButton::textColourOffId, PlugDataColours::popupMenuTextColour);
158+
audioSettingsButton.setColour(TextButton::textColourOnId, PlugDataColours::popupMenuTextColour);
159+
audioSettingsButton.setColour(TextButton::buttonColourId, PlugDataColours::popupMenuBackgroundColour.contrasting(0.04f));
160+
audioSettingsButton.setColour(TextButton::buttonOnColourId, PlugDataColours::popupMenuBackgroundColour.contrasting(0.075f));
161+
audioSettingsButton.setColour(ComboBox::outlineColourId, Colours::transparentBlack);
162+
addAndMakeVisible(audioSettingsButton);
163+
164+
setSize(200, 146);
159165
}
160166

161167
void resized() override
162168
{
163-
auto bounds = getLocalBounds().reduced(4.0f).withTrimmedTop(24);
169+
auto b = getLocalBounds().reduced(10, 8);
170+
constexpr int labelHeight = 18;
171+
constexpr int selectorHeight = 28;
172+
constexpr int gap = 6;
164173

165-
if (type == Limiter) {
166-
limiterSettings.setBounds(bounds.removeFromTop(28));
167-
} else {
168-
oversampleSettings.setBounds(bounds.removeFromTop(28));
169-
}
170-
}
174+
limiterLabel.setBounds(b.removeFromTop(labelHeight));
175+
limiterSettings.setBounds(b.removeFromTop(selectorHeight));
176+
b.removeFromTop(gap);
171177

172-
void paint(Graphics& g) override
173-
{
174-
if (type == Limiter) {
175-
g.setColour(PlugDataColours::popupMenuTextColour);
176-
g.setFont(Fonts::getBoldFont().withHeight(15));
177-
g.drawText("Limiter Threshold", 0, 0, getWidth(), 24, Justification::centred);
178-
} else {
179-
g.setColour(PlugDataColours::popupMenuTextColour);
180-
g.setFont(Fonts::getBoldFont().withHeight(15));
181-
g.drawText("Oversampling", 0, 0, getWidth(), 24, Justification::centred);
182-
}
178+
oversamplingLabel.setBounds(b.removeFromTop(labelHeight));
179+
oversampleSettings.setBounds(b.removeFromTop(selectorHeight));
180+
b.removeFromTop(gap + 4);
183181

184-
g.setColour(PlugDataColours::toolbarOutlineColour);
185-
g.drawLine(4, 24, getWidth() - 8, 24);
182+
audioSettingsButton.setBounds(b.removeFromTop(selectorHeight - 4));
186183
}
187184

188-
static void show(PluginEditor* editor, Rectangle<int> const bounds, AudioOutputSettings::Type typeToShow, std::function<void()> changeCallback = [] { })
185+
void closeCalloutBox()
189186
{
190-
if (isShowing)
191-
return;
192-
193-
isShowing = true;
194-
195-
auto audioOutputSettings = std::make_unique<AudioOutputSettings>(editor->pd, typeToShow, changeCallback);
196-
editor->showCalloutBox(std::move(audioOutputSettings), bounds);
187+
MessageManager::callAsync([_callout = SafePointer(findParentComponentOfClass<CallOutBox>())]() {
188+
if (_callout)
189+
_callout->dismiss();
190+
});
197191
}
198192

199193
private:
200-
static inline bool isShowing = false;
194+
PluginProcessor* pd;
195+
196+
Label limiterLabel;
201197
LimiterSettings limiterSettings;
198+
199+
Label oversamplingLabel;
202200
OversampleSettings oversampleSettings;
203-
Type type;
204-
std::function<void()> onChange;
201+
202+
TextButton audioSettingsButton;
203+
204+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AudioSettingsCallout)
205205
};
206+

Source/Objects/GraphOnParent.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ class GraphOnParent final : public ObjectBase {
148148
});
149149
}
150150

151+
bool showParametersWhenSelected() override
152+
{
153+
return false;
154+
}
155+
151156
void update() override
152157
{
153158
if (auto glist = ptr.get<t_canvas>()) {

0 commit comments

Comments
 (0)