Skip to content

Commit

Permalink
Use fill instead of outline for generic text buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyschoen committed Oct 28, 2023
1 parent eaa326e commit a7bc078
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 19 deletions.
14 changes: 14 additions & 0 deletions Source/Dialogs/AboutPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ class AboutPanel : public Component {
credits.setLineSpacing(1.1f);
addAndMakeVisible(credits);

auto backgroundColour = findColour(PlugDataColour::dialogBackgroundColourId);
viewOnGithub.setColour(TextButton::buttonColourId, backgroundColour.contrasting(0.05f));
viewOnGithub.setColour(TextButton::buttonOnColourId, backgroundColour.contrasting(0.1f));
viewOnGithub.setColour(ComboBox::outlineColourId, Colours::transparentBlack);

reportIssue.setColour(TextButton::buttonColourId, backgroundColour.contrasting(0.05f));
reportIssue.setColour(TextButton::buttonOnColourId, backgroundColour.contrasting(0.1f));
reportIssue.setColour(ComboBox::outlineColourId, Colours::transparentBlack);

sponsor.setColour(TextButton::buttonColourId, backgroundColour.contrasting(0.05f));
sponsor.setColour(TextButton::buttonOnColourId, backgroundColour.contrasting(0.1f));
sponsor.setColour(ComboBox::outlineColourId, Colours::transparentBlack);


viewOnGithub.setButtonText("View on Github");
reportIssue.setButtonText("Report issue");
sponsor.setButtonText("Become a sponsor");
Expand Down
10 changes: 3 additions & 7 deletions Source/Dialogs/Deken.h
Original file line number Diff line number Diff line change
Expand Up @@ -815,13 +815,9 @@ class Deken : public Component
addChildComponent(uninstallButton);
addChildComponent(addToPathButton);

installButton.setColour(TextButton::buttonColourId, findColour(PlugDataColour::panelForegroundColourId));
uninstallButton.setColour(TextButton::buttonColourId, findColour(PlugDataColour::panelForegroundColourId));
addToPathButton.setColour(TextButton::buttonColourId, findColour(PlugDataColour::panelForegroundColourId));

installButton.setColour(TextButton::buttonOnColourId, findColour(PlugDataColour::panelActiveBackgroundColourId));
uninstallButton.setColour(TextButton::buttonOnColourId, findColour(PlugDataColour::panelActiveBackgroundColourId));
addToPathButton.setColour(TextButton::buttonOnColourId, findColour(PlugDataColour::panelActiveBackgroundColourId));
installButton.setColour(ComboBox::outlineColourId, Colours::transparentBlack);
uninstallButton.setColour(ComboBox::outlineColourId, Colours::transparentBlack);
addToPathButton.setColour(ComboBox::outlineColourId, Colours::transparentBlack);

installButton.setTooltip("Install package");
uninstallButton.setTooltip("Uninstall package");
Expand Down
21 changes: 16 additions & 5 deletions Source/Dialogs/Dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,25 @@ void Dialogs::showOkayCancelDialog(std::unique_ptr<Dialog>* target, Component* p
OkayCancelDialog(Dialog* dialog, String const& title, std::function<void(bool)> const& callback)
: label("", title)
{
setSize(400, 200);
setSize(375, 200);

label.setJustificationType(Justification::centred);
label.setFont(Fonts::getBoldFont().withHeight(14.0f));

addAndMakeVisible(label);
addAndMakeVisible(cancel);
addAndMakeVisible(okay);

cancel.setColour(TextButton::buttonColourId, Colours::transparentBlack);
okay.setColour(TextButton::buttonColourId, Colours::transparentBlack);


auto backgroundColour = findColour(PlugDataColour::dialogBackgroundColourId);

cancel.setColour(TextButton::buttonColourId, backgroundColour.contrasting(0.05f));
cancel.setColour(TextButton::buttonOnColourId, backgroundColour.contrasting(0.1f));
cancel.setColour(ComboBox::outlineColourId, Colours::transparentBlack);

okay.setColour(TextButton::buttonColourId, backgroundColour.contrasting(0.05f));
okay.setColour(TextButton::buttonOnColourId, backgroundColour.contrasting(0.1f));
okay.setColour(ComboBox::outlineColourId, Colours::transparentBlack);

cancel.onClick = [dialog, callback] {
callback(false);
dialog->closeDialog();
Expand Down
14 changes: 9 additions & 5 deletions Source/Dialogs/SaveDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ class SaveDialogButton : public TextButton {
auto activeColour = findColour(PlugDataColour::toolbarActiveColourId);

if (isMouseOver() || isMouseButtonDown()) {
backgroundColour = backgroundColour.contrasting(0.05f);
backgroundColour = backgroundColour.contrasting(0.1f);
}
else {
backgroundColour = backgroundColour.contrasting(0.06f);
}

g.setColour(backgroundColour);
Expand All @@ -31,10 +34,11 @@ class SaveDialogButton : public TextButton {

g.drawText(getButtonText(), getLocalBounds().reduced(3), Justification::centred);

auto outlineColour = hasKeyboardFocus(false) ? activeColour : findColour(PlugDataColour::outlineColourId);

g.setColour(outlineColour);
PlugDataLook::drawSmoothedRectangle(g, PathStrokeType(1.0f), bounds, Corners::defaultCornerRadius);
if(hasKeyboardFocus(false))
{
g.setColour(activeColour);
PlugDataLook::drawSmoothedRectangle(g, PathStrokeType(1.0f), bounds, Corners::defaultCornerRadius);
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion Source/Heavy/DaisyExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DaisyExporter : public ExporterBase {
exportButton.setVisible(false);
addAndMakeVisible(flashButton);

flashButton.setColour(TextButton::buttonColourId, findColour(PlugDataColour::panelBackgroundColourId));
flashButton.setColour(ComboBox::outlineColourId, findColour(PlugDataColour::panelBackgroundColourId));

exportTypeValue.addListener(this);
targetBoardValue.addListener(this);
Expand Down
2 changes: 1 addition & 1 deletion Source/Heavy/ExporterBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct ExporterBase : public Component
{
addAndMakeVisible(exportButton);

exportButton.setColour(TextButton::buttonColourId, findColour(PlugDataColour::panelBackgroundColourId));
exportButton.setColour(ComboBox::outlineColourId, findColour(PlugDataColour::panelBackgroundColourId));

Array<PropertiesPanelProperty*> properties;

Expand Down
1 change: 1 addition & 0 deletions Source/LookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ void PlugDataLook::drawTextButtonBackground(Graphics& g, Button& button, bool sh
auto cornerSize = Corners::defaultCornerRadius;
g.setColour(backgroundColour);
fillSmoothedRectangle(g, button.getLocalBounds().toFloat(), cornerSize);
jassertfalse; // I think we don't use this anymore?
}

void PlugDataLook::drawToolbarButtonBackground(Graphics& g, Button& button, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown)
Expand Down

0 comments on commit a7bc078

Please sign in to comment.