Skip to content

Commit 924864d

Browse files
committed
Clean up, fix rounded corners on Linux
1 parent 1ff7a52 commit 924864d

6 files changed

Lines changed: 29 additions & 6 deletions

File tree

Libraries/nanovg

Source/Canvas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ void Canvas::updateFramebuffers(NVGcontext* nvg)
472472
if (dotsLargeImage.needsUpdate(gridBufferSize, gridBufferSize) || lastObjectGridSize != gridLogicalSize) {
473473
lastObjectGridSize = gridLogicalSize;
474474

475-
dotsLargeImage = NVGImage(nvg, gridBufferSize, gridBufferSize, [this, zoom, viewScale, gridLogicalSize, gridSizeCommon](Graphics& g) {
475+
dotsLargeImage = NVGImage(nvg, gridBufferSize, gridBufferSize, [zoom, viewScale, gridLogicalSize, gridSizeCommon](Graphics& g) {
476476
g.addTransform(AffineTransform::scale(viewScale, viewScale));
477477
float const ellipseRadius = zoom < 1.0f ? jmap(zoom, 0.25f, 1.0f, 3.0f, 1.0f) : 1.0f;
478478

Source/NVGSurface.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ using namespace juce::gl;
1414
#ifdef NANOVG_GL_IMPLEMENTATION
1515
# include <nanovg_gl.h>
1616
# include <nanovg_gl_utils.h>
17+
#if JUCE_LINUX || JUCE_BSD
18+
void nvgluSetCornerRadius(float radius, bool left, bool right);
19+
#endif
1720
#endif
1821

1922
#include "NVGSurface.h"
@@ -155,6 +158,10 @@ void NVGSurface::initialise()
155158
return;
156159
}
157160

161+
#if JUCE_LINUX || JUCE_BSD
162+
nvgluSetCornerRadius(12.0f * lastRenderScale, roundedRight, roundedRight);
163+
#endif
164+
158165
surfaces[nvg] = this;
159166

160167
nvgAtlasTextThreshold(nvg, 32.0f);
@@ -456,6 +463,15 @@ void NVGSurface::blitToScreen()
456463
#endif
457464
}
458465

466+
#if JUCE_LINUX || JUCE_BSD
467+
void NVGSurface::setRoundedBottomCorners(bool left, bool right)
468+
{
469+
roundedLeft = left;
470+
roundedRight = right;
471+
nvgluSetCornerRadius(12.0f * lastRenderScale, roundedLeft, roundedRight);
472+
}
473+
#endif
474+
459475
void NVGSurface::renderFrameToImage(Image& image, Rectangle<int> const area)
460476
{
461477
nvgBindFramebuffer(nullptr);

Source/NVGSurface.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ class NVGSurface final :
106106

107107
void resized() override;
108108

109+
#if JUCE_LINUX || JUCE_BSD
110+
bool roundedLeft = false, roundedRight = true;
111+
void setRoundedBottomCorners(bool left, bool right);
112+
#endif
113+
109114
void addBufferedObject(NVGComponent* component);
110115
void removeBufferedObject(NVGComponent* component);
111116

Source/PluginEditor.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ void PluginEditor::paint(Graphics& g)
374374
baseColour = baseColour.brighter(baseColour.getBrightness() / 2.5f);
375375
}
376376

377-
#if JUCE_MAC || JUCE_LINUX
377+
#if JUCE_MAC || JUCE_LINUX || JUCE_BSD
378378
if (wantsRoundedCorners()) {
379379
g.setColour(baseColour);
380380
g.fillRoundedRectangle(getLocalBounds().toFloat(), Corners::windowCornerRadius);
@@ -552,6 +552,10 @@ void PluginEditor::resized()
552552
return;
553553
}
554554

555+
#if JUCE_LINUX || JUCE_BSD
556+
nvgSurface.setRoundedBottomCorners(true, sidebar->isHidden());
557+
#endif
558+
555559
auto const workAreaHeight = getHeight() - toolbarHeight;
556560
auto const sidebarWidth = (sidebar->isVisible() && !sidebar->isHidden()) ? sidebar->getWidth() : 0;
557561
workArea = Rectangle<int>(0, toolbarHeight, getWidth() - sidebarWidth, workAreaHeight);
@@ -587,8 +591,6 @@ void PluginEditor::resized()
587591
redoButton.setBounds(2 * buttonDistance + offset, 0, buttonSize, buttonSize);
588592
addObjectMenuButton.setBounds(3 * buttonDistance + offset, 0, buttonSize, buttonSize);
589593

590-
auto const startX = getWidth() / 2.0f - toolbarHeight * 1.5;
591-
592594
if (touchSelectionHelper) {
593595
auto touchHelperBounds = getLocalBounds().removeFromBottom(48).withSizeKeepingCentre(192, 48).translated(0, -54);
594596
if (touchSelectionHelper)

Source/Toolbar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ void AudioToolbar::setLatencyDisplay(int samples)
13231323
{
13241324
if (!ProjectInfo::isStandalone) {
13251325
dawLatencyBadge->setVisible(samples);
1326-
dawLatencyBadge->setText(String("Latency: " + samples));
1326+
dawLatencyBadge->setText("Latency: " + String(samples));
13271327
}
13281328
}
13291329

0 commit comments

Comments
 (0)