From 7c7ffde58581cbe54b709928fddade2f6ac77978 Mon Sep 17 00:00:00 2001 From: Anjal Doshi Date: Fri, 27 Sep 2024 18:45:01 -0700 Subject: [PATCH] Use non-native titlebar on Windows --- Source/MainWindow.cpp | 7 +++++-- Source/Processors/Editors/VisualizerEditor.cpp | 6 ++++-- Source/Processors/Visualization/DataWindow.cpp | 6 +++++- Source/UI/LookAndFeel/CustomLookAndFeel.cpp | 16 ++++++++++------ Source/UI/PluginInstaller.cpp | 6 +++++- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Source/MainWindow.cpp b/Source/MainWindow.cpp index ad04b467b..9000acc2a 100644 --- a/Source/MainWindow.cpp +++ b/Source/MainWindow.cpp @@ -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 diff --git a/Source/Processors/Editors/VisualizerEditor.cpp b/Source/Processors/Editors/VisualizerEditor.cpp index 12d22a174..f86e879e6 100755 --- a/Source/Processors/Editors/VisualizerEditor.cpp +++ b/Source/Processors/Editors/VisualizerEditor.cpp @@ -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 @@ -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()) diff --git a/Source/Processors/Visualization/DataWindow.cpp b/Source/Processors/Visualization/DataWindow.cpp index f39c971a6..3808032df 100755 --- a/Source/Processors/Visualization/DataWindow.cpp +++ b/Source/Processors/Visualization/DataWindow.cpp @@ -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); } diff --git a/Source/UI/LookAndFeel/CustomLookAndFeel.cpp b/Source/UI/LookAndFeel/CustomLookAndFeel.cpp index 9ab610a4c..267f26554 100644 --- a/Source/UI/LookAndFeel/CustomLookAndFeel.cpp +++ b/Source/UI/LookAndFeel/CustomLookAndFeel.cpp @@ -710,7 +710,6 @@ void CustomLookAndFeel::drawMenuBarBackground (Graphics& g, int width, int heigh Rectangle 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)); @@ -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()); @@ -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); @@ -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; } diff --git a/Source/UI/PluginInstaller.cpp b/Source/UI/PluginInstaller.cpp index 194c7025f..16b4b2263 100644 --- a/Source/UI/PluginInstaller.cpp +++ b/Source/UI/PluginInstaller.cpp @@ -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