JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_SplashScreen.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29SplashScreen::SplashScreen (const String& title, const Image& image, bool useDropShadow)
30 : Component (title),
31 backgroundImage (image),
32 clickCountToDelete (0)
33{
34 // You must supply a valid image here!
35 jassert (backgroundImage.isValid());
36
37 setOpaque (! backgroundImage.hasAlphaChannel());
38
39 #if JUCE_IOS || JUCE_ANDROID
40 const bool useFullScreen = true;
41 #else
42 const bool useFullScreen = false;
43 #endif
44
45 makeVisible (image.getWidth(), image.getHeight(), useDropShadow, useFullScreen);
46}
47
48SplashScreen::SplashScreen (const String& title, int width, int height, bool useDropShadow)
49 : Component (title),
50 clickCountToDelete (0)
51{
52 makeVisible (width, height, useDropShadow, false);
53}
54
55void SplashScreen::makeVisible (int w, int h, bool useDropShadow, bool fullscreen)
56{
57 clickCountToDelete = Desktop::getInstance().getMouseButtonClickCounter();
58 creationTime = Time::getCurrentTime();
59
61 const int width = (fullscreen ? screenSize.getWidth() : w);
62 const int height = (fullscreen ? screenSize.getHeight() : h);
63
64 setAlwaysOnTop (true);
65 setVisible (true);
66 centreWithSize (width, height);
68
69 if (fullscreen)
70 getPeer()->setFullScreen (true);
71
72 toFront (false);
73}
74
76
78{
79 // Note that this method must be safe to call from non-GUI threads
81 clickCountToDelete = std::numeric_limits<int>::max();
82
83 minimumVisibleTime = timeout;
84
85 startTimer (50);
86}
87
89{
90 g.setOpacity (1.0f);
92}
93
94void SplashScreen::timerCallback()
95{
96 if (Time::getCurrentTime() > creationTime + minimumVisibleTime
97 || Desktop::getInstance().getMouseButtonClickCounter() > clickCountToDelete)
98 delete this;
99}
100
101} // namespace juce
virtual void setFullScreen(bool shouldBeFullScreen)=0
Enable/disable fullscreen mode for the window.
@ windowHasDropShadow
Indicates that the window should have a drop-shadow (this may not be possible on all platforms).
The base class for all JUCE user-interface objects.
void toFront(bool shouldAlsoGainKeyboardFocus)
Brings the component to the front of its siblings.
void setAlwaysOnTop(bool shouldStayOnTop)
Sets whether the component should always be kept at the front of its siblings.
void setOpaque(bool shouldBeOpaque)
Indicates whether any parts of the component might be transparent.
virtual void addToDesktop(int windowStyleFlags, void *nativeWindowToAttachTo=nullptr)
Makes this component appear as a window on the desktop.
ComponentPeer * getPeer() const
Returns the heavyweight window that contains this component.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
void centreWithSize(int width, int height)
Changes the component's size and centres it within its parent.
virtual void setVisible(bool shouldBeVisible)
Makes the component visible or invisible.
const Displays & getDisplays() const noexcept
Returns the Displays object representing the connected displays.
int getMouseButtonClickCounter() const noexcept
Returns the number of times the mouse button has been clicked since the app started.
static Desktop &JUCE_CALLTYPE getInstance()
There's only one desktop object, and this method will return it.
Rectangle< int > userArea
The total area of this display in logical pixels which isn't covered by OS-dependent objects like the...
const Display * getPrimaryDisplay() const noexcept
Returns the Display object representing the display acting as the user's main screen,...
A graphics context, used for drawing a component or image.
void drawImage(const Image &imageToDraw, int destX, int destY, int destWidth, int destHeight, int sourceX, int sourceY, int sourceWidth, int sourceHeight, bool fillAlphaChannelWithCurrentBrush=false) const
Draws part of an image, rescaling it to fit in a given target region.
void setOpacity(float newOpacity)
Changes the opacity to use with the current colour.
Holds a fixed-size bitmap.
Definition juce_Image.h:58
bool hasAlphaChannel() const noexcept
True if the image contains an alpha-channel.
bool isValid() const noexcept
Returns true if this image isn't null.
Definition juce_Image.h:147
Defines the method used to position some kind of rectangular object within a rectangular viewport.
@ fillDestination
If this flag is set, then the source rectangle will be resized so that it is the minimum size to comp...
Manages a rectangle and allows geometric operations to be performed on it.
A relative measure of time.
void paint(Graphics &) override
Components can override this method to draw their content.
void deleteAfterDelay(RelativeTime minimumTotalTimeToDisplayFor, bool removeOnMouseClick)
Tells the component to auto-delete itself after a timeout period, or when the mouse is clicked.
SplashScreen(const String &title, const Image &backgroundImage, bool useDropShadow)
Creates a SplashScreen object.
~SplashScreen() override
Destructor.
The JUCE String class!
Definition juce_String.h:53
static Time JUCE_CALLTYPE getCurrentTime() noexcept
Returns a Time object that is set to the current system time.
void startTimer(int intervalInMilliseconds) noexcept
Starts the timer and sets the length of interval required.
#define jassert(expression)
Platform-independent assertion macro.
T max(T... args)
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88