diff --git a/Source/Components/PropertiesPanel.h b/Source/Components/PropertiesPanel.h index b4460ed17..61af85db2 100644 --- a/Source/Components/PropertiesPanel.h +++ b/Source/Components/PropertiesPanel.h @@ -111,7 +111,7 @@ class PropertiesPanel : public Component { auto titleX = x; if (parent.titleAlignment == AlignWithPropertyName) { - titleX += 12; + titleX += 11; } auto title = getName(); @@ -542,18 +542,16 @@ class PropertiesPanel : public Component { void paint(Graphics& g) override { bool isDown = getValue(toggleStateValue); - bool isHovered = isMouseOver(); auto bounds = getLocalBounds().toFloat().removeFromRight(getWidth() / (2.0f - hideLabel)); - - if (isDown || isHovered) { - Path p; - p.addRoundedRectangle(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), Corners::largeCornerRadius, Corners::largeCornerRadius, false, roundTopCorner, false, roundBottomCorner); - - // Add some alpha to make it look good on any background... - g.setColour(findColour(TextButton::buttonColourId).withAlpha(isDown ? 0.9f : 0.7f)); - g.fillPath(p); - } + auto buttonBounds = bounds.reduced(4); + + auto contrast = isDown ? 0.3f : 0.0f; + if(isMouseOver()) contrast += 0.05; + + // Add some alpha to make it look good on any background... + g.setColour(findColour(PlugDataColour::sidebarActiveBackgroundColourId).contrasting(contrast).withAlpha(0.3f)); + g.fillRoundedRectangle(buttonBounds, Corners::defaultCornerRadius); auto textColour = findColour(PlugDataColour::panelTextColourId); @@ -592,42 +590,7 @@ class PropertiesPanel : public Component { StringArray textOptions; Value toggleStateValue; }; - - struct InspectorBoolComponent : public BoolComponent - { - using BoolComponent::BoolComponent; - - void paint(Graphics& g) override - { - bool isDown = getValue(toggleStateValue); - auto bounds = getLocalBounds().toFloat().removeFromRight(getWidth() / (2.0f - hideLabel)); - auto buttonBounds = bounds.reduced(4); - - auto contrast = isDown ? 0.2f : 0.05f; - if(isMouseOver()) contrast += 0.025; - // Add some alpha to make it look good on any background... - g.setColour(findColour(PlugDataColour::sidebarActiveBackgroundColourId).contrasting(contrast).withAlpha(0.3f)); - g.fillRoundedRectangle(buttonBounds, Corners::defaultCornerRadius); - - auto textColour = findColour(PlugDataColour::panelTextColourId); - - if (!isEnabled()) { - textColour = findColour(PlugDataColour::panelTextColourId).withAlpha(0.5f); - } - Fonts::drawText(g, textOptions[isDown], bounds, textColour, 14.0f, Justification::centred); - - // Paint label - PropertiesPanelProperty::paint(g); - } - - PropertiesPanelProperty* createCopy() override - { - return new InspectorBoolComponent(getName(), toggleStateValue, textOptions); - } - - }; - struct InspectorColourComponent : public PropertiesPanelProperty , public Value::Listener { diff --git a/Source/Dialogs/AudioSettingsPanel.h b/Source/Dialogs/AudioSettingsPanel.h index 9a7cb5d9f..0132bfdf9 100644 --- a/Source/Dialogs/AudioSettingsPanel.h +++ b/Source/Dialogs/AudioSettingsPanel.h @@ -118,7 +118,7 @@ class ChannelToggleProperty : public PropertiesPanel::BoolComponent { : PropertiesPanel::BoolComponent(channelName, isEnabled, { "Disabled", "Enabled" }) , callback(std::move(onClick)) { - setPreferredHeight(28); + setPreferredHeight(30); repaint(); } @@ -132,26 +132,23 @@ class ChannelToggleProperty : public PropertiesPanel::BoolComponent { void paint(Graphics& g) override { bool isDown = getValue(toggleStateValue); - bool isHovered = isMouseOver(); - Path backgroundShape; - backgroundShape.addRoundedRectangle(0, 0, getWidth(), getHeight(), Corners::largeCornerRadius, Corners::largeCornerRadius, roundTopCorner, roundTopCorner, roundBottomCorner, roundBottomCorner); - - g.setColour(findColour(PlugDataColour::panelForegroundColourId).darker(0.015f)); - g.fillPath(backgroundShape); - - auto buttonBounds = getLocalBounds().toFloat().removeFromRight(getWidth() / (2.0f - hideLabel)); + auto bounds = getLocalBounds().toFloat().removeFromRight(getWidth() / (2.0f - hideLabel)); + auto buttonBounds = bounds.reduced(4); + + auto contrast = isDown ? 0.3f : 0.0f; + if(isMouseOver()) contrast += 0.05; + + // Add some alpha to make it look good on any background... + g.setColour(findColour(PlugDataColour::sidebarActiveBackgroundColourId).contrasting(contrast).withAlpha(0.3f)); + g.fillRoundedRectangle(buttonBounds, Corners::defaultCornerRadius); - Path buttonShape; - buttonShape.addRoundedRectangle(buttonBounds.getX(), buttonBounds.getY(), buttonBounds.getWidth(), buttonBounds.getHeight(), Corners::largeCornerRadius, Corners::largeCornerRadius, false, roundTopCorner, false, roundBottomCorner); + auto textColour = findColour(PlugDataColour::panelTextColourId); - if (isDown || isHovered) { - // Add some alpha to make it look good on any background... - g.setColour(findColour(TextButton::buttonColourId).withAlpha(isDown ? 0.9f : 0.7f)); - g.fillPath(buttonShape); + if (!isEnabled()) { + textColour = findColour(PlugDataColour::panelTextColourId).withAlpha(0.5f); } - - Fonts::drawText(g, textOptions[isDown], buttonBounds, findColour(PlugDataColour::panelTextColourId), 14.0f, Justification::centred); + Fonts::drawText(g, textOptions[isDown], bounds, textColour, 14.0f, Justification::centred); // Paint label PropertiesPanelProperty::paint(g); diff --git a/Source/LookAndFeel.cpp b/Source/LookAndFeel.cpp index 6d1b9bed1..784533a2c 100644 --- a/Source/LookAndFeel.cpp +++ b/Source/LookAndFeel.cpp @@ -838,7 +838,7 @@ void PlugDataLook::drawPropertyComponentLabel(Graphics& g, int width, int height auto textW = jmin(300, component.getWidth() / 2); auto r = Rectangle(textW, 0, component.getWidth() - textW, component.getHeight() - 1); - Fonts::drawFittedText(g, component.getName(), indent + 2, r.getY(), r.getX(), r.getHeight(), colour, 1, 1.0f, (float)jmin(height, 24) * 0.65f, Justification::centredLeft); + Fonts::drawFittedText(g, component.getName(), indent + 1, r.getY(), r.getX(), r.getHeight(), colour, 1, 1.0f, (float)jmin(height, 24) * 0.65f, Justification::centredLeft); } void PlugDataLook::drawPropertyPanelSectionHeader(Graphics& g, String const& name, bool isOpen, int width, int height) diff --git a/Source/Objects/ArrayObject.h b/Source/Objects/ArrayObject.h index 3546c920e..756c96306 100644 --- a/Source/Objects/ArrayObject.h +++ b/Source/Objects/ArrayObject.h @@ -735,7 +735,7 @@ struct ArrayPropertiesPanel : public PropertiesPanelProperty addAndMakeVisible(properties.add(new PropertiesPanel::EditableComponent("Name", graph->name))); addAndMakeVisible(properties.add(new PropertiesPanel::EditableComponent("Size", graph->size))); addAndMakeVisible(properties.add(new PropertiesPanel::RangeComponent("Range", graph->range, false))); - addAndMakeVisible(properties.add(new PropertiesPanel::InspectorBoolComponent("Save contents", graph->saveContents, { "No", "Yes" }))); + addAndMakeVisible(properties.add(new PropertiesPanel::BoolComponent("Save contents", graph->saveContents, { "No", "Yes" }))); addAndMakeVisible(properties.add(new PropertiesPanel::ComboComponent("Draw Style", graph->drawMode, { "Points", "Polygon", "Bezier curve" }))); // To detect name changes, so we can redraw the array title @@ -750,7 +750,7 @@ struct ArrayPropertiesPanel : public PropertiesPanelProperty addAndMakeVisible(deleteButton); } - auto newHeight = (192 * graphs.size()) + 24; + auto newHeight = (176 * graphs.size()) + 24; setPreferredHeight(newHeight); if (auto* propertiesPanel = findParentComponentOfClass()) { propertiesPanel->updatePropHolderLayout(); @@ -776,7 +776,7 @@ struct ArrayPropertiesPanel : public PropertiesPanelProperty if (!graphs[i]) continue; - auto start = (i * 192) - 6; + auto start = (i * 176) - 6; g.setColour(findColour(PlugDataColour::sidebarActiveBackgroundColourId).withAlpha(0.75f)); g.fillRoundedRectangle(0.0f, start + 26, getWidth(), 158, Corners::largeCornerRadius); diff --git a/Source/Sidebar/Inspector.h b/Source/Sidebar/Inspector.h index fa8431d92..b8a15d57b 100644 --- a/Source/Sidebar/Inspector.h +++ b/Source/Sidebar/Inspector.h @@ -130,7 +130,7 @@ class Inspector : public Component { case tColour: return new PropertiesPanel::InspectorColourComponent(name, *value); case tBool: - return new PropertiesPanel::InspectorBoolComponent(name, *value, options); + return new PropertiesPanel::BoolComponent(name, *value, options); case tCombo: return new PropertiesPanel::ComboComponent(name, *value, options); case tRangeFloat: