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.

150 lines
5.7KB

  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"),
  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. auto buildDate = Time::getCompilationDate();
  40. addAndMakeVisible (versionLabel);
  41. versionLabel.setText ("JUCE v" + ProjucerApplication::getApp().getApplicationVersion()
  42. + "\nBuild date: " + String (buildDate.getDayOfMonth())
  43. + " " + Time::getMonthName (buildDate.getMonth(), true)
  44. + " " + String (buildDate.getYear()),
  45. dontSendNotification);
  46. versionLabel.setJustificationType (Justification::centred);
  47. addAndMakeVisible (copyrightLabel);
  48. copyrightLabel.setJustificationType (Justification::centred);
  49. addAndMakeVisible (aboutButton);
  50. aboutButton.setTooltip ( {} );
  51. if (showPurchaseButton)
  52. {
  53. addAndMakeVisible (licenseButton = new TextButton ("Purchase License"));
  54. licenseButton->addListener (this);
  55. }
  56. }
  57. void resized() override
  58. {
  59. auto bounds = getLocalBounds();
  60. bounds.removeFromBottom (20);
  61. auto rightSlice = bounds.removeFromRight (150);
  62. auto leftSlice = bounds.removeFromLeft (150);
  63. auto centreSlice = bounds;
  64. //======================================================================
  65. rightSlice.removeFromRight (20);
  66. auto iconSlice = rightSlice.removeFromRight (100);
  67. huckleberryLogoBounds = iconSlice.removeFromBottom (100).toFloat();
  68. //======================================================================
  69. juceLogoBounds = leftSlice.removeFromTop (150).toFloat();
  70. juceLogoBounds.setWidth (juceLogoBounds.getWidth() + 100);
  71. juceLogoBounds.setHeight (juceLogoBounds.getHeight() + 100);
  72. copyrightLabel.setBounds (leftSlice.removeFromBottom (20));
  73. //======================================================================
  74. auto titleHeight = 40;
  75. centreSlice.removeFromTop ((centreSlice.getHeight() / 2) - (titleHeight / 2));
  76. titleLabel.setBounds (centreSlice.removeFromTop (titleHeight));
  77. centreSlice.removeFromTop (10);
  78. versionLabel.setBounds (centreSlice.removeFromTop (40));
  79. centreSlice.removeFromTop (10);
  80. if (licenseButton != nullptr)
  81. licenseButton->setBounds (centreSlice.removeFromTop (25).reduced (25, 0));
  82. aboutButton.setBounds (centreSlice.removeFromBottom (20));
  83. }
  84. void paint (Graphics& g) override
  85. {
  86. g.fillAll (findColour (backgroundColourId));
  87. if (juceLogo != nullptr)
  88. juceLogo->drawWithin (g, juceLogoBounds.translated (-75, -75), RectanglePlacement::centred, 1.0);
  89. if (huckleberryLogo != nullptr)
  90. huckleberryLogo->drawWithin (g, huckleberryLogoBounds, RectanglePlacement::centred, 1.0);
  91. }
  92. private:
  93. Label titleLabel, versionLabel, copyrightLabel;
  94. HyperlinkButton aboutButton;
  95. ScopedPointer<TextButton> licenseButton;
  96. Rectangle<float> huckleberryLogoBounds;
  97. Rectangle<float> juceLogoBounds;
  98. ScopedPointer<Drawable> juceLogo
  99. = Drawable::createFromImageData (BinaryData::juce_icon_png,
  100. BinaryData::juce_icon_pngSize);
  101. ScopedPointer<Drawable> huckleberryLogo
  102. = Drawable::createFromImageData (BinaryData::huckleberry_icon_svg,
  103. BinaryData::huckleberry_icon_svgSize);
  104. void buttonClicked (Button* b) override
  105. {
  106. if (b == licenseButton)
  107. {
  108. if (LicenseController* controller = ProjucerApplication::getApp().licenseController)
  109. controller->chooseNewLicense();
  110. }
  111. }
  112. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AboutWindowComponent)
  113. };