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.

123 lines
4.1KB

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