Skip to content

Commit

Permalink
SQUASHME: move info text drawing to function
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseDiazRohena committed Apr 14, 2024
1 parent 643d763 commit d531673
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 36 deletions.
75 changes: 39 additions & 36 deletions libs/tote_bag/juce_gui/components/panels/InfoPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,49 @@ InfoPanel::~InfoPanel()

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

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

drawWatermark (g);
drawInfoText (g);
}

void InfoPanel::mouseUp (const juce::MouseEvent& e)
{
if (urlBounds.contains (e.getPosition()))
{
githubURL.launchInDefaultBrowser();
}
else
{
onMouseUp();
}
}

void InfoPanel::drawWatermark (juce::Graphics& g)
{
const auto bounds = getLocalBounds();
const auto boundsWidth = bounds.getWidth();
const auto boundsHeight = bounds.getHeight();

const auto totieX = bounds.getX() + (boundsWidth * .28f);
const auto totieY = bounds.getY() - (boundsHeight * .08f);
const auto totieHeight = boundsHeight * 1.22f;
const auto totieBounds =
bounds.withX (totieX)
.withY (totieY)
.withHeight (totieHeight)
.withWidth (totieHeight * detail::kTotieWidthHeightRatio);

totieWatermark->drawWithin (g,
totieBounds.toFloat(),
juce::RectanglePlacement::stretchToFit,
1.0f);
}

void InfoPanel::drawInfoText (juce::Graphics& g)
{
const auto bounds = getLocalBounds();
const auto boundsWidth = bounds.getWidth();
const auto boundsHeight = bounds.getHeight();

Expand Down Expand Up @@ -82,37 +118,4 @@ void InfoPanel::paint (juce::Graphics& g)
urlBounds = placeText ("Github");
}

void InfoPanel::mouseUp (const juce::MouseEvent& e)
{
if (urlBounds.contains (e.getPosition()))
{
githubURL.launchInDefaultBrowser();
}
else
{
onMouseUp();
}
}

void InfoPanel::drawWatermark (juce::Graphics& g)
{
const auto bounds = getLocalBounds();
const auto boundsWidth = bounds.getWidth();
const auto boundsHeight = bounds.getHeight();

const auto totieX = bounds.getX() + (boundsWidth * .28f);
const auto totieY = bounds.getY() - (boundsHeight * .08f);
const auto totieHeight = boundsHeight * 1.22f;
const auto totieBounds =
bounds.withX (totieX)
.withY (totieY)
.withHeight (totieHeight)
.withWidth (totieHeight * detail::kTotieWidthHeightRatio);

totieWatermark->drawWithin (g,
totieBounds.toFloat(),
juce::RectanglePlacement::stretchToFit,
1.0f);
}

} // namespace tote_bag
1 change: 1 addition & 0 deletions libs/tote_bag/juce_gui/components/panels/InfoPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class InfoPanel : public juce::Component

private:
void drawWatermark (juce::Graphics& g);
void drawInfoText (juce::Graphics& g);

std::function<void()> onMouseUp;

Expand Down

0 comments on commit d531673

Please sign in to comment.