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.

130 lines
4.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - 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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-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. setTitle ("Home");
  35. setFocusContainerType (FocusContainerType::focusContainer);
  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. auto bottomSlice = area.removeFromBottom (24);
  45. linkButton.setBounds (bottomSlice.removeFromRight (getWidth() / 4));
  46. versionLabel.setBounds (bottomSlice);
  47. logo.setBounds (area);
  48. }
  49. private:
  50. Label versionLabel;
  51. HyperlinkButton linkButton { "www.juce.com", { "http://www.juce.com" } };
  52. //==============================================================================
  53. struct LogoDrawComponent : public Component,
  54. private Timer
  55. {
  56. LogoDrawComponent()
  57. {
  58. setTitle ("JUCE Logo");
  59. startTimerHz (30); // repaint at 30 fps
  60. }
  61. void paint (Graphics& g) override
  62. {
  63. Path wavePath;
  64. auto waveStep = 10.0f;
  65. auto waveY = (float) getHeight() * 0.5f;
  66. int i = 0;
  67. for (auto x = waveStep * 0.5f; x < (float) getWidth(); x += waveStep)
  68. {
  69. auto y1 = waveY + (float) getHeight() * 0.05f * std::sin ((float) i * 0.38f + elapsed);
  70. auto y2 = waveY + (float) getHeight() * 0.10f * std::sin ((float) i * 0.20f + elapsed * 2.0f);
  71. wavePath.addLineSegment ({ x, y1, x, y2 }, 2.0f);
  72. wavePath.addEllipse (x - waveStep * 0.3f, y1 - waveStep * 0.3f, waveStep * 0.6f, waveStep * 0.6f);
  73. wavePath.addEllipse (x - waveStep * 0.3f, y2 - waveStep * 0.3f, waveStep * 0.6f, waveStep * 0.6f);
  74. ++i;
  75. }
  76. g.setColour (Colour::greyLevel (0.4f));
  77. g.fillPath (wavePath);
  78. g.setColour (Colour (0xc4f39082));
  79. g.fillPath (logoPath, RectanglePlacement (RectanglePlacement::centred)
  80. .getTransformToFit (logoPath.getBounds(),
  81. getLocalBounds().reduced (20, getHeight() / 4).toFloat()));
  82. }
  83. void timerCallback() override
  84. {
  85. repaint();
  86. elapsed += 0.02f;
  87. }
  88. std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override
  89. {
  90. return std::make_unique<AccessibilityHandler> (*this, AccessibilityRole::image);
  91. }
  92. Path logoPath { getJUCELogoPath() };
  93. float elapsed = 0.0f;
  94. };
  95. LogoDrawComponent logo;
  96. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (IntroScreen)
  97. };