Skip to content

Commit 91aee41

Browse files
committed
More small layout fixes
1 parent ec03712 commit 91aee41

5 files changed

Lines changed: 34 additions & 42 deletions

File tree

Source/PluginEditor.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,9 @@ void PluginEditor::showWelcomePanel(bool const shouldShow)
503503
undoButton.setVisible(!shouldShow);
504504
redoButton.setVisible(!shouldShow);
505505
sidebar->setVisible(!shouldShow);
506+
audioToolbar->setVisible(!shouldShow);
506507

507-
welcomePanelSearchButton.setVisible(false); // TODO: fix this!
508+
welcomePanelSearchButton.setVisible(shouldShow);
508509
recentlyOpenedPanelSelector.setVisible(shouldShow);
509510
libraryPanelSelector.setVisible(shouldShow);
510511

@@ -621,7 +622,7 @@ void PluginEditor::resized()
621622
resizerSize, resizerSize);
622623
}
623624

624-
welcomePanelSearchButton.setBounds(getWidth() - windowControlsOffset, 0, buttonSize, buttonSize);
625+
welcomePanelSearchButton.setBounds(getWidth() - (windowControlsOffset + 40.f), 0, buttonSize, buttonSize);
625626

626627
welcomePanelSearchInput.setBounds(libraryPanelSelector.getRight() + 10, 4, welcomePanelSearchButton.getX() - libraryPanelSelector.getRight() - 20, toolbarHeight - 4);
627628

Source/Sidebar/CommandInput.h

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class CommandInput final
248248
updateSize();
249249
};
250250

251-
commandInput.setBorder({ 3, 3, 0, 0 });
251+
commandInput.setBorder({ 4, 3, 0, 0 });
252252
commandInput.addKeyListener(this);
253253
commandInput.addMouseListener(this, false);
254254
commandInput.setFont(Fonts::getDefaultFont().withHeight(15));
@@ -709,31 +709,20 @@ class CommandInput final
709709
auto bounds = getLocalBounds();
710710
g.setColour(PlugDataColours::dataColour);
711711
g.setFont(Fonts::getSemiBoldFont().withHeight(15));
712-
g.drawText(consoleTargetName, bounds.getX() + 7, bounds.getY(), consoleTargetLength, bounds.getHeight() - 3, Justification::centredLeft);
712+
g.drawText(consoleTargetName, bounds.getX() + 9, bounds.getY(), consoleTargetLength, bounds.getHeight() - 1, Justification::centredLeft);
713713
}
714714

715715
void paint(Graphics& g) override
716716
{
717717
auto bounds = getLocalBounds();
718-
/*
719-
g.setFont(Fonts::getSemiBoldFont().withHeight(15));
720-
g.setColour(PlugDataColours::panelTextColour);
721-
g.drawText("Command input", bounds.removeFromTop(22), Justification::centred);
722-
723-
bounds.removeFromTop(4);
724-
725-
if (helpButton.getToggleState()) {
726-
bounds.removeFromTop(200);
727-
} */
728-
729718
g.setColour(PlugDataColours::levelMeterBackgroundColour);
730-
g.fillRoundedRectangle(bounds.reduced(2, 2).toFloat(), Corners::defaultCornerRadius);
719+
g.fillRoundedRectangle(bounds.reduced(2, 1).toFloat(), Corners::defaultCornerRadius);
731720
}
732721

733722
void resized() override
734723
{
735724
auto inputBounds = getLocalBounds();
736-
commandInput.setBounds(inputBounds.withTrimmedLeft(consoleTargetLength).withTrimmedRight(30));
725+
commandInput.setBounds(inputBounds.withTrimmedLeft(consoleTargetLength + 4).withTrimmedRight(30));
737726
auto const buttonBounds = inputBounds.removeFromRight(30);
738727
clearButton.setBounds(buttonBounds);
739728
}
@@ -744,7 +733,7 @@ class CommandInput final
744733
if (target == "empty")
745734
consoleTargetName = ">";
746735
consoleTargetLength = CachedStringWidth<15>::calculateStringWidth(consoleTargetName) + 4;
747-
commandInput.setBounds(commandInput.getBounds().withLeft(consoleTargetLength));
736+
commandInput.setBounds(commandInput.getBounds().withLeft(consoleTargetLength + 4));
748737
repaint();
749738
}
750739

