The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
6.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef __JUCE_SPLASHSCREEN_JUCEHEADER__
  18. #define __JUCE_SPLASHSCREEN_JUCEHEADER__
  19. //==============================================================================
  20. /** A component for showing a splash screen while your app starts up.
  21. This will automatically position itself, and delete itself when the app has
  22. finished initialising (it uses the JUCEApplication::isInitialising() to detect
  23. this).
  24. To use it, just create one of these in your JUCEApplication::initialise() method,
  25. call its show() method and let the object delete itself later.
  26. E.g. @code
  27. void MyApp::initialise (const String& commandLine)
  28. {
  29. SplashScreen* splash = new SplashScreen();
  30. splash->show ("welcome to my app",
  31. ImageCache::getFromFile (File ("/foobar/splash.jpg")),
  32. 4000, false);
  33. .. no need to delete the splash screen - it'll do that itself.
  34. }
  35. @endcode
  36. */
  37. class JUCE_API SplashScreen : public Component,
  38. private Timer,
  39. private DeletedAtShutdown
  40. {
  41. public:
  42. //==============================================================================
  43. /** Creates a SplashScreen object.
  44. After creating one of these (or your subclass of it), call one of the show()
  45. methods to display it.
  46. */
  47. SplashScreen();
  48. /** Destructor. */
  49. ~SplashScreen();
  50. //==============================================================================
  51. /** Creates a SplashScreen object that will display an image.
  52. As soon as this is called, the SplashScreen will be displayed in the centre of the
  53. screen. This method will also dispatch any pending messages to make sure that when
  54. it returns, the splash screen has been completely drawn, and your initialisation
  55. code can carry on.
  56. @param title the name to give the component
  57. @param backgroundImage an image to draw on the component. The component's size
  58. will be set to the size of this image, and if the image is
  59. semi-transparent, the component will be made semi-transparent
  60. too. This image will be deleted (or released from the ImageCache
  61. if that's how it was created) by the splash screen object when
  62. it is itself deleted.
  63. @param minimumTimeToDisplayFor how long (in milliseconds) the splash screen
  64. should stay visible for. If the initialisation takes longer than
  65. this time, the splash screen will wait for it to finish before
  66. disappearing, but if initialisation is very quick, this lets
  67. you make sure that people get a good look at your splash.
  68. @param useDropShadow if true, the window will have a drop shadow
  69. @param removeOnMouseClick if true, the window will go away as soon as the user clicks
  70. the mouse (anywhere)
  71. */
  72. void show (const String& title,
  73. const Image& backgroundImage,
  74. int minimumTimeToDisplayFor,
  75. bool useDropShadow,
  76. bool removeOnMouseClick = true);
  77. /** Creates a SplashScreen object with a specified size.
  78. For a custom splash screen, you can use this method to display it at a certain size
  79. and then override the paint() method yourself to do whatever's necessary.
  80. As soon as this is called, the SplashScreen will be displayed in the centre of the
  81. screen. This method will also dispatch any pending messages to make sure that when
  82. it returns, the splash screen has been completely drawn, and your initialisation
  83. code can carry on.
  84. @param title the name to give the component
  85. @param width the width to use
  86. @param height the height to use
  87. @param minimumTimeToDisplayFor how long (in milliseconds) the splash screen
  88. should stay visible for. If the initialisation takes longer than
  89. this time, the splash screen will wait for it to finish before
  90. disappearing, but if initialisation is very quick, this lets
  91. you make sure that people get a good look at your splash.
  92. @param useDropShadow if true, the window will have a drop shadow
  93. @param removeOnMouseClick if true, the window will go away as soon as the user clicks
  94. the mouse (anywhere)
  95. */
  96. void show (const String& title,
  97. int width,
  98. int height,
  99. int minimumTimeToDisplayFor,
  100. bool useDropShadow,
  101. bool removeOnMouseClick = true);
  102. //==============================================================================
  103. /** @internal */
  104. void paint (Graphics&);
  105. private:
  106. //==============================================================================
  107. Image backgroundImage;
  108. Time earliestTimeToDelete;
  109. int originalClickCounter;
  110. void timerCallback();
  111. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SplashScreen)
  112. };
  113. #endif // __JUCE_SPLASHSCREEN_JUCEHEADER__