Skip to content

Commit

Permalink
Draw borders and dividers
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseDiazRohena committed Dec 3, 2023
1 parent 6c25f36 commit 8ac0f34
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 9 deletions.
3 changes: 1 addition & 2 deletions libs/tote_bag/juce_gui/utilities/GraphicsUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ void drawRoundedRect (juce::Graphics& g,

auto h = croppedBounds.getHeight();
auto lineThickness = h * .025f;
auto cornerSize = h * .25f;
auto cornerSize = h * .075f;

g.setColour (colour.darker());

g.drawRoundedRectangle (croppedBounds, cornerSize, lineThickness);

g.setColour (colour);

juce::Path p;
p.addRoundedRectangle (croppedBounds, cornerSize);
g.fillPath (p);
Expand Down
44 changes: 43 additions & 1 deletion src/gui/panels/ValentineCenterPanel.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,68 @@
// 2023 Tote Bag Labs

#include "ValentineCenterPanel.h"
#include "BinaryData.h"
#include "PluginProcessor.h"

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

namespace tote_bag
{
namespace valentine
{
CenterPanel::CenterPanel (ValentineAudioProcessor& processor)
: borderLineThickness (0.0f)
, borderCornerSize (0.0f)
{
}

CenterPanel::~CenterPanel()
{
}

void CenterPanel::paint (juce::Graphics&)
void CenterPanel::paint (juce::Graphics& g)
{
g.setColour (juce::Colours::black);

g.drawRoundedRectangle (topRowBorder.toFloat(),
borderCornerSize,
borderLineThickness);

g.drawRoundedRectangle (bottomRowBorder.toFloat(),
borderCornerSize,
borderLineThickness);

g.fillRect (bottomRowDivider);
}

void CenterPanel::resized()
{
auto localBounds = getLocalBounds();
const auto margin = juce::roundToInt (localBounds.getHeight() * .025f);

const auto topRowHeight = localBounds.getHeight() * .55f;
const auto topRowWidth = localBounds.getWidth();

auto topRowBounds = localBounds.removeFromTop (juce::roundToInt (topRowHeight));
topRowBorder = topRowBounds.reduced (margin);

const auto topRowBorderHeight = topRowBorder.getHeight();
borderLineThickness = topRowBorderHeight * .01f;
borderCornerSize = topRowBorderHeight * .060f;

localBounds.removeFromTop (margin);
bottomRowBorder = localBounds.reduced (margin);

const auto bottomRowBorderWidth = bottomRowBorder.getWidth();
const auto bottomRowBorderY = bottomRowBorder.getY();
const auto bottomRowBorderHeight = bottomRowBorder.getHeight();
bottomRowDivider =
juce::Rectangle<int> (juce::roundToInt (bottomRowBorderWidth * .6f),
bottomRowBorderY,
juce::roundToInt (borderLineThickness),
bottomRowBorderHeight)
.reduced (0, bottomRowBorderHeight * .1f);
}
} // namespace tote_bag
} // namespace valentine
8 changes: 7 additions & 1 deletion src/gui/panels/ValentineCenterPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ class CenterPanel : public juce::Component
CenterPanel (ValentineAudioProcessor& processor);
~CenterPanel() override;

void paint (juce::Graphics&) override;
void paint (juce::Graphics& g) override;
void resized() override;

private:
juce::Rectangle<int> topRowBorder;
juce::Rectangle<int> bottomRowBorder;
juce::Rectangle<int> bottomRowDivider;
float borderLineThickness;
float borderCornerSize;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CenterPanel)
};
} // namespace valentine
Expand Down
11 changes: 6 additions & 5 deletions src/gui/panels/ValentineMainPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ VMainPanel::VMainPanel (ValentineAudioProcessor& processor)
FFCompParameterLabel()[getParameterIndex (VParameter::bypass)],
FFCompParameterID()[getParameterIndex (VParameter::bypass)],
processor.treeState)
, inputMeterPanel (ReductionMeterPlacement::Right,
&processor.getInputMeterSource())
, inputMeterPanel (ReductionMeterPlacement::Right, &processor.getInputMeterSource())
, outputMeterPanel (ReductionMeterPlacement::Left,
&processor.getOutputMeterSource(),
&processor.getGrMeterSource())
, centerPanel (processor)
, newCenterPanel (processor)
{
addAndMakeVisible (presetPanel);
addAndMakeVisible (centerPanel);
addAndMakeVisible (newCenterPanel);
addAndMakeVisible (inputMeterPanel);
addAndMakeVisible (outputMeterPanel);

Expand All @@ -48,7 +48,8 @@ void VMainPanel::resized()
{
auto panelBounds = getLocalBounds();

const auto presetBounds = panelBounds.removeFromTop (juce::roundToInt (panelBounds.getHeight() * .075f));
const auto presetBounds =
panelBounds.removeFromTop (juce::roundToInt (panelBounds.getHeight() * .075f));
presetPanel.setBounds (presetBounds);

const auto resizerMargin = juce::roundToInt (panelBounds.getHeight() * .03f);
Expand All @@ -66,5 +67,5 @@ void VMainPanel::resized()

inputMeterPanel.setBounds (inMeterBounds);
outputMeterPanel.setBounds (outMeterBounds);
centerPanel.setBounds (panelBounds);
newCenterPanel.setBounds (panelBounds);
}
1 change: 1 addition & 0 deletions src/gui/panels/ValentineMainPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ class VMainPanel : public juce::Component
VerticalMeterPanel inputMeterPanel;
VerticalMeterPanel outputMeterPanel;
CenterPanel centerPanel;
tote_bag::valentine::CenterPanel newCenterPanel;
};

0 comments on commit 8ac0f34

Please sign in to comment.