Source/Sidebar/Sidebar.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ void Sidebar::paint(Graphics& g)
133133
Fonts::drawStyledText(g, panelName, Rectangle<int>(0, 0, getWidth() - 30, 30), PlugDataColours::toolbarTextColour, Bold, 15, Justification::centred);
134134

135135
if (inspectorButton.isInspectorPinned()) {
136-
auto inpectorPos = Point<int>(0, dividerFactor * getHeight());
136+
auto inpectorPos = Point<int>(0, dividerFactor * (getHeight() - getCommandInputHeight()));
137137
if (inspector->isEmpty())
138-
inpectorPos.setY(getHeight() - 30);
138+
inpectorPos.setY(getHeight() - getCommandInputHeight() - 30);
139139
g.setColour(PlugDataColours::sidebarActiveBackgroundColour);
140140
g.fillRect(inpectorPos.x, inpectorPos.y, getWidth() - 30, 30);
141141
auto inspectorTitle = inspector->getTitle();
@@ -146,6 +146,11 @@ void Sidebar::paint(Graphics& g)
146146
}
147147
}
148148

149+
int Sidebar::getCommandInputHeight()
150+
{
151+
return commandInput->isVisible() ? 46 : 0;
152+
}
153+
149154
void Sidebar::paintOverChildren(Graphics& g)
150155
{
151156
g.setColour(PlugDataColours::toolbarOutlineColour);
@@ -179,7 +184,7 @@ void Sidebar::resized()
179184
if(sidebarHidden) buttonBarBounds.translate(-24, 0);
180185

181186
if (SettingsFile::getInstance()->getProperty<bool>("centre_sidepanel_buttons")) {
182-
buttonBarBounds = buttonBarBounds.withSizeKeepingCentre(30, 144 + 30 + 8 + 30);
187+
buttonBarBounds = buttonBarBounds.withSizeKeepingCentre(30, 144 + 30 + 30 + 8 + 30);
183188
} else {
184189
buttonBarBounds = buttonBarBounds.withTrimmedTop(34);
185190
}
@@ -204,13 +209,13 @@ void Sidebar::resized()
204209
extraSettingsButton->setBounds(panelTitleBarBounds);
205210
}
206211

207-
auto const dividerPos = getHeight() * (1.0f - dividerFactor);
208-
209212
if(commandInput->isVisible())
210213
{
211-
commandInput->setBounds(bounds.removeFromBottom(46).reduced(8));
214+
commandInput->setBounds(bounds.removeFromBottom(getCommandInputHeight()).reduced(8));
212215
}
213216

217+
auto const dividerPos = (getHeight() - getCommandInputHeight()) * (1.0f - dividerFactor);
218+
214219
if (inspector->isVisible()) {
215220
if (inspectorButton.isInspectorAuto()) {
216221
if (extraSettingsButton)
@@ -221,7 +226,7 @@ void Sidebar::resized()
221226
}
222227
inspector->setBounds(bounds);
223228
} else {
224-
auto bottomB = bounds.removeFromBottom(inspector->isEmpty() ? 30 : dividerPos);
229+
auto bottomB = bounds.removeFromBottom(inspector->isEmpty() ? (30 + getCommandInputHeight()) : dividerPos);
225230
auto resetB = bottomB.removeFromTop(30);
226231
inspector->setBounds(bottomB);
227232
auto const resetBounds = resetB.removeFromLeft(30);
@@ -249,13 +254,16 @@ void Sidebar::resized()
249254
bool Sidebar::hitTest(int x, int y)
250255
{
251256
Rectangle<int> buttonBounds;
252-
for(auto* button : StackArray<SidebarSelectorButton*, 5>{
257+
for(auto* button : StackArray<Component*, 6>{
253258
&consoleButton,
254259
&browserButton,
255260
&automationButton,
256261
&searchButton,
257-
&paletteButton})
258-
buttonBounds = buttonBounds.getUnion(button->getBounds());
262+
&paletteButton,
263+
&inspectorButton})
264+
{
265+
if(button->isVisible()) buttonBounds = buttonBounds.getUnion(button->getBounds());
266+
}
259267

260268
return !isHidden() || buttonBounds.contains(x, y);
261269
}
@@ -274,7 +282,7 @@ void Sidebar::mouseDown(MouseEvent const& e)
274282
draggingSidebar = false;
275283
}
276284

277-
dragOffset = static_cast<float>(e.getEventRelativeTo(this).y) - dividerFactor * getHeight();
285+
dragOffset = static_cast<float>(e.getEventRelativeTo(this).y) - dividerFactor * (getHeight() - getCommandInputHeight());
278286
}
279287

280288
void Sidebar::mouseDrag(MouseEvent const& e)
@@ -290,7 +298,7 @@ void Sidebar::mouseDrag(MouseEvent const& e)
290298
getParentComponent()->resized();
291299
} else if (isDraggingDivider && !inspector->isEmpty()) {
292300
auto const newDividerY = static_cast<float>(jlimit(30, getHeight() - 30, e.getEventRelativeTo(this).getPosition().y - dragOffset));
293-
dividerFactor = newDividerY / getHeight();
301+
dividerFactor = newDividerY / (getHeight() - getCommandInputHeight());
294302
resized();
295303
repaint();
296304
}
@@ -310,7 +318,7 @@ void Sidebar::mouseMove(MouseEvent const& e)
310318
bool const resizeCursor = e.getEventRelativeTo(this).getPosition().getX() < dragbarWidth && e.getEventRelativeTo(this).getPosition().getY() < getHeight() - 30;
311319

312320
auto const pos = e.getEventRelativeTo(this).getPosition();
313-
bool const resizeVertical = pos.x > 5 && pos.y > dividerFactor * getHeight() + 3 && pos.y < dividerFactor * getHeight() + 30 - 6;
321+
bool const resizeVertical = pos.x > 5 && pos.y > dividerFactor * (getHeight() - getCommandInputHeight()) + 3 && pos.y < dividerFactor * (getHeight() - getCommandInputHeight()) + 30 - 6;
314322

315323
isDraggingDivider = false;
316324

@@ -540,7 +548,7 @@ void Sidebar::renderButtonsOnCanvas(NVGcontext* nvg)
540548
{
541549
Graphics g(*editor->getNanoLLGC());
542550

543-
auto b = editor->nvgSurface.getLocalArea(this, getLocalBounds()).withSizeKeepingCentre(36, 186).translated(-15, -15);
551+
auto b = editor->nvgSurface.getLocalArea(this, getLocalBounds()).withSizeKeepingCentre(36, 186).translated(-15, -30);
544552

545553
StackShadow::drawShadowForRect(g, b.reduced(3.0f), 10, Corners::largeCornerRadius, 0.4f, 1);
546554

Source/Sidebar/Sidebar.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ class InspectorButton final : public Component
5454
onClick();
5555
}
5656

57-
bool hitTest(int const x, int const y) override
58-
{
59-
if (getLocalBounds().reduced(3, 4).contains(Point<int>(x, y)))
60-
return true;
61-
62-
return false;
63-
}
64-
6557
void mouseEnter(MouseEvent const& e) override
6658
{
6759
isHovering = true;
@@ -145,7 +137,7 @@ class InspectorButton final : public Component
145137
int const textWidth = getWidth() - 4;
146138

147139
if (textWidth > 0)
148-
g.drawFittedText(icon, 2, yIndent, textWidth, getHeight() - yIndent * 2, Justification::centred, 2);
140+
g.drawFittedText(icon, 2, yIndent, textWidth, getHeight() - yIndent * 2, Justification::centred, 1);
149141

150142
if (state == InspectorOff) {
151143
auto const b = getLocalBounds().toFloat().reduced(10.5f).translated(-0.5f, 0.5f);
@@ -307,6 +299,8 @@ class Sidebar final : public Component
307299
static constexpr int dragbarWidth = 6;
308300

309301
private:
302+
303+
int getCommandInputHeight();
310304
void updateExtraSettingsButton();
311305

312306
PluginProcessor* pd;

Source/Toolbar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ class PowerButton final : public Component
980980
{
981981
auto* editor = findParentComponentOfClass<PluginEditor>();
982982
auto content = std::make_unique<AudioSettingsCallout>(editor);
983-
editor->showCalloutBox(std::move(content), chevron.getScreenBounds());
983+
editor->showCalloutBox(std::move(content), chevron.getScreenBounds().translated(-26, 0));
984984
}
985985

986986
PluginProcessor* pd;

0 commit comments

Comments
 (0)