/* ============================================================================== This file is part of the JUCE library. Copyright (c) 2020 - Raw Material Software Limited JUCE is an open source library subject to commercial or open-source licensing. By using JUCE, you agree to the terms of both the JUCE 6 End-User License Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020). End User License Agreement: www.juce.com/juce-6-licence Privacy Policy: www.juce.com/juce-privacy-policy Or: You may also use this code under the terms of the GPL v3 (see www.gnu.org/licenses). JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE DISCLAIMED. ============================================================================== */ namespace juce { /* ============================================================================== In accordance with the terms of the JUCE 6 End-Use License Agreement, the JUCE Code in SECTION A cannot be removed, changed or otherwise rendered ineffective unless you have a JUCE Indie or Pro license, or are using JUCE under the GPL v3 license. End User License Agreement: www.juce.com/juce-6-licence ============================================================================== */ // BEGIN SECTION A #if ! defined (JUCE_DISPLAY_SPLASH_SCREEN) #define JUCE_DISPLAY_SPLASH_SCREEN 1 #endif #if ! defined (JUCE_USE_DARK_SPLASH_SCREEN) #define JUCE_USE_DARK_SPLASH_SCREEN 1 #endif static const int millisecondsToDisplaySplash = 2000, splashScreenFadeOutTime = 2000; static const int splashScreenLogoWidth = 123, splashScreenLogoHeight = 63; static uint32 splashDisplayTime = 0; static bool splashHasStartedFading = false; static Rectangle getLogoArea (Rectangle parentRect) { return parentRect.reduced (6.0f) .removeFromRight ((float) splashScreenLogoWidth) .removeFromBottom ((float) splashScreenLogoHeight); } //============================================================================== JUCESplashScreen::JUCESplashScreen (Component& parent) { ignoreUnused (parent); #if JUCE_DISPLAY_SPLASH_SCREEN if (splashDisplayTime == 0 || Time::getMillisecondCounter() < splashDisplayTime + (uint32) millisecondsToDisplaySplash) { content = getSplashScreenLogo(); setAlwaysOnTop (true); parent.addAndMakeVisible (this); } else #endif { startTimer (1); } } std::unique_ptr JUCESplashScreen::getSplashScreenLogo() { const char* svgData = R"JUCESPLASHSCREEN( " R"JUCESPLASHSCREEN( )JUCESPLASHSCREEN"; auto svgXml = parseXML (svgData); jassert (svgXml != nullptr); return Drawable::createFromSVG (*svgXml); } void JUCESplashScreen::paint (Graphics& g) { auto r = getLocalBounds().toFloat(); Point bottomRight (0.9f * r.getWidth(), 0.9f * r.getHeight()); ColourGradient cg (Colour (0x00000000), Line (0.0f, r.getHeight(), r.getWidth(), 0.0f) .findNearestPointTo (bottomRight), Colour (0xff000000), bottomRight, false); cg.addColour (0.25f, Colour (0x10000000)); cg.addColour (0.50f, Colour (0x30000000)); cg.addColour (0.75f, Colour (0x70000000)); g.setFillType (cg); g.fillAll(); content->drawWithin (g, getLogoArea (r), RectanglePlacement::centred, 1.0f); if (splashDisplayTime == 0) splashDisplayTime = Time::getMillisecondCounter(); if (! isTimerRunning()) startTimer (millisecondsToDisplaySplash); } void JUCESplashScreen::timerCallback() { #if JUCE_DISPLAY_SPLASH_SCREEN if (isVisible() && ! splashHasStartedFading) { splashHasStartedFading = true; fader.animateComponent (this, getBounds(), 0.0f, splashScreenFadeOutTime, false, 0, 0); } if (splashHasStartedFading && ! fader.isAnimating()) #endif delete this; } void JUCESplashScreen::parentSizeChanged() { if (auto* p = getParentComponent()) setBounds (p->getLocalBounds().removeFromBottom (splashScreenLogoHeight * 3) .removeFromRight (splashScreenLogoWidth * 3)); } void JUCESplashScreen::parentHierarchyChanged() { toFront (false); } bool JUCESplashScreen::hitTest (int x, int y) { if (! splashHasStartedFading) return getLogoArea (getLocalBounds().toFloat()).contains ((float) x, (float) y); return false; } void JUCESplashScreen::mouseUp (const MouseEvent&) { URL juceWebsite ("https://juce.com"); juceWebsite.launchInDefaultBrowser(); } // END SECTION A } // namespace juce