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.

152 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. //==============================================================================
  21. class AboutWindowComponent : public Component,
  22. private Button::Listener
  23. {
  24. public:
  25. AboutWindowComponent()
  26. : titleLabel ("title", "PROJUCER"),
  27. versionLabel ("version"),
  28. copyrightLabel ("copyright", String (CharPointer_UTF8 ("\xc2\xa9")) + String (" 2017 ROLI Ltd.")),
  29. aboutButton ("About Us", URL ("https://juce.com"))
  30. {
  31. bool showPurchaseButton = false;
  32. #if ! JUCER_ENABLE_GPL_MODE
  33. if (LicenseController* controller = ProjucerApplication::getApp().licenseController)
  34. showPurchaseButton = (controller->getState().type != LicenseState::Type::indie
  35. && controller->getState().type != LicenseState::Type::pro);
  36. #endif
  37. addAndMakeVisible (titleLabel);
  38. titleLabel.setJustificationType (Justification::centred);
  39. titleLabel.setFont (Font (35.0f, Font::FontStyleFlags::bold));
  40. auto buildDate = Time::getCompilationDate();
  41. addAndMakeVisible (versionLabel);
  42. versionLabel.setText ("JUCE v" + ProjucerApplication::getApp().getApplicationVersion()
  43. + "\nBuild date: " + String (buildDate.getDayOfMonth())
  44. + " " + Time::getMonthName (buildDate.getMonth(), true)
  45. + " " + String (buildDate.getYear()),
  46. dontSendNotification);
  47. versionLabel.setJustificationType (Justification::centred);
  48. addAndMakeVisible (copyrightLabel);
  49. copyrightLabel.setJustificationType (Justification::centred);
  50. addAndMakeVisible (aboutButton);
  51. aboutButton.setTooltip ( {} );
  52. if (showPurchaseButton)
  53. {
  54. addAndMakeVisible (licenseButton = new TextButton ("Purchase License"));
  55. licenseButton->addListener (this);
  56. }
  57. }
  58. void resized() override
  59. {
  60. auto bounds = getLocalBounds();
  61. bounds.removeFromBottom (20);
  62. auto rightSlice = bounds.removeFromRight (150);
  63. auto leftSlice = bounds.removeFromLeft (150);
  64. auto centreSlice = bounds;
  65. //======================================================================
  66. rightSlice.removeFromRight (20);
  67. auto iconSlice = rightSlice.removeFromRight (100);
  68. huckleberryLogoBounds = iconSlice.removeFromBottom (100).toFloat();
  69. //======================================================================
  70. juceLogoBounds = leftSlice.removeFromTop (150).toFloat();
  71. juceLogoBounds.setWidth (juceLogoBounds.getWidth() + 100);
  72. juceLogoBounds.setHeight (juceLogoBounds.getHeight() + 100);
  73. copyrightLabel.setBounds (leftSlice.removeFromBottom (20));
  74. //======================================================================
  75. auto titleHeight = 40;
  76. centreSlice.removeFromTop ((centreSlice.getHeight() / 2) - (titleHeight / 2));
  77. titleLabel.setBounds (centreSlice.removeFromTop (titleHeight));
  78. centreSlice.removeFromTop (10);
  79. versionLabel.setBounds (centreSlice.removeFromTop (40));
  80. centreSlice.removeFromTop (10);
  81. if (licenseButton != nullptr)
  82. licenseButton->setBounds (centreSlice.removeFromTop (25).reduced (25, 0));
  83. aboutButton.setBounds (centreSlice.removeFromBottom (20));
  84. }
  85. void paint (Graphics& g) override
  86. {
  87. g.fillAll (findColour (backgroundColourId));
  88. if (juceLogo != nullptr)
  89. juceLogo->drawWithin (g, juceLogoBounds.translated (-75, -75), RectanglePlacement::centred, 1.0);
  90. if (huckleberryLogo != nullptr)
  91. huckleberryLogo->drawWithin (g, huckleberryLogoBounds, RectanglePlacement::centred, 1.0);
  92. }
  93. private:
  94. Label titleLabel, versionLabel, copyrightLabel;
  95. HyperlinkButton aboutButton;
  96. ScopedPointer<TextButton> licenseButton;
  97. Rectangle<float> huckleberryLogoBounds;
  98. Rectangle<float> juceLogoBounds;
  99. ScopedPointer<Drawable> juceLogo
  100. = Drawable::createFromImageData (BinaryData::juce_icon_png,
  101. BinaryData::juce_icon_pngSize);
  102. ScopedPointer<Drawable> huckleberryLogo
  103. = Drawable::createFromImageData (BinaryData::huckleberry_icon_svg,
  104. BinaryData::huckleberry_icon_svgSize);
  105. void buttonClicked (Button* b) override
  106. {
  107. if (b == licenseButton)
  108. {
  109. if (LicenseController* controller = ProjucerApplication::getApp().licenseController)
  110. controller->chooseNewLicense();
  111. }
  112. }
  113. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AboutWindowComponent)
  114. };