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.

126 lines
4.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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. #include "JuceDemoHeader.h"
  18. //==============================================================================
  19. class IntroScreen : public Component
  20. {
  21. public:
  22. IntroScreen()
  23. : linkButton ("www.juce.com", URL ("http://www.juce.com"))
  24. {
  25. setOpaque (true);
  26. addAndMakeVisible (versionLabel);
  27. addAndMakeVisible (linkButton);
  28. addAndMakeVisible (logo);
  29. versionLabel.setColour (Label::textColourId, Colours::white);
  30. versionLabel.setText (String ("{version} built on {date}")
  31. .replace ("{version}", SystemStats::getJUCEVersion())
  32. .replace ("{date}", String (__DATE__).replace (" ", " ")),
  33. dontSendNotification);
  34. linkButton.setColour (HyperlinkButton::textColourId, Colours::lightblue);
  35. }
  36. void paint (Graphics& g) override
  37. {
  38. g.fillAll (Colour (0xff4d4d4d));
  39. }
  40. void resized() override
  41. {
  42. Rectangle<int> area (getLocalBounds().reduced (10));
  43. logo.setBounds (area);
  44. area = area.removeFromBottom (24);
  45. linkButton.setBounds (area.removeFromRight (getWidth() / 4));
  46. versionLabel.setBounds (area);
  47. }
  48. private:
  49. Label versionLabel;
  50. HyperlinkButton linkButton;
  51. //==============================================================================
  52. struct LogoDrawComponent : public Component,
  53. private Timer
  54. {
  55. LogoDrawComponent() : logoPath (MainAppWindow::getJUCELogoPath()), elapsed (0.0f)
  56. {
  57. startTimerHz (30); // repaint at 30 fps
  58. }
  59. void paint (Graphics& g) override
  60. {
  61. Path wavePath;
  62. const float waveStep = 10.0f;
  63. const float waveY = getHeight() * 0.44f;
  64. int i = 0;
  65. for (float x = waveStep * 0.5f; x < getWidth(); x += waveStep)
  66. {
  67. const float y1 = waveY + getHeight() * 0.05f * std::sin (i * 0.38f + elapsed);
  68. const float y2 = waveY + getHeight() * 0.10f * std::sin (i * 0.20f + elapsed * 2.0f);
  69. wavePath.addLineSegment (Line<float> (x, y1, x, y2), 2.0f);
  70. wavePath.addEllipse (x - waveStep * 0.3f, y1 - waveStep * 0.3f, waveStep * 0.6f, waveStep * 0.6f);
  71. wavePath.addEllipse (x - waveStep * 0.3f, y2 - waveStep * 0.3f, waveStep * 0.6f, waveStep * 0.6f);
  72. ++i;
  73. }
  74. g.setColour (Colour::greyLevel (0.4f));
  75. g.fillPath (wavePath);
  76. g.setColour (Colour (0xc4f39082));
  77. g.fillPath (logoPath, RectanglePlacement (RectanglePlacement::centred)
  78. .getTransformToFit (logoPath.getBounds(),
  79. getLocalBounds().reduced (20, getHeight() / 4).toFloat()));
  80. }
  81. private:
  82. void timerCallback() override
  83. {
  84. repaint();
  85. elapsed += 0.02f;
  86. }
  87. Path logoPath;
  88. float elapsed;
  89. };
  90. LogoDrawComponent logo;
  91. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (IntroScreen)
  92. };
  93. // This static object will register this demo type in a global list of demos..
  94. static JuceDemoType<IntroScreen> demo ("00 Welcome!");