Skip to content

Commit a5606a9

Browse files
committed
Update AudioWindowButton
1 parent cfe354a commit a5606a9

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

Source/Processors/AudioNode/AudioEditor.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ MuteButton::MuteButton()
3636
offimage = ImageCache::getFromMemory (BinaryData::muteoff_png, BinaryData::muteoff_pngSize);
3737
onimage = ImageCache::getFromMemory (BinaryData::muteon_png, BinaryData::muteon_pngSize);
3838

39-
setImages (false, true, true, offimage, 1.0f,
40-
findColour (ThemeColours::controlPanelText), offimage, 0.5f,
41-
findColour (ThemeColours::controlPanelText).withAlpha (0.5f), onimage, 0.7f,
42-
findColour (ThemeColours::controlPanelText).withAlpha (0.7f));
39+
setImages (false, true, true, offimage, 1.0f, findColour (ThemeColours::controlPanelText), offimage, 0.5f, findColour (ThemeColours::controlPanelText).withAlpha (0.5f), onimage, 0.7f, findColour (ThemeColours::controlPanelText).withAlpha (0.7f));
4340

4441
setClickingTogglesState (true);
4542

@@ -48,10 +45,7 @@ MuteButton::MuteButton()
4845

4946
void MuteButton::updateImages()
5047
{
51-
setImages (false, true, true, offimage, 1.0f,
52-
findColour (ThemeColours::controlPanelText), offimage, 0.5f,
53-
findColour (ThemeColours::controlPanelText).withAlpha (0.5f), onimage, 0.7f,
54-
findColour (ThemeColours::controlPanelText).withAlpha (0.7f));
48+
setImages (false, true, true, offimage, 1.0f, findColour (ThemeColours::controlPanelText), offimage, 0.5f, findColour (ThemeColours::controlPanelText).withAlpha (0.5f), onimage, 0.7f, findColour (ThemeColours::controlPanelText).withAlpha (0.7f));
5549
}
5650

5751
AudioWindowButton::AudioWindowButton()
@@ -61,19 +55,25 @@ AudioWindowButton::AudioWindowButton()
6155

6256
textString = ":AUDIO";
6357
setTooltip ("Change the buffer size");
58+
59+
String svgPathString = "M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0 M12 7v5l3 3";
60+
61+
latencySvgPath = Drawable::parseSVGPath (svgPathString);
6462
}
6563

6664
void AudioWindowButton::paintButton (Graphics& g, bool isMouseOver, bool isButtonDown)
6765
{
66+
float alpha = isMouseOver ? 0.6f : 1.0f;
67+
6868
if (getToggleState())
69-
g.setColour (Colours::yellow);
69+
g.setColour (Colours::yellow.withAlpha (alpha));
7070
else
71-
g.setColour (findColour (ThemeColours::controlPanelText));
71+
g.setColour (findColour (ThemeColours::controlPanelText).withAlpha (alpha));
72+
73+
g.strokePath (latencySvgPath, PathStrokeType (1.5f), latencySvgPath.getTransformToScaleToFit (5, 7, 14, 14, true));
7274

73-
const bool isLatencyLabelVisible = getParentComponent()->getWidth() >= 450;
74-
auto textToDraw = isLatencyLabelVisible ? textString : textString.fromLastOccurrenceOf (":", false, true);
7575
g.setFont (FontOptions ("Silkscreen", "Regular", 14));
76-
g.drawSingleLineText (textToDraw, 0, 15);
76+
g.drawFittedText (textString, 25, 0, getWidth() - 30, getHeight(), Justification::centredLeft, 1);
7777
}
7878

7979
void AudioWindowButton::setText (const String& newText)
@@ -128,7 +128,7 @@ void AudioEditor::resized()
128128

129129
// Since width of the label on button is always the same, we should reserve it.
130130
const bool isLatencyLabelVisible = width >= 450;
131-
const int audioWindowButtonWidth = isLatencyLabelVisible ? 110 : 60;
131+
const int audioWindowButtonWidth = 68;
132132
const int gateLabelWidth = 45;
133133

134134
const int availableWidth = width - audioWindowButtonWidth - gateLabelWidth;
@@ -140,13 +140,13 @@ void AudioEditor::resized()
140140
muteButton->setBounds (margin, 5, 20, 20);
141141
volumeSlider->setBounds (margin + 30, sliderY, sliderWidth, sliderHeight);
142142
noiseGateSlider->setBounds (volumeSlider->getRight() + margin + gateLabelWidth, sliderY, sliderWidth, sliderHeight);
143-
audioWindowButton->setBounds (width - audioWindowButtonWidth + 2, 5, audioWindowButtonWidth, height);
143+
audioWindowButton->setBounds (width - audioWindowButtonWidth + 2, 2, audioWindowButtonWidth - 4, height - 4);
144144
}
145145

146146
void AudioEditor::updateBufferSizeText()
147147
{
148148
String t = String (AccessClass::getAudioComponent()->getBufferSizeMs());
149-
t = "Latency: " + t + " ms";
149+
t = t + " ms";
150150

151151
audioWindowButton->setText (t);
152152
}

Source/Processors/AudioNode/AudioEditor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class AudioWindowButton : public Button
7777

7878
private:
7979
String textString;
80+
Path latencySvgPath;
8081
};
8182

8283
/**

0 commit comments

Comments
 (0)