Skip to content

Commit

Permalink
WIP add crush button and slider to new center panel
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseDiazRohena committed Nov 26, 2023
1 parent 6c25f36 commit 1a9b6d4
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libs/tote_bag/juce_gui/utilities/GraphicsUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ 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());

Expand Down
42 changes: 41 additions & 1 deletion src/gui/panels/ValentineCenterPanel.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,66 @@
// 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 detail
{
// Get ratio of svg dimensions so we can correctly resize it.
inline constexpr auto kButtonWidth = 108.1f;
inline constexpr auto kButtonHeight = 201.84f;
inline constexpr auto kButtonRatio = kButtonWidth / kButtonHeight;

inline const juce::String kCrushSliderText = "CRUSH";
} // namespace detail

namespace tote_bag
{
namespace valentine
{
CenterPanel::CenterPanel (ValentineAudioProcessor& processor)
: crushSlider (detail::kCrushSliderText,
parameterID (VParameter::bitCrush),
processor.treeState)
, crushEnableButton (
juce::Drawable::createFromImageData (BinaryData::on_button_svg,
BinaryData::on_button_svgSize)
.get(),
juce::Drawable::createFromImageData (BinaryData::off_button_svg,
BinaryData ::off_button_svgSize)
.get(),
parameterID (VParameter::crushEnable),
processor.treeState)
{
addAndMakeVisible (crushSlider);
addAndMakeVisible (crushEnableButton);
}

CenterPanel::~CenterPanel()
{
}

void CenterPanel::paint (juce::Graphics&)
void CenterPanel::paint (juce::Graphics& g)
{
gui_utils::drawRoundedRect (g,
topRowBorderBounds.toFloat(),
laf_constants::vPinkDark);
}

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

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

auto topRowBounds = localBounds.removeFromTop (juce::roundToInt (topRowHeight));
topRowBorderBounds = topRowBounds;
topRowBounds.reduce (margin, margin);
}
} // namespace tote_bag
} // namespace valentine
11 changes: 10 additions & 1 deletion src/gui/panels/ValentineCenterPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#pragma once

#include "tote_bag/juce_gui/components/widgets/DrawableParameterButton.h"
#include "tote_bag/juce_gui/components/widgets/LabelSlider.h"

#include <juce_gui_basics/juce_gui_basics.h>

class ValentineAudioProcessor;
Expand All @@ -16,10 +19,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:
LabelSlider crushSlider;
DrawableParameterButton crushEnableButton;

juce::Rectangle<int> testTopRow;
juce::Rectangle<int> topRowBorderBounds;

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 1a9b6d4

Please sign in to comment.