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.

143 lines
5.5KB

  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. {
  23. public:
  24. AboutWindowComponent()
  25. {
  26. bool showPurchaseButton = false;
  27. #if ! JUCER_ENABLE_GPL_MODE
  28. if (auto* controller = ProjucerApplication::getApp().licenseController.get())
  29. showPurchaseButton = (controller->getState().type != LicenseState::Type::indie
  30. && controller->getState().type != LicenseState::Type::pro);
  31. #endif
  32. addAndMakeVisible (titleLabel);
  33. titleLabel.setJustificationType (Justification::centred);
  34. titleLabel.setFont (Font (35.0f, Font::FontStyleFlags::bold));
  35. auto buildDate = Time::getCompilationDate();
  36. addAndMakeVisible (versionLabel);
  37. versionLabel.setText ("JUCE v" + ProjucerApplication::getApp().getApplicationVersion()
  38. + "\nBuild date: " + String (buildDate.getDayOfMonth())
  39. + " " + Time::getMonthName (buildDate.getMonth(), true)
  40. + " " + String (buildDate.getYear()),
  41. dontSendNotification);
  42. versionLabel.setJustificationType (Justification::centred);
  43. addAndMakeVisible (copyrightLabel);
  44. copyrightLabel.setJustificationType (Justification::centred);
  45. addAndMakeVisible (aboutButton);
  46. aboutButton.setTooltip ( {} );
  47. if (showPurchaseButton)
  48. {
  49. addAndMakeVisible (licenseButton);
  50. licenseButton.onClick = []
  51. {
  52. if (auto* controller = ProjucerApplication::getApp().licenseController.get())
  53. controller->chooseNewLicense();
  54. };
  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.isShowing())
  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 { "title", "PROJUCER" },
  94. versionLabel { "version" },
  95. copyrightLabel { "copyright", String (CharPointer_UTF8 ("\xc2\xa9")) + String (" 2017 ROLI Ltd.") };
  96. HyperlinkButton aboutButton { "About Us", URL ("https://juce.com") };
  97. TextButton licenseButton { "Purchase License" };
  98. Rectangle<float> huckleberryLogoBounds, juceLogoBounds;
  99. ScopedPointer<Drawable> juceLogo { Drawable::createFromImageData (BinaryData::juce_icon_png,
  100. BinaryData::juce_icon_pngSize) };
  101. ScopedPointer<Drawable> huckleberryLogo { Drawable::createFromImageData (BinaryData::huckleberry_icon_svg,
  102. BinaryData::huckleberry_icon_svgSize) };
  103. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AboutWindowComponent)
  104. };