From 0add34279063f9ef54d1c0a57c66a1bd2b896e98 Mon Sep 17 00:00:00 2001 From: Mario Kruselj Date: Tue, 29 Nov 2022 14:55:04 +0100 Subject: [PATCH] Repositioning of internal dialog titlebar buttons to the left size for Mac --- src/surge-xt/gui/SurgeJUCELookAndFeel.cpp | 6 +++--- src/surge-xt/gui/overlays/MiniEdit.cpp | 11 ++++++++--- src/surge-xt/gui/overlays/OverlayWrapper.cpp | 20 +++++++++++++++++--- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp b/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp index 75195db7268..89104cba3f2 100644 --- a/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp +++ b/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp @@ -230,16 +230,16 @@ void SurgeJUCELookAndFeel::drawDocumentWindowTitleBar(DocumentWindow &window, Gr auto sw = fontSurge.getStringWidth(surgeLabel); auto vw = fontVersion.getStringWidth(surgeVersion); - auto ic = associatedBitmapStore->getImage(IDB_SURGE_ICON); + auto icon = associatedBitmapStore->getImage(IDB_SURGE_ICON); // Surge icon is 12 x 14 so draw that in the center auto titleCenter = w / 2; auto textMargin = Surge::Build::IsRelease ? 0 : 5; auto titleTextWidth = sw + vw + textMargin; - if (ic) + if (icon) { - ic->drawAt(g, titleCenter - (titleTextWidth / 2) - 14 - textMargin, h / 2 - 7, 1.0); + icon->drawAt(g, titleCenter - (titleTextWidth / 2) - 14 - textMargin, h / 2 - 7, 1.0); } auto boxSurge = Rectangle(titleCenter - (titleTextWidth / 2), 0, sw, h); diff --git a/src/surge-xt/gui/overlays/MiniEdit.cpp b/src/surge-xt/gui/overlays/MiniEdit.cpp index e2e7d3cd2cc..89c0821287e 100644 --- a/src/surge-xt/gui/overlays/MiniEdit.cpp +++ b/src/surge-xt/gui/overlays/MiniEdit.cpp @@ -80,11 +80,16 @@ void MiniEdit::paint(juce::Graphics &g) g.setFont(skin->fontManager->getLatoAtSize(10, juce::Font::bold)); g.drawText(title, tbRect, juce::Justification::centred); - auto d = associatedBitmapStore->getImage(IDB_SURGE_ICON); + auto icon = associatedBitmapStore->getImage(IDB_SURGE_ICON); - if (d) + if (icon) { - d->drawAt(g, fullRect.getX() + 2, fullRect.getY() + 2, 1.0); + const auto iconSize = 14; +#if MAC + icon->drawAt(g, fullRect.getRight() - iconSize + 2, fullRect.getY() + 1, 1); +#else + icon->drawAt(g, fullRect.getX() + 2, fullRect.getY() + 1, 1); +#endif } auto bodyRect = fullRect.withTrimmedTop(18); diff --git a/src/surge-xt/gui/overlays/OverlayWrapper.cpp b/src/surge-xt/gui/overlays/OverlayWrapper.cpp index 3c1cdf764dd..e3f4a79ce4b 100644 --- a/src/surge-xt/gui/overlays/OverlayWrapper.cpp +++ b/src/surge-xt/gui/overlays/OverlayWrapper.cpp @@ -81,7 +81,13 @@ void OverlayWrapper::paint(juce::Graphics &g) if (icon) { + const auto iconSize = titlebarSize; + +#if MAC + icon->drawAt(g, sp.getRight() - iconSize + 1, sp.getY() + 1, 1); +#else icon->drawAt(g, sp.getX() + 2, sp.getY() + 1, 1); +#endif } g.setColour(skin->getColor(Colors::Dialog::Border)); @@ -100,14 +106,22 @@ void OverlayWrapper::addAndTakeOwnership(std::unique_ptr c) auto q = sp.reduced(2 * margin, 2 * margin) .withTrimmedBottom(titlebarSize) - .translated(0, titlebarSize + 0 * margin); + .translated(0, titlebarSize); primaryChild = std::move(c); primaryChild->setBounds(q); auto buttonSize = titlebarSize; - auto closeButtonBounds = + juce::Rectangle closeButtonBounds; + juce::Rectangle tearOutButtonBounds; + +#if MAC + closeButtonBounds = getLocalBounds().withSize(buttonSize, buttonSize).translated(2, 2); + tearOutButtonBounds = closeButtonBounds.translated(buttonSize + 2, 0); +#else + closeButtonBounds = getLocalBounds().withHeight(buttonSize).withLeft(getWidth() - buttonSize).translated(-2, 2); - auto tearOutButtonBounds = closeButtonBounds.translated(-buttonSize - 2, 0); + tearOutButtonBounds = closeButtonBounds.translated(-buttonSize - 2, 0); +#endif if (showCloseButton) {