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.

125 lines
4.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #include "JuceDemoHeader.h"
  20. //==============================================================================
  21. class IntroScreen : public Component
  22. {
  23. public:
  24. IntroScreen()
  25. {
  26. setOpaque (true);
  27. addAndMakeVisible (versionLabel);
  28. addAndMakeVisible (linkButton);
  29. addAndMakeVisible (logo);
  30. // versionLabel.setColour (Label::textColourId, Colours::white);
  31. versionLabel.setText (String ("{version} built on {date}")
  32. .replace ("{version}", SystemStats::getJUCEVersion())
  33. .replace ("{date}", String (__DATE__).replace (" ", " ")),
  34. dontSendNotification);
  35. linkButton.setColour (HyperlinkButton::textColourId, Colours::lightblue);
  36. }
  37. void paint (Graphics& g) override
  38. {
  39. g.fillAll (getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground));
  40. }
  41. void resized() override
  42. {
  43. auto area = getLocalBounds().reduced (10);
  44. logo.setBounds (area);
  45. area = area.removeFromBottom (24);
  46. linkButton.setBounds (area.removeFromRight (getWidth() / 4));
  47. versionLabel.setBounds (area);
  48. }
  49. private:
  50. Label versionLabel;
  51. HyperlinkButton linkButton { "www.juce.com", URL ("http://www.juce.com") };
  52. //==============================================================================
  53. struct LogoDrawComponent : public Component,
  54. private Timer
  55. {
  56. LogoDrawComponent()
  57. {
  58. startTimerHz (30); // repaint at 30 fps
  59. }
  60. void paint (Graphics& g) override
  61. {
  62. Path wavePath;
  63. const float waveStep = 10.0f;
  64. const float waveY = getHeight() * 0.44f;
  65. int i = 0;
  66. for (float x = waveStep * 0.5f; x < getWidth(); x += waveStep)
  67. {
  68. const float y1 = waveY + getHeight() * 0.05f * std::sin (i * 0.38f + elapsed);
  69. const float y2 = waveY + getHeight() * 0.10f * std::sin (i * 0.20f + elapsed * 2.0f);
  70. wavePath.addLineSegment (Line<float> (x, y1, x, y2), 2.0f);
  71. wavePath.addEllipse (x - waveStep * 0.3f, y1 - waveStep * 0.3f, waveStep * 0.6f, waveStep * 0.6f);
  72. wavePath.addEllipse (x - waveStep * 0.3f, y2 - waveStep * 0.3f, waveStep * 0.6f, waveStep * 0.6f);
  73. ++i;
  74. }
  75. g.setColour (Colour::greyLevel (0.4f));
  76. g.fillPath (wavePath);
  77. g.setColour (Colour (0xc4f39082));
  78. g.fillPath (logoPath, RectanglePlacement (RectanglePlacement::centred)
  79. .getTransformToFit (logoPath.getBounds(),
  80. getLocalBounds().reduced (20, getHeight() / 4).toFloat()));
  81. }
  82. void timerCallback() override
  83. {
  84. repaint();
  85. elapsed += 0.02f;
  86. }
  87. Path logoPath { MainAppWindow::getJUCELogoPath() };
  88. float elapsed = 0;
  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!");