Skip to content

Commit

Permalink
wip new toggle button drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseDiazRohena committed Dec 10, 2023
1 parent cce84fc commit 6a361b4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
12 changes: 12 additions & 0 deletions libs/tote_bag/juce_gui/lookandfeel/LookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,18 @@ void LookAndFeel::drawPopupMenuItem (juce::Graphics& g,
g.drawFittedText (text, r, juce::Justification::left, 1);
}

void LookAndFeel::drawToggleButton (juce::Graphics& g,
juce::ToggleButton& button,
bool shouldDrawButtonAsHighlighted,
bool shouldDrawButtonAsDown)
{
const auto bounds = button.getLocalBounds();

auto fillColour = findColour (ColourIds::knobColourId);
g.setColour (fillColour);
g.fillEllipse (bounds.toFloat());
}

juce::Slider::SliderLayout LookAndFeel::getSliderLayout (juce::Slider& slider)
{
// 1. compute the actually visible textBox size from the slider textBox size and some additional constraints
Expand Down
5 changes: 5 additions & 0 deletions libs/tote_bag/juce_gui/lookandfeel/LookAndFeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ class LookAndFeel : public juce::LookAndFeel_V4,
const juce::Drawable*,
const juce::Colour*) override;

void drawToggleButton (juce::Graphics& g,
juce::ToggleButton& button,
bool shouldDrawButtonAsHighlighted,
bool shouldDrawButtonAsDown) override;

juce::Slider::SliderLayout getSliderLayout (juce::Slider& slider) override;

enum ColourIds { knobColourId = 0x1001800, pointerColourId = 0x1001801 };
Expand Down
13 changes: 9 additions & 4 deletions src/gui/panels/ValentineCenterPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,18 @@ void CenterPanel::resized()
juce::roundToInt (topRowComponents.getWidth() * .65f));

// Get basic width for top row sliders
auto topRowSliderWidth = juce::roundToInt (topRowSliders.getHeight() * .33f);
// Use that width as reference for button width
const auto topRowButtonWidth = juce::roundToInt (topRowSliderWidth * .25f);
auto topRowSliderWidth = juce::roundToInt (topRowSliders.getWidth() * .33f);
// Use slider width as reference for button width
const auto topRowButtonWidth = juce::roundToInt (topRowSliderWidth * .5f);
// Adjust button width to make room
topRowSliderWidth -= topRowButtonWidth;

const auto crushButtonBounds = topRowSliders.removeFromLeft (topRowButtonWidth);
auto crushButtonBounds = topRowSliders.removeFromLeft (topRowButtonWidth);
auto crushButtonSpacer = juce::roundToInt (
(crushButtonBounds.getHeight() - crushButtonBounds.getWidth()) * .5f);
crushButtonBounds.removeFromTop (crushButtonSpacer);
crushButtonBounds.removeFromBottom (crushButtonSpacer);

crushEnableButton.setBounds (crushButtonBounds);

const auto logoHeight = juce::roundToInt (topRowComponents.getHeight() * .25f);
Expand Down

0 comments on commit 6a361b4

Please sign in to comment.