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.

104 lines
3.8KB

  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 AboutWindowComponent : public Component
  21. {
  22. public:
  23. AboutWindowComponent()
  24. {
  25. addAndMakeVisible (titleLabel);
  26. titleLabel.setJustificationType (Justification::centred);
  27. titleLabel.setFont (Font (35.0f, Font::FontStyleFlags::bold));
  28. auto buildDate = Time::getCompilationDate();
  29. addAndMakeVisible (versionLabel);
  30. versionLabel.setText ("JUCE v" + ProjucerApplication::getApp().getApplicationVersion()
  31. + "\nBuild date: " + String (buildDate.getDayOfMonth())
  32. + " " + Time::getMonthName (buildDate.getMonth(), true)
  33. + " " + String (buildDate.getYear()),
  34. dontSendNotification);
  35. versionLabel.setJustificationType (Justification::centred);
  36. addAndMakeVisible (copyrightLabel);
  37. copyrightLabel.setJustificationType (Justification::centred);
  38. addAndMakeVisible (aboutButton);
  39. aboutButton.setTooltip ( {} );
  40. }
  41. void resized() override
  42. {
  43. auto bounds = getLocalBounds();
  44. bounds.removeFromBottom (20);
  45. auto leftSlice = bounds.removeFromLeft (150);
  46. auto centreSlice = bounds.withTrimmedRight (150);
  47. juceLogoBounds = leftSlice.removeFromTop (150).toFloat();
  48. juceLogoBounds.setWidth (juceLogoBounds.getWidth() + 100);
  49. juceLogoBounds.setHeight (juceLogoBounds.getHeight() + 100);
  50. auto titleHeight = 40;
  51. centreSlice.removeFromTop ((centreSlice.getHeight() / 2) - (titleHeight / 2));
  52. titleLabel.setBounds (centreSlice.removeFromTop (titleHeight));
  53. centreSlice.removeFromTop (10);
  54. versionLabel.setBounds (centreSlice.removeFromTop (40));
  55. centreSlice.removeFromTop (10);
  56. aboutButton.setBounds (centreSlice.removeFromTop (20));
  57. copyrightLabel.setBounds (getLocalBounds().removeFromBottom (50));
  58. }
  59. void paint (Graphics& g) override
  60. {
  61. g.fillAll (findColour (backgroundColourId));
  62. if (juceLogo != nullptr)
  63. juceLogo->drawWithin (g, juceLogoBounds.translated (-75, -75), RectanglePlacement::centred, 1.0);
  64. }
  65. private:
  66. Label titleLabel { "title", "PROJUCER" },
  67. versionLabel { "version" },
  68. copyrightLabel { "copyright", String (CharPointer_UTF8 ("\xc2\xa9")) + String (" 2020 Raw Material Software Limited") };
  69. HyperlinkButton aboutButton { "About Us", URL ("https://juce.com") };
  70. Rectangle<float> juceLogoBounds;
  71. std::unique_ptr<Drawable> juceLogo { Drawable::createFromImageData (BinaryData::juce_icon_png,
  72. BinaryData::juce_icon_pngSize) };
  73. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AboutWindowComponent)
  74. };