/* ============================================================================== This file is part of the JUCE 6 technical preview. Copyright (c) 2020 - Raw Material Software Limited You may use this code under the terms of the GPL v3 (see www.gnu.org/licenses). For this technical preview, this file is not subject to commercial licensing. 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 5 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-5-licence ============================================================================== */ // BEGIN SECTION A #if ! defined (JUCE_REPORT_APP_USAGE) #define JUCE_REPORT_APP_USAGE 1 #endif #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