ReaWwise

REAPER extension
Log | Files | Refs | Submodules

AboutComponent.cpp (4975B)


      1 /*----------------------------------------------------------------------------------------
      2 
      3 Copyright (c) 2023 AUDIOKINETIC Inc.
      4 
      5 This file is licensed to use under the license available at:
      6 https://github.com/audiokinetic/ReaWwise/blob/main/License.txt (the "License").
      7 You may not use this file except in compliance with the License.
      8 
      9 Unless required by applicable law or agreed to in writing, software distributed
     10 under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
     11 CONDITIONS OF ANY KIND, either express or implied.  See the License for the
     12 specific language governing permissions and limitations under the License.
     13 
     14 ----------------------------------------------------------------------------------------*/
     15 
     16 #include "AboutComponent.h"
     17 
     18 #include "AK/AkWwiseSDKVersion.h"
     19 #include "BinaryData.h"
     20 #include "Theme/CustomLookAndFeel.h"
     21 
     22 #include <juce_gui_basics/juce_gui_basics.h>
     23 
     24 #define AK_WWISE_VST_VERSION_FULL AK_WWISESDK_VERSIONNAME_SHORT "." AK_WWISESDK_NUM2STRING(AK_WWISESDK_VERSION_BUILD)
     25 
     26 namespace AK::WwiseTransfer
     27 {
     28 	namespace AboutComponentConstants
     29 	{
     30 		constexpr int titleHeight = 32;
     31 		constexpr int labelHeight = 24;
     32 		constexpr int linkHeight = 20;
     33 		constexpr int margin = 10;
     34 		constexpr int width = 300;
     35 		constexpr int height = 254;
     36 		constexpr int wwiseIconHeight = 100;
     37 		const juce::String githubBaseUrl = "https://github.com/audiokinetic/";
     38 		const juce::String releaseNoteUrlPart = "/releases/tag/";
     39 		const juce::String licenseUrlPart = "/blob/main/License.txt";
     40 		const juce::String documentationUrl = "https://www.audiokinetic.com/library/reawwise";
     41 	} // namespace AboutComponentConstants
     42 
     43 	AboutComponent::AboutComponent(const juce::String& applicationName)
     44 		: copyRightSymbol(juce::CharPointer_UTF8("\xa9"))
     45 		, wwiseIcon(juce::Drawable::createFromImageData(BinaryData::wwise_icon_svg, BinaryData::wwise_icon_svgSize))
     46 		, tooltipWindow(this)
     47 
     48 	{
     49 		using namespace AboutComponentConstants;
     50 
     51 		setSize(width, height);
     52 		setLookAndFeel(&lookAndFeel);
     53 
     54 		titleLabel.setFont(titleHeight);
     55 		titleLabel.setText("ReaWwise", juce::dontSendNotification);
     56 		titleLabel.setJustificationType(juce::Justification::centred);
     57 
     58 		versionLabel.setText("Version " + juce::String(JUCE_APPLICATION_VERSION_STRING) + " " + juce::String(COMMIT_HASH), juce::dontSendNotification);
     59 		versionLabel.setEnabled(false);
     60 		versionLabel.setJustificationType(juce::Justification::centred);
     61 
     62 		copyrightLabel.setText(juce::String(juce::CharPointer_UTF8("\xc2\xa9")) + " " + juce::String(YEAR) + " Audiokinetic Inc.", juce::dontSendNotification);
     63 		copyrightLabel.setJustificationType(juce::Justification::centred);
     64 
     65 		documentationLink.setButtonText("Documentation");
     66 		documentationLink.setAlpha(0.5f);
     67 		documentationLink.setURL(documentationUrl);
     68 		documentationLink.setJustificationType(juce::Justification::centred);
     69 
     70 		releaseNotesLink.setButtonText("Release Notes");
     71 		releaseNotesLink.setAlpha(0.5f);
     72 		releaseNotesLink.setURL(githubBaseUrl + applicationName + releaseNoteUrlPart + JUCE_APPLICATION_VERSION_STRING);
     73 		releaseNotesLink.setJustificationType(juce::Justification::centred);
     74 
     75 		licensingLink.setButtonText("License Info");
     76 		licensingLink.setAlpha(0.5f);
     77 		licensingLink.setURL(githubBaseUrl + applicationName + licenseUrlPart);
     78 		licensingLink.setJustificationType(juce::Justification::centred);
     79 
     80 		addAndMakeVisible(titleLabel);
     81 		addAndMakeVisible(versionLabel);
     82 		addAndMakeVisible(copyrightLabel);
     83 		addAndMakeVisible(documentationLink);
     84 		addAndMakeVisible(releaseNotesLink);
     85 		addAndMakeVisible(licensingLink);
     86 		addAndMakeVisible(*wwiseIcon);
     87 
     88 		versionLabel.setTooltip("Wwise SDK: " + juce::String(AK_WWISE_VST_VERSION_FULL) + juce::newLine +
     89 								"Branch: " + juce::String(BRANCH_NAME) + juce::newLine +
     90 								"Build: " + juce::String(BUILD_NUMBER));
     91 	}
     92 
     93 	AboutComponent::~AboutComponent()
     94 	{
     95 		setLookAndFeel(nullptr);
     96 	}
     97 
     98 	void AboutComponent::resized()
     99 	{
    100 		using namespace AboutComponentConstants;
    101 
    102 		auto area = getLocalBounds();
    103 		area.reduce(margin, margin);
    104 
    105 		titleLabel.setBounds(area.removeFromTop(titleHeight));
    106 		versionLabel.setBounds(area.removeFromTop(labelHeight));
    107 
    108 		area.removeFromTop(margin);
    109 
    110 		wwiseIcon->setTransformToFit(area.removeFromTop(wwiseIconHeight).toFloat(), juce::RectanglePlacement::centred);
    111 
    112 		area.removeFromTop(margin);
    113 
    114 		copyrightLabel.setBounds(area.removeFromTop(labelHeight));
    115 
    116 		area.removeFromTop(margin);
    117 
    118 		juce::FlexBox fb;
    119 		fb.flexDirection = juce::FlexBox::Direction::row;
    120 
    121 		fb.items.add(juce::FlexItem(documentationLink).withHeight(linkHeight).withFlex(1));
    122 		fb.items.add(juce::FlexItem(releaseNotesLink).withHeight(linkHeight).withFlex(1));
    123 		fb.items.add(juce::FlexItem(licensingLink).withHeight(linkHeight).withFlex(1));
    124 
    125 		fb.performLayout(area.removeFromTop(linkHeight));
    126 	}
    127 
    128 	void AboutComponent::paint(juce::Graphics& g)
    129 	{
    130 		g.fillAll(getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId));
    131 	}
    132 } // namespace AK::WwiseTransfer