Skip to content

Commit

Permalink
Draw frames for top and bottom row
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseDiazRohena committed Nov 27, 2023
1 parent 6c25f36 commit cc21df2
Show file tree
Hide file tree
Showing 5 changed files with 43 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
32 changes: 31 additions & 1 deletion src/gui/panels/ValentineCenterPanel.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// 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
Expand All @@ -15,12 +19,38 @@ CenterPanel::~CenterPanel()
{
}

void CenterPanel::paint (juce::Graphics&)
void CenterPanel::paint (juce::Graphics& g)
{
// These are used for drawing both bottom and top
// rows.
const auto h = topRowBorderBounds.getHeight();
const auto lineThickness = h * .01f;
const auto cornerSize = h * .060f;
const auto margin = juce::roundToInt (topRowBorderBounds.getHeight() * .025f);

// Draw outline for top row
const auto croppedTopRow = topRowBorderBounds.reduced (margin);
g.setColour (juce::Colours::black);
g.drawRoundedRectangle (croppedTopRow.toFloat(), cornerSize, lineThickness);

// Draw outline for bottom row
const auto croppedBottomRow = bottomRowBorderBounds.reduced (margin);
g.drawRoundedRectangle (croppedBottomRow.toFloat(), cornerSize, lineThickness);
}

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

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

auto topRowBounds = localBounds.removeFromTop (juce::roundToInt (topRowHeight));
topRowBorderBounds = topRowBounds;

localBounds.removeFromTop (margin);
bottomRowBorderBounds = localBounds;
}
} // namespace tote_bag
} // namespace valentine
5 changes: 4 additions & 1 deletion src/gui/panels/ValentineCenterPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ 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> topRowBorderBounds;
juce::Rectangle<int> bottomRowBorderBounds;

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 cc21df2

Please sign in to comment.