From f12f0c9f91558e8a25d5e9e3bc5efa9331b43dd6 Mon Sep 17 00:00:00 2001 From: Jose Diaz Rohena Date: Mon, 1 Apr 2024 22:43:21 +0200 Subject: [PATCH] Add github url to Valentine Info rewording to make sure I can push --- .../juce_gui/components/panels/InfoPanel.cpp | 25 ++++++++++++++----- .../juce_gui/components/panels/InfoPanel.h | 3 +++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/libs/tote_bag/juce_gui/components/panels/InfoPanel.cpp b/libs/tote_bag/juce_gui/components/panels/InfoPanel.cpp index 3b075846..1d4732d9 100644 --- a/libs/tote_bag/juce_gui/components/panels/InfoPanel.cpp +++ b/libs/tote_bag/juce_gui/components/panels/InfoPanel.cpp @@ -11,6 +11,7 @@ namespace tote_bag InfoPanel::InfoPanel (std::function mouseUpCallback) : onMouseUp (mouseUpCallback) + , githubURL ("https://github.com/tote-bag-labs/valentine") { } @@ -32,28 +33,40 @@ void InfoPanel::paint (juce::Graphics& g) juce::roundToInt (boundsHeight / 4.0f)); const auto textAreaHeight = textArea.getHeight(); - const auto textHeight = juce::roundToInt (textAreaHeight / 8.0f); + const auto textHeight = juce::roundToInt (textAreaHeight / 16.0f); const auto textMargin = juce::roundToInt (textAreaHeight / 64.0f); g.setColour (colours::plainBlack); const auto placeText = [&] (const juce::String& text) { - g.drawFittedText (text, - textArea.removeFromTop (textHeight), - juce::Justification::centredBottom, - 1); + const auto bounds = textArea.removeFromTop (textHeight); + + g.drawFittedText (text, bounds, juce::Justification::centredBottom, 1); + textArea.removeFromTop (textMargin); + + return bounds; }; placeText ("Valentine"); placeText ("Tote Bag Labs"); placeText (CURRENT_VERSION); placeText (juce::String ("Build: " + juce::String (BUILD_ID))); + + g.setColour (colours::valentinePink); + urlBounds = placeText ("Github"); } void InfoPanel::mouseUp (const juce::MouseEvent& e) { - onMouseUp(); + if (urlBounds.contains (e.getPosition())) + { + githubURL.launchInDefaultBrowser(); + } + else + { + onMouseUp(); + } } } // namespace tote_bag \ No newline at end of file diff --git a/libs/tote_bag/juce_gui/components/panels/InfoPanel.h b/libs/tote_bag/juce_gui/components/panels/InfoPanel.h index f537c358..e3e289b0 100644 --- a/libs/tote_bag/juce_gui/components/panels/InfoPanel.h +++ b/libs/tote_bag/juce_gui/components/panels/InfoPanel.h @@ -23,6 +23,9 @@ class InfoPanel : public juce::Component private: std::function onMouseUp; + juce::Rectangle urlBounds; + juce::URL githubURL; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InfoPanel) };