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.

144 lines
5.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. class AboutWindowComponent : public Component,
  21. private Button::Listener
  22. {
  23. public:
  24. AboutWindowComponent()
  25. : titleLabel ("title", "PROJUCER"),
  26. versionLabel ("version", "JUCE v" + ProjucerApplication::getApp().getApplicationVersion()),
  27. copyrightLabel ("copyright", String (CharPointer_UTF8 ("\xc2\xa9")) + String (" 2017 ROLI Ltd.")),
  28. aboutButton ("About Us", URL ("https://juce.com"))
  29. {
  30. bool showPurchaseButton = false;
  31. #if ! JUCER_ENABLE_GPL_MODE
  32. if (LicenseController* controller = ProjucerApplication::getApp().licenseController)
  33. showPurchaseButton = (controller->getState().type != LicenseState::Type::indie
  34. && controller->getState().type != LicenseState::Type::pro);
  35. #endif
  36. addAndMakeVisible (titleLabel);
  37. titleLabel.setJustificationType (Justification::centred);
  38. titleLabel.setFont (Font (35.0f, Font::FontStyleFlags::bold));
  39. addAndMakeVisible (versionLabel);
  40. versionLabel.setJustificationType (Justification::centred);
  41. addAndMakeVisible (copyrightLabel);
  42. copyrightLabel.setJustificationType (Justification::centred);
  43. addAndMakeVisible (aboutButton);
  44. aboutButton.setTooltip ( {} );
  45. if (showPurchaseButton)
  46. {
  47. addAndMakeVisible (licenseButton = new TextButton ("Purchase License"));
  48. licenseButton->addListener (this);
  49. }
  50. }
  51. void resized() override
  52. {
  53. auto bounds = getLocalBounds();
  54. bounds.removeFromBottom (20);
  55. auto rightSlice = bounds.removeFromRight (150);
  56. auto leftSlice = bounds.removeFromLeft (150);
  57. auto centreSlice = bounds;
  58. //======================================================================
  59. rightSlice.removeFromRight (20);
  60. auto iconSlice = rightSlice.removeFromRight (100);
  61. huckleberryLogoBounds = iconSlice.removeFromBottom (100).toFloat();
  62. //======================================================================
  63. juceLogoBounds = leftSlice.removeFromTop (150).toFloat();
  64. juceLogoBounds.setWidth (juceLogoBounds.getWidth() + 100);
  65. juceLogoBounds.setHeight (juceLogoBounds.getHeight() + 100);
  66. copyrightLabel.setBounds (leftSlice.removeFromBottom (20));
  67. //======================================================================
  68. auto titleHeight = 40;
  69. centreSlice.removeFromTop ((centreSlice.getHeight() / 2) - (titleHeight / 2));
  70. titleLabel.setBounds (centreSlice.removeFromTop (titleHeight));
  71. centreSlice.removeFromTop (10);
  72. versionLabel.setBounds (centreSlice.removeFromTop (25));
  73. centreSlice.removeFromTop (10);
  74. if (licenseButton != nullptr)
  75. licenseButton->setBounds (centreSlice.removeFromTop (25).reduced (25, 0));
  76. aboutButton.setBounds (centreSlice.removeFromBottom (20));
  77. }
  78. void paint (Graphics& g) override
  79. {
  80. g.fillAll (findColour (backgroundColourId));
  81. if (juceLogo != nullptr)
  82. juceLogo->drawWithin (g, juceLogoBounds.translated (-75, -75), RectanglePlacement::centred, 1.0);
  83. if (huckleberryLogo != nullptr)
  84. huckleberryLogo->drawWithin (g, huckleberryLogoBounds, RectanglePlacement::centred, 1.0);
  85. }
  86. private:
  87. Label titleLabel, versionLabel, copyrightLabel;
  88. HyperlinkButton aboutButton;
  89. ScopedPointer<TextButton> licenseButton;
  90. Rectangle<float> huckleberryLogoBounds;
  91. Rectangle<float> juceLogoBounds;
  92. ScopedPointer<Drawable> juceLogo
  93. = Drawable::createFromImageData (BinaryData::juce_icon_png,
  94. BinaryData::juce_icon_pngSize);
  95. ScopedPointer<Drawable> huckleberryLogo
  96. = Drawable::createFromImageData (BinaryData::huckleberry_icon_svg,
  97. BinaryData::huckleberry_icon_svgSize);
  98. void buttonClicked (Button* b) override
  99. {
  100. if (b == licenseButton)
  101. {
  102. if (LicenseController* controller = ProjucerApplication::getApp().licenseController)
  103. controller->chooseNewLicense();
  104. }
  105. }
  106. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AboutWindowComponent)
  107. };