Skip to content

Commit

Permalink
Repositioning of internal dialog titlebar buttons to the left size fo…
Browse files Browse the repository at this point in the history
…r Mac (#6713)
  • Loading branch information
mkruselj authored Nov 30, 2022
1 parent 2ad1ce9 commit f8c6d7c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/surge-xt/gui/SurgeJUCELookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(titleCenter - (titleTextWidth / 2), 0, sw, h);
Expand Down
11 changes: 8 additions & 3 deletions src/surge-xt/gui/overlays/MiniEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 17 additions & 3 deletions src/surge-xt/gui/overlays/OverlayWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -100,14 +106,22 @@ void OverlayWrapper::addAndTakeOwnership(std::unique_ptr<juce::Component> 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<int> closeButtonBounds;
juce::Rectangle<int> 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)
{
Expand Down

0 comments on commit f8c6d7c

Please sign in to comment.