/* ============================================================================== This file is part of the JUCE framework. Copyright (c) Raw Material Software Limited JUCE is an open source framework subject to commercial or open source licensing. By downloading, installing, or using the JUCE framework, or combining the JUCE framework with any other source code, object code, content or any other copyrightable work, you agree to the terms of the JUCE End User Licence Agreement, and all incorporated terms including the JUCE Privacy Policy and the JUCE Website Terms of Service, as applicable, which will bind you. If you do not agree to the terms of these agreements, we will not license the JUCE framework to you, and you must discontinue the installation or download process and cease use of the JUCE framework. JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/ JUCE Privacy Policy: https://juce.com/juce-privacy-policy JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/ Or: You may also use this code under the terms of the AGPLv3: https://www.gnu.org/licenses/agpl-3.0.en.html THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. ============================================================================== */ namespace juce { /* ============================================================================== In accordance with the terms of the JUCE 7 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-7-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 constexpr int millisecondsToDisplaySplash = 2000, splashScreenFadeOutTime = 2000, 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 ([[maybe_unused]] Component& 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); } setAccessible (false); } std::unique_ptr JUCESplashScreen::getSplashScreenLogo() { const char* svgData = 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(); } //============================================================================== std::unique_ptr JUCESplashScreen::createAccessibilityHandler() { return std::make_unique (*this, AccessibilityRole::splashScreen); } // END SECTION A } // namespace juce