Skip to content

Commit 473cd2b

Browse files
committed
Control panel: UI improvements.
* Implemented sliders' material lookAndFeel; * Material lookAndFeel have been applied to sliders; * Improved UI layout for panel. * Adjusted positioning of elements during resizing. * New icon for "Mute" button;
1 parent 956e9a7 commit 473cd2b

9 files changed

Lines changed: 384 additions & 147 deletions

File tree

β€ŽJuceLibraryCode/BinaryData.cppβ€Ž

Lines changed: 19 additions & 54 deletions
Large diffs are not rendered by default.

β€ŽJuceLibraryCode/BinaryData.hβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ namespace BinaryData
169169
const int IntanIcon_pngSize = 16352;
170170

171171
extern const char* muteoff_png;
172-
const int muteoff_pngSize = 2034;
172+
const int muteoff_pngSize = 637;
173173

174174
extern const char* muteon_png;
175-
const int muteon_pngSize = 1570;
175+
const int muteon_pngSize = 532;
176176

177177
extern const char* MergerA01_png;
178178
const int MergerA01_pngSize = 5609;

β€ŽResources/Images/Buttons/muteoff.pngβ€Ž

100644100755
-1.47 KB
Loading

β€ŽResources/Images/Buttons/muteon.pngβ€Ž

100644100755
-933 Bytes
Loading

β€ŽSource/Processors/AudioNode/AudioEditor.cppβ€Ž

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,25 @@
2424
#include "AudioEditor.h"
2525
#include "../../Audio/AudioComponent.h"
2626
#include "../../AccessClass.h"
27+
#include "../../UI/LookAndFeel/MaterialSliderLookAndFeel.h"
28+
29+
30+
static const Colour COLOUR_SLIDER_TRACK (Colour::fromRGB (92, 92, 92));
31+
static const Colour COLOUR_SLIDER_TRACK_FILL (Colour::fromRGB (255, 255, 255));
32+
33+
static const Font FONT_LABEL ("Small Text", 12, Font::plain);
34+
2735

2836
MuteButton::MuteButton()
2937
: ImageButton ("MuteButton")
3038
{
3139
Image offimage = ImageCache::getFromMemory (BinaryData::muteoff_png, BinaryData::muteoff_pngSize);
32-
Image onimage = ImageCache::getFromMemory (BinaryData::muteon_png, BinaryData::muteon_pngSize);
40+
Image onimage = ImageCache::getFromMemory (BinaryData::muteon_png, BinaryData::muteon_pngSize);
3341

3442
setImages (false, true, true,
3543
offimage, 1.0f, Colours::white.withAlpha (0.0f),
3644
offimage, 1.0f, Colours::black.withAlpha (0.0f),
37-
onimage, 1.0f, Colours::white.withAlpha (0.0f));
45+
onimage, 1.0f, Colours::lightgrey);
3846

3947
setClickingTogglesState (true);
4048

@@ -52,8 +60,7 @@ AudioWindowButton::AudioWindowButton()
5260
{
5361
setClickingTogglesState (true);
5462

55-
font = Font ("Small Text", 12, Font::plain);
56-
textString = "AUDIO";
63+
textString = ":AUDIO";
5764
setTooltip ("Change the buffer size");
5865
}
5966

@@ -70,8 +77,10 @@ void AudioWindowButton::paintButton (Graphics& g, bool isMouseOver, bool isButto
7077
else
7178
g.setColour (Colours::lightgrey);
7279

73-
g.setFont (font);
74-
g.drawSingleLineText (textString, 0, 15);
80+
const bool isLatencyLabelVisible = getParentComponent()->getWidth() >= 450;
81+
auto textToDraw = isLatencyLabelVisible ? textString : textString.fromLastOccurrenceOf (":", false, true);
82+
g.setFont (FONT_LABEL);
83+
g.drawSingleLineText (textToDraw, 0, 15);
7584
}
7685

7786

@@ -99,18 +108,27 @@ AudioEditor::AudioEditor (AudioNode* owner)
99108
addAndMakeVisible (audioWindowButton);
100109

101110
volumeSlider = new Slider ("Volume Slider");
102-
volumeSlider->setRange (0,100,1);
103-
volumeSlider->addListener (this);
111+
volumeSlider->setSliderStyle (Slider::LinearHorizontal);
104112
volumeSlider->setTextBoxStyle (Slider::NoTextBox,
105113
false, 0, 0);
106-
volumeSlider->setColour (Slider::trackColourId, Colours::yellow);
114+
volumeSlider->setRange (0, 100, 1);
115+
volumeSlider->setColour (Slider::backgroundColourId, COLOUR_SLIDER_TRACK);
116+
volumeSlider->setColour (Slider::trackColourId, COLOUR_SLIDER_TRACK_FILL);
117+
volumeSlider->setColour (Slider::thumbColourId, COLOUR_SLIDER_TRACK_FILL);
118+
volumeSlider->setLookAndFeel (materialSliderLookAndFeel);
119+
volumeSlider->addListener (this);
107120
addAndMakeVisible (volumeSlider);
108121

109122
noiseGateSlider = new Slider ("Noise Gate Slider");
110-
noiseGateSlider->setRange (0,100,1);
111-
noiseGateSlider->addListener (this);
123+
volumeSlider->setSliderStyle (Slider::LinearHorizontal);
112124
noiseGateSlider->setTextBoxStyle (Slider::NoTextBox,
113125
false, 0, 0);
126+
noiseGateSlider->setRange (0,100,1);
127+
noiseGateSlider->setColour (Slider::backgroundColourId, COLOUR_SLIDER_TRACK);
128+
noiseGateSlider->setColour (Slider::trackColourId, COLOUR_SLIDER_TRACK_FILL);
129+
noiseGateSlider->setColour (Slider::thumbColourId, COLOUR_SLIDER_TRACK_FILL);
130+
noiseGateSlider->setLookAndFeel (materialSliderLookAndFeel);
131+
noiseGateSlider->addListener (this);
114132
addAndMakeVisible (noiseGateSlider);
115133
}
116134

@@ -122,14 +140,24 @@ AudioEditor::~AudioEditor()
122140

123141
void AudioEditor::resized()
124142
{
125-
const int height = getHeight();
126-
const int sliderWidth = 50;
127-
const int sliderHeight = height - 5;
128-
129-
muteButton->setBounds (0, 5, 30, 25);
130-
volumeSlider->setBounds (35, 8, sliderWidth, sliderHeight);
131-
noiseGateSlider->setBounds (85, 8, sliderWidth, sliderHeight);
132-
audioWindowButton->setBounds (140, 5, 200, height);
143+
const int width = getWidth();
144+
const int height = getHeight();
145+
146+
// Since width of the label on button is always the same, we should reserve it.
147+
const bool isLatencyLabelVisible = width >= 450;
148+
const int audioWindowButtonWidth = isLatencyLabelVisible ? 110 : 60;
149+
const int gateLabelWidth = 45;
150+
151+
const int availableWidth = width - audioWindowButtonWidth - gateLabelWidth;
152+
const int sliderWidth = availableWidth * 0.4;
153+
const int sliderHeight = height - 6;
154+
const int sliderY = (height - sliderHeight) / 2;
155+
const int margin = availableWidth * 0.03;
156+
157+
muteButton->setBounds (margin, 5, 20, 20);
158+
volumeSlider->setBounds (margin + 30, sliderY, sliderWidth, sliderHeight);
159+
noiseGateSlider->setBounds (volumeSlider->getRight() + margin + gateLabelWidth, sliderY, sliderWidth, sliderHeight);
160+
audioWindowButton->setBounds (width - audioWindowButtonWidth + 2, 5, audioWindowButtonWidth, height);
133161
}
134162

135163

@@ -143,7 +171,7 @@ bool AudioEditor::keyPressed (const KeyPress& key)
143171
void AudioEditor::updateBufferSizeText()
144172
{
145173
String t = String (AccessClass::getAudioComponent()->getBufferSizeMs());
146-
t += " ms";
174+
t = "Latency: " + t + " ms";
147175

148176
audioWindowButton->setText (t);
149177
}
@@ -221,10 +249,12 @@ void AudioEditor::sliderValueChanged (Slider* slider)
221249

222250
void AudioEditor::paint (Graphics& g)
223251
{
224-
g.setColour (Colours::grey);
225-
g.setFont (10);
226-
g.drawText ("VOLUME:", 40, 1, 50, 10, Justification::left, false);
227-
g.drawText ("GATE:", 90, 1, 50, 10, Justification::left, false);
252+
g.fillAll (Colours::green);
253+
254+
const int margin = getWidth() * 0.03;
255+
g.setColour (Colours::lightgrey);
256+
g.setFont (FONT_LABEL);
257+
g.drawSingleLineText ("GATE:", volumeSlider->getBounds().getRight() + margin, 20);
228258
}
229259

230260

β€ŽSource/Processors/AudioNode/AudioEditor.hβ€Ž

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@
3030

3131
class AudioNode;
3232
class AudioComponent;
33+
class MaterialSliderLookAndFeel;
3334

3435
/**
35-
Toggles audio output on and off.
36+
Toggles audio output on and off.
3637
37-
@see AudioNode, AudioEditor
38+
@see AudioNode, AudioEditor
3839
3940
*/
4041
class MuteButton : public ImageButton
@@ -46,9 +47,9 @@ class MuteButton : public ImageButton
4647

4748

4849
/**
49-
Used to show and hide the AudioConfigurationWindow.
50+
Used to show and hide the AudioConfigurationWindow.
5051
51-
@see AudioNode, AudioEditor
52+
@see AudioNode, AudioEditor
5253
5354
*/
5455
class AudioWindowButton : public Button
@@ -63,15 +64,14 @@ class AudioWindowButton : public Button
6364

6465

6566
private:
66-
Font font;
6767
String textString;
6868
};
6969

7070

7171
/**
72-
Allows the user to access audio output settings.
72+
Allows the user to access audio output settings.
7373
74-
@see AudioNode, AudioEditor
74+
@see AudioNode, AudioEditor
7575
7676
*/
7777
class AudioConfigurationWindow : public DocumentWindow
@@ -91,9 +91,9 @@ class AudioConfigurationWindow : public DocumentWindow
9191
};
9292

9393
/**
94-
Holds the interface for editing audio output parameters.
94+
Holds the interface for editing audio output parameters.
9595
96-
@see AudioNode
96+
@see AudioNode
9797
9898
*/
9999
class AudioEditor : public AudioProcessorEditor
@@ -135,6 +135,8 @@ class AudioEditor : public AudioProcessorEditor
135135
ScopedPointer<Slider> volumeSlider;
136136
ScopedPointer<Slider> noiseGateSlider;
137137

138+
SharedResourcePointer<MaterialSliderLookAndFeel> materialSliderLookAndFeel;
139+
138140
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioEditor);
139141
};
140142

0 commit comments

Comments
 (0)