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.

111 lines
4.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. #pragma once
  14. //==============================================================================
  15. class AboutWindowComponent : public Component
  16. {
  17. public:
  18. AboutWindowComponent()
  19. {
  20. addAndMakeVisible (titleLabel);
  21. titleLabel.setJustificationType (Justification::centred);
  22. titleLabel.setFont (Font (35.0f, Font::FontStyleFlags::bold));
  23. auto buildDate = Time::getCompilationDate();
  24. addAndMakeVisible (versionLabel);
  25. versionLabel.setText ("JUCE v" + ProjucerApplication::getApp().getApplicationVersion()
  26. + "\nBuild date: " + String (buildDate.getDayOfMonth())
  27. + " " + Time::getMonthName (buildDate.getMonth(), true)
  28. + " " + String (buildDate.getYear()),
  29. dontSendNotification);
  30. versionLabel.setJustificationType (Justification::centred);
  31. addAndMakeVisible (copyrightLabel);
  32. copyrightLabel.setJustificationType (Justification::centred);
  33. addAndMakeVisible (aboutButton);
  34. aboutButton.setTooltip ( {} );
  35. }
  36. void resized() override
  37. {
  38. auto bounds = getLocalBounds();
  39. bounds.removeFromBottom (20);
  40. auto rightSlice = bounds.removeFromRight (150);
  41. auto leftSlice = bounds.removeFromLeft (150);
  42. auto centreSlice = bounds;
  43. //==============================================================================
  44. rightSlice.removeFromRight (20);
  45. auto iconSlice = rightSlice.removeFromRight (100);
  46. huckleberryLogoBounds = iconSlice.removeFromBottom (100).toFloat();
  47. //==============================================================================
  48. juceLogoBounds = leftSlice.removeFromTop (150).toFloat();
  49. juceLogoBounds.setWidth (juceLogoBounds.getWidth() + 100);
  50. juceLogoBounds.setHeight (juceLogoBounds.getHeight() + 100);
  51. copyrightLabel.setBounds (leftSlice.removeFromBottom (20));
  52. //==============================================================================
  53. auto titleHeight = 40;
  54. centreSlice.removeFromTop ((centreSlice.getHeight() / 2) - (titleHeight / 2));
  55. titleLabel.setBounds (centreSlice.removeFromTop (titleHeight));
  56. centreSlice.removeFromTop (10);
  57. versionLabel.setBounds (centreSlice.removeFromTop (40));
  58. centreSlice.removeFromTop (10);
  59. aboutButton.setBounds (centreSlice.removeFromBottom (20));
  60. }
  61. void paint (Graphics& g) override
  62. {
  63. g.fillAll (findColour (backgroundColourId));
  64. if (juceLogo != nullptr)
  65. juceLogo->drawWithin (g, juceLogoBounds.translated (-75, -75), RectanglePlacement::centred, 1.0);
  66. if (huckleberryLogo != nullptr)
  67. huckleberryLogo->drawWithin (g, huckleberryLogoBounds, RectanglePlacement::centred, 1.0);
  68. }
  69. private:
  70. Label titleLabel { "title", "PROJUCER" },
  71. versionLabel { "version" },
  72. copyrightLabel { "copyright", String (CharPointer_UTF8 ("\xc2\xa9")) + String (" 2017 ROLI Ltd.") };
  73. HyperlinkButton aboutButton { "About Us", URL ("https://juce.com") };
  74. Rectangle<float> huckleberryLogoBounds, juceLogoBounds;
  75. std::unique_ptr<Drawable> juceLogo { Drawable::createFromImageData (BinaryData::juce_icon_png,
  76. BinaryData::juce_icon_pngSize) };
  77. std::unique_ptr<Drawable> huckleberryLogo { Drawable::createFromImageData (BinaryData::huckleberry_icon_svg,
  78. BinaryData::huckleberry_icon_svgSize) };
  79. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AboutWindowComponent)
  80. };