Skip to content

Commit 8119967

Browse files
committed
Add pi to number box expressions, clean up command input button
1 parent 1157883 commit 8119967

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

Source/Components/DraggableNumber.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ class DraggableNumber : public Label
548548
else {
549549
String parseError;
550550
try {
551-
return Expression(expression, parseError).evaluate();
551+
return Expression(expression.replace("pi", "3.1415926536"), parseError).evaluate();
552552
} catch (...) {
553553
return 0.0f;
554554
}

Source/Statusbar.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,21 @@
3131
#include "Sidebar/CommandInput.h"
3232

3333
class CommandButton : public Component, public MultiTimer {
34-
35-
SmallIconButton rightIcon = SmallIconButton(Icons::Console);
3634
Label leftText;
3735
Component hitArea;
3836

3937
Colour bgCol;
4038
Colour textCol;
4139

42-
int textWidth = 0;
43-
4440
float tW, tH;
4541
float cW, cH;
46-
4742
float alpha = 0.0f;
48-
49-
const int textHeight = 14;
50-
43+
static constexpr int textHeight = 14;
44+
int textWidth = 0;
45+
5146
public:
5247
CommandButton()
5348
{
54-
addAndMakeVisible(rightIcon);
5549
addAndMakeVisible(leftText);
5650
addAndMakeVisible(hitArea);
5751

@@ -61,21 +55,14 @@ class CommandButton : public Component, public MultiTimer {
6155

6256
setCommandButtonText();
6357

64-
setSize(20,20);
58+
setSize(25, 20);
6559
};
6660

6761
~CommandButton()
6862
{
6963
hitArea.removeMouseListener(this);
7064
}
7165

72-
// This button expands left, so use the right icon inside the badge to centre the callout
73-
// As that wont change position
74-
Rectangle<int> getStaticButtonScreenBounds()
75-
{
76-
return rightIcon.getScreenBounds();
77-
}
78-
7966
void lookAndFeelChanged() override
8067
{
8168
leftText.setFont(Fonts::getDefaultFont().withHeight(textHeight));
@@ -92,6 +79,9 @@ class CommandButton : public Component, public MultiTimer {
9279
auto bgColour = isMouseOver(true) ? bgCol.withAlpha(0.15f) : bgCol.withAlpha(0.05f);
9380
g.setColour(bgColour);
9481
g.fillRoundedRectangle(getLocalBounds().toFloat(), Corners::defaultCornerRadius);
82+
83+
g.setColour(findColour(PlugDataColour::toolbarTextColourId));
84+
g.drawText(">", getWidth() - 22, 0, 20, 20, Justification::centred);
9585
}
9686

9787
void mouseDown(const MouseEvent& e) override
@@ -128,7 +118,7 @@ class CommandButton : public Component, public MultiTimer {
128118
Font font = Fonts::getDefaultFont().withHeight(textHeight);
129119
textWidth = ceil(font.getStringWidthFloat(text));
130120

131-
animateTo(textWidth + 30, 20);
121+
animateTo(textWidth + 25, 20);
132122

133123
// We dont want to flash the alpha animation when the text is going to be very similar
134124
if (!(text.containsWholeWord("selected)") && prevText.containsWholeWord("selected)"))) {
@@ -196,7 +186,6 @@ class CommandButton : public Component, public MultiTimer {
196186
{
197187
auto b = getLocalBounds().removeFromLeft(textWidth + 12);
198188
leftText.setBounds(b);
199-
rightIcon.setBounds(getWidth() - 25, 0, 20, 20);
200189

201190
hitArea.setBounds(getLocalBounds());
202191

@@ -1276,7 +1265,7 @@ void Statusbar::showCommandInput()
12761265

12771266
auto commandInput = std::make_unique<CommandInput>(editor);
12781267
auto rawCommandInput = commandInput.get();
1279-
auto& callout = editor->showCalloutBox(std::move(commandInput), commandInputButton->getStaticButtonScreenBounds());
1268+
auto& callout = editor->showCalloutBox(std::move(commandInput), commandInputButton->getScreenBounds().removeFromRight(22));
12801269

12811270
commandInputCallout = (&callout);
12821271

0 commit comments

Comments
 (0)