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.

114 lines
3.7KB

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