1 /*
2   ==============================================================================
3 
4    This file is part of the JUCE library.
5    Copyright (c) 2020 - Raw Material Software Limited
6 
7    JUCE is an open source library subject to commercial or open-source
8    licensing.
9 
10    By using JUCE, you agree to the terms of both the JUCE 6 End-User License
11    Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
12 
13    End User License Agreement: www.juce.com/juce-6-licence
14    Privacy Policy: www.juce.com/juce-privacy-policy
15 
16    Or: You may also use this code under the terms of the GPL v3 (see
17    www.gnu.org/licenses).
18 
19    JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20    EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21    DISCLAIMED.
22 
23   ==============================================================================
24 */
25 
26 #pragma once
27 
28 
29 //==============================================================================
30 class AboutWindowComponent    : public Component
31 {
32 public:
AboutWindowComponent()33     AboutWindowComponent()
34     {
35         addAndMakeVisible (titleLabel);
36         titleLabel.setJustificationType (Justification::centred);
37         titleLabel.setFont (Font (35.0f, Font::FontStyleFlags::bold));
38 
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 
47         versionLabel.setJustificationType (Justification::centred);
48         addAndMakeVisible (copyrightLabel);
49         copyrightLabel.setJustificationType (Justification::centred);
50 
51         addAndMakeVisible (aboutButton);
52         aboutButton.setTooltip ( {} );
53     }
54 
resized()55     void resized() override
56     {
57         auto bounds = getLocalBounds();
58         bounds.removeFromBottom (20);
59 
60         auto leftSlice   = bounds.removeFromLeft (150);
61         auto centreSlice = bounds.withTrimmedRight (150);
62 
63         juceLogoBounds = leftSlice.removeFromTop (150).toFloat();
64         juceLogoBounds.setWidth (juceLogoBounds.getWidth() + 100);
65         juceLogoBounds.setHeight (juceLogoBounds.getHeight() + 100);
66 
67         copyrightLabel.setBounds (leftSlice.removeFromBottom (20));
68 
69         auto titleHeight = 40;
70 
71         centreSlice.removeFromTop ((centreSlice.getHeight() / 2) - (titleHeight / 2));
72 
73         titleLabel.setBounds (centreSlice.removeFromTop (titleHeight));
74 
75         centreSlice.removeFromTop (10);
76         versionLabel.setBounds (centreSlice.removeFromTop (40));
77 
78         centreSlice.removeFromTop (10);
79         aboutButton.setBounds (centreSlice.removeFromBottom (20));
80     }
81 
paint(Graphics & g)82     void paint (Graphics& g) override
83     {
84         g.fillAll (findColour (backgroundColourId));
85 
86         if (juceLogo != nullptr)
87             juceLogo->drawWithin (g, juceLogoBounds.translated (-75, -75), RectanglePlacement::centred, 1.0);
88     }
89 
90 private:
91     Label titleLabel { "title", "PROJUCER" },
92           versionLabel { "version" },
93           copyrightLabel { "copyright", String (CharPointer_UTF8 ("\xc2\xa9")) + String (" 2020 Raw Material Software Limited") };
94 
95     HyperlinkButton aboutButton { "About Us", URL ("https://juce.com") };
96 
97     Rectangle<float> juceLogoBounds;
98 
99     std::unique_ptr<Drawable> juceLogo { Drawable::createFromImageData (BinaryData::juce_icon_png,
100                                                                         BinaryData::juce_icon_pngSize) };
101 
102     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AboutWindowComponent)
103 };
104