Skip to content

Commit

Permalink
Add github url to Valentine Info
Browse files Browse the repository at this point in the history
rewording to make sure I can push
  • Loading branch information
JoseDiazRohena committed Apr 6, 2024
1 parent 9da0896 commit f12f0c9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
25 changes: 19 additions & 6 deletions libs/tote_bag/juce_gui/components/panels/InfoPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace tote_bag

InfoPanel::InfoPanel (std::function<void()> mouseUpCallback)
: onMouseUp (mouseUpCallback)
, githubURL ("https://github.com/tote-bag-labs/valentine")
{
}

Expand All @@ -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
3 changes: 3 additions & 0 deletions libs/tote_bag/juce_gui/components/panels/InfoPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class InfoPanel : public juce::Component
private:
std::function<void()> onMouseUp;

juce::Rectangle<int> urlBounds;
juce::URL githubURL;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InfoPanel)
};

Expand Down

0 comments on commit f12f0c9

Please sign in to comment.