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.

147 lines
6.6KB

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