Skip to content

Commit

Permalink
Use non-native titlebar on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaldoshi committed Sep 28, 2024
1 parent 2aa4c57 commit 7c7ffde
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
7 changes: 5 additions & 2 deletions Source/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ MainWindow::MainWindow (const File& fileToLoad, bool isConsoleApp_) : isConsoleA

loadWindowBounds();

// Use native title bar on Mac and Linux
documentWindow->setUsingNativeTitleBar (true);
#ifdef JUCE_WINDOWS
documentWindow->setUsingNativeTitleBar (false);
#else
documentWindow->setUsingNativeTitleBar (true); // Use native title bar on Mac and Linux
#endif

documentWindow->addToDesktop (documentWindow->getDesktopWindowStyleFlags()); // prevents the maximize
// button from randomly disappearing
Expand Down
6 changes: 4 additions & 2 deletions Source/Processors/Editors/VisualizerEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ void VisualizerEditor::ButtonResponder::buttonClicked (Button* button)

editor->dataWindow->setContentNonOwned (editor->canvas.get(), true);
editor->dataWindow->setVisible (true);
editor->dataWindow->toFront (true);
editor->dataWindow->addListener (editor);

// Set the rendering engine for the window
Expand All @@ -180,14 +181,15 @@ void VisualizerEditor::ButtonResponder::buttonClicked (Button* button)
if (editor->windowSelector->getToggleState())
{
editor->dataWindow->setContentNonOwned (editor->canvas.get(), true);
editor->dataWindow->setVisible (true);
editor->dataWindow->toFront (true);
// editor->canvas->setBounds (0, 0, editor->canvas->getParentWidth(), editor->canvas->getParentHeight());
}
else
{
editor->dataWindow->setContentNonOwned (0, false);
editor->dataWindow->setVisible (false);
}

editor->dataWindow->setVisible (editor->windowSelector->getToggleState());
}
}
else if (button == editor->tabSelector.get())
Expand Down
6 changes: 5 additions & 1 deletion Source/Processors/Visualization/DataWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ DataWindow::DataWindow (Button* cButton, String name)

{
centreWithSize (1020, 780);
setUsingNativeTitleBar (true);
#ifdef JUCE_WINDOWS
setUsingNativeTitleBar (false);
#else
setUsingNativeTitleBar (true); // Use native title bar on Mac and Linux
#endif
setResizable (true, false);
}

Expand Down
16 changes: 10 additions & 6 deletions Source/UI/LookAndFeel/CustomLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,6 @@ void CustomLookAndFeel::drawMenuBarBackground (Graphics& g, int width, int heigh
Rectangle<int> r (1, 0, width - 2, height);

g.setColour (colour.contrasting (0.15f));
g.fillRect (r.removeFromTop (1));
g.fillRect (r.removeFromBottom (1));

g.setGradientFill (ColourGradient::vertical (colour, 0, colour.darker (0.2f), (float) height));
Expand Down Expand Up @@ -1063,10 +1062,15 @@ void CustomLookAndFeel::drawDocumentWindowTitleBar (DocumentWindow& window, Grap

auto isActive = window.isActiveWindow();

g.setColour (findColour (ThemeColours::componentParentBackground));
g.fillAll();
const Colour colour (findColour (ThemeColours::componentParentBackground));

Font font (withDefaultMetrics (FontOptions ("Inter", "Bold", (float) h * 0.65f)));
g.setGradientFill (ColourGradient::vertical (colour, 0, colour.darker (0.2f), (float) h));
g.fillRect (0, 0, w, h);

g.setColour (colour.contrasting (0.15f));
g.fillRect (0, h - 1, w, 1);

Font font (withDefaultMetrics (FontOptions ("Inter", "Semi Bold", (float) h * 0.65f)));
g.setFont (font);

auto textW = font.getStringWidth (window.getName());
Expand All @@ -1079,7 +1083,7 @@ void CustomLookAndFeel::drawDocumentWindowTitleBar (DocumentWindow& window, Grap
iconW = icon->getWidth() * iconH / icon->getHeight() + 4;
}

textW = jmin (titleSpaceW, textW + iconW);
textW = jmin (titleSpaceW, textW + iconW + 4);
auto textX = drawTitleTextOnLeft ? titleSpaceX
: jmax (titleSpaceX, (w - textW) / 2);

Expand All @@ -1090,7 +1094,7 @@ void CustomLookAndFeel::drawDocumentWindowTitleBar (DocumentWindow& window, Grap
{
g.setOpacity (isActive ? 1.0f : 0.6f);
g.drawImageWithin (*icon, textX, (h - iconH) / 2, iconW, iconH, RectanglePlacement::centred, false);
textX += iconW;
textX += iconW + 4;
textW -= iconW;
}

Expand Down
6 changes: 5 additions & 1 deletion Source/UI/PluginInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ PluginInstaller::PluginInstaller (bool loadComponents)
if (loadComponents)
{
setSize (910, 480);
setUsingNativeTitleBar (true);
#ifdef JUCE_WINDOWS
setUsingNativeTitleBar (false);
#else
setUsingNativeTitleBar (true); // Use native title bar on Mac and Linux
#endif
setContentOwned (new PluginInstallerComponent(), false);
setVisible (true);
setResizable (true, false); // useBottomCornerRisizer -- doesn't work very well
Expand Down

0 comments on commit 7c7ffde

Please sign in to comment.