generated from sudara/pamplejuce
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Place components in new center panel
- Loading branch information
1 parent
395fad7
commit 452719c
Showing
13 changed files
with
284 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
libs/tote_bag/juce_gui/components/widgets/tbl_ToggleButton.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// 2023 Tote Bag Labs | ||
|
||
#include "tbl_ToggleButton.h" | ||
|
||
namespace tote_bag | ||
{ | ||
ToggleButton::ToggleButton (const juce::String& parameterId, | ||
juce::AudioProcessorValueTreeState& stateToControl) | ||
: juce::ToggleButton (parameterId) | ||
, buttonValue (stateToControl, parameterId, *this) | ||
{ | ||
setClickingTogglesState (true); | ||
} | ||
} // namespace tote_bag |
28 changes: 28 additions & 0 deletions
28
libs/tote_bag/juce_gui/components/widgets/tbl_ToggleButton.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
// 2023 Tote Bag Labs | ||
|
||
#pragma once | ||
|
||
#include <juce_audio_processors/juce_audio_processors.h> | ||
#include <juce_gui_basics/juce_gui_basics.h> | ||
|
||
namespace tote_bag | ||
{ | ||
class ToggleButton : public juce::ToggleButton | ||
{ | ||
public: | ||
ToggleButton (const juce::String& parameterId, | ||
juce::AudioProcessorValueTreeState& stateToControl); | ||
|
||
enum ColourIds | ||
{ | ||
backgroundColourId = 0x1006504, | ||
highightColourId = 0x1006505, | ||
}; | ||
|
||
private: | ||
juce::AudioProcessorValueTreeState::ButtonAttachment buttonValue; | ||
|
||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToggleButton) | ||
}; | ||
} // namespace tote_bag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,191 @@ | ||
// 2023 Tote Bag Labs | ||
|
||
#include "ValentineCenterPanel.h" | ||
#include "BinaryData.h" | ||
#include "PluginProcessor.h" | ||
|
||
#include "ValentineParameters.h" | ||
#include "tote_bag/juce_gui/lookandfeel/LookAndFeelConstants.h" | ||
#include "tote_bag/juce_gui/utilities/GraphicsUtilities.h" | ||
|
||
namespace tote_bag | ||
{ | ||
namespace valentine | ||
{ | ||
namespace detail | ||
{ | ||
inline const juce::String kCrushSliderText = "CRUSH"; | ||
inline const juce::String kCompressSliderText = "COMPRESS"; | ||
inline const juce::String kSaturateSliderText = "SATURATE"; | ||
inline const juce::String kRatioSliderText = "RATIO"; | ||
inline const juce::String kAttackSliderText = "ATTACK"; | ||
inline const juce::String kReleaseSliderText = "RELEASE"; | ||
inline const juce::String kOutputSliderText = "OUTPUT"; | ||
inline const juce::String kMixSliderText = "MIX"; | ||
} // namespace detail | ||
|
||
CenterPanel::CenterPanel (ValentineAudioProcessor& processor) | ||
: borderLineThickness (0.0f) | ||
, borderCornerSize (0.0f) | ||
, crushEnableButton (parameterID (VParameter::crushEnable), processor.treeState) | ||
, crushSlider (detail::kCrushSliderText, | ||
parameterID (VParameter::bitCrush), | ||
processor.treeState) | ||
, compressSlider (detail::kCompressSliderText, | ||
parameterID (VParameter::inputGain), | ||
processor.treeState) | ||
, saturateEnableButton (parameterID (VParameter::saturateEnable), processor.treeState) | ||
, saturateSlider (detail::kSaturateSliderText, | ||
parameterID (VParameter::saturation), | ||
processor.treeState) | ||
, valentineLogo ( | ||
juce::Drawable::createFromImageData (BinaryData::logo_218x40_svg, | ||
BinaryData::logo_218x40_svgSize)) | ||
, ratioSlider (detail::kRatioSliderText, | ||
parameterID (VParameter::ratio), | ||
processor.treeState) | ||
, attackSlider (detail::kAttackSliderText, | ||
parameterID (VParameter::attack), | ||
processor.treeState) | ||
, releaseSlider (detail::kReleaseSliderText, | ||
parameterID (VParameter::release), | ||
processor.treeState) | ||
, clipEnableButton (parameterID (VParameter::outputClipEnable), processor.treeState) | ||
, outputSlider (detail::kOutputSliderText, | ||
parameterID (VParameter::makeupGain), | ||
processor.treeState) | ||
, mixSlider (detail::kMixSliderText, | ||
parameterID (VParameter::dryWet), | ||
processor.treeState) | ||
{ | ||
addAndMakeVisible (crushEnableButton); | ||
addAndMakeVisible (crushSlider); | ||
addAndMakeVisible (compressSlider); | ||
addAndMakeVisible (saturateEnableButton); | ||
addAndMakeVisible (saturateSlider); | ||
addAndMakeVisible (valentineLogo.get()); | ||
addAndMakeVisible (ratioSlider); | ||
addAndMakeVisible (attackSlider); | ||
addAndMakeVisible (releaseSlider); | ||
addAndMakeVisible (clipEnableButton); | ||
addAndMakeVisible (outputSlider); | ||
addAndMakeVisible (mixSlider); | ||
} | ||
|
||
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; | ||
|
||
topRowBorder = | ||
localBounds.removeFromTop (juce::roundToInt (topRowHeight)).reduced (margin); | ||
auto topRowComponents = topRowBorder.reduced (margin); | ||
|
||
auto topRowSliders = topRowComponents.removeFromLeft ( | ||
juce::roundToInt (topRowComponents.getWidth() * .65f)); | ||
const auto topRowButtonWidth = juce::roundToInt (topRowSliders.getWidth() * .033f); | ||
const auto adjustedTopRowComponentsWidth = | ||
topRowSliders.getWidth() - (topRowButtonWidth * 2.0f); | ||
const auto topRowSliderWidth = | ||
juce::roundToInt (adjustedTopRowComponentsWidth / 3.0f); | ||
|
||
const auto topRowButtonSpacer = | ||
juce::roundToInt ((topRowSliders.getHeight() - topRowButtonWidth) * .5f); | ||
const auto topRowButtonNudge = topRowButtonWidth / 2.2f; | ||
const auto initialCrushButtonX = topRowSliders.getX(); | ||
const auto crushEnableButtonBounds = | ||
topRowSliders.removeFromLeft (topRowButtonWidth) | ||
.reduced (0, topRowButtonSpacer) | ||
.withX (initialCrushButtonX + topRowButtonNudge); | ||
|
||
crushEnableButton.setBounds (crushEnableButtonBounds); | ||
crushSlider.setBounds (topRowSliders.removeFromLeft (topRowSliderWidth)); | ||
compressSlider.setBounds (topRowSliders.removeFromLeft (topRowSliderWidth)); | ||
|
||
const auto initialSaturateButtonX = topRowSliders.getX(); | ||
const auto saturateEnableButtonBounds = | ||
topRowSliders.removeFromLeft (topRowButtonWidth) | ||
.reduced (0, topRowButtonSpacer) | ||
.withX (initialSaturateButtonX + topRowButtonNudge); | ||
|
||
saturateEnableButton.setBounds (saturateEnableButtonBounds); | ||
saturateSlider.setBounds (topRowSliders.removeFromLeft (topRowSliderWidth)); | ||
|
||
const auto logoHeight = juce::roundToInt (topRowComponents.getHeight() * .25f); | ||
topRowComponents.removeFromTop (logoHeight * 1.45f); | ||
topRowComponents.removeFromRight (logoHeight * .5f); | ||
const auto valentineLogoBounds = topRowComponents.removeFromTop (logoHeight); | ||
|
||
valentineLogo->setTransformToFit ( | ||
valentineLogoBounds.toFloat(), | ||
juce::RectanglePlacement (juce::RectanglePlacement::centred | ||
| juce::RectanglePlacement::fillDestination)); | ||
|
||
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(); | ||
|
||
auto bottomRowComponents = bottomRowBorder.reduced (margin); | ||
|
||
const auto bottomRowButtonWidth = | ||
juce::roundToInt (bottomRowComponents.getWidth() / 60.0f); | ||
const auto adjustedBottomRowComponentsWidth = | ||
bottomRowComponents.getWidth() - bottomRowButtonWidth; | ||
const auto bottomRowSliderWidth = | ||
juce::roundToInt (adjustedBottomRowComponentsWidth / 6.0f); | ||
|
||
ratioSlider.setBounds (bottomRowComponents.removeFromLeft (bottomRowSliderWidth)); | ||
attackSlider.setBounds (bottomRowComponents.removeFromLeft (bottomRowSliderWidth)); | ||
releaseSlider.setBounds (bottomRowComponents.removeFromLeft (bottomRowSliderWidth)); | ||
|
||
const auto dividerBounds = bottomRowComponents.removeFromLeft (bottomRowSliderWidth); | ||
|
||
bottomRowDivider = | ||
juce::Rectangle<int> (juce::roundToInt (dividerBounds.getCentreX()), | ||
dividerBounds.getY(), | ||
juce::roundToInt (borderLineThickness), | ||
dividerBounds.getHeight()); | ||
|
||
const auto bottomRowButtonSpacer = | ||
juce::roundToInt ((bottomRowComponents.getHeight() - bottomRowButtonWidth) * .5f); | ||
const auto bottomRowButtonNudge = bottomRowButtonWidth / 1.25f; | ||
const auto clipButtonInitialX = bottomRowComponents.getX(); | ||
const auto clipButtonBounds = | ||
bottomRowComponents.removeFromLeft (bottomRowButtonWidth) | ||
.reduced (0, bottomRowButtonSpacer) | ||
.withX (clipButtonInitialX + bottomRowButtonNudge); | ||
|
||
clipEnableButton.setBounds (clipButtonBounds); | ||
outputSlider.setBounds (bottomRowComponents.removeFromLeft (bottomRowSliderWidth)); | ||
mixSlider.setBounds (bottomRowComponents.removeFromLeft (bottomRowSliderWidth)); | ||
} | ||
} // namespace tote_bag | ||
} // namespace valentine |
Oops, something went wrong.