Skip to content

Commit

Permalink
Add text for info view
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 49e2773 commit dabf038
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
46 changes: 44 additions & 2 deletions libs/tote_bag/juce_gui/components/panels/InfoPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

#include "InfoPanel.h"

#include "generated/version.h"

#include "tote_bag/juce_gui/lookandfeel/LookAndFeelConstants.h"

namespace tote_bag
{

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

Expand All @@ -18,13 +21,52 @@ InfoPanel::~InfoPanel()

void InfoPanel::paint (juce::Graphics& g)
{
const auto bounds = getLocalBounds();

g.setColour (colours::plainWhite);
g.fillRect (getLocalBounds());
g.fillRect (bounds);

const auto boundsWidth = bounds.getWidth();
const auto boundsHeight = bounds.getHeight();

auto textArea = bounds.reduced (juce::roundToInt (boundsWidth / 4.0f),
juce::roundToInt (boundsHeight / 4.0f));

const auto textAreaHeight = textArea.getHeight();
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) {
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 dabf038

Please sign in to comment.