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.

121 lines
4.0KB

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