Skip to content

Commit bab6193

Browse files
committed
Use ThemeColours in ElectrodeButton
1 parent 6cf395a commit bab6193

2 files changed

Lines changed: 14 additions & 20 deletions

File tree

Source/Processors/Editors/ElectrodeButtons.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323

2424
#include "ElectrodeButtons.h"
25+
#include "../../UI/LookAndFeel/CustomLookAndFeel.h"
2526

2627
ElectrodeButton::ElectrodeButton (int chan_, Colour defaultColour_) : Button ("Electrode"),
2728
chan (chan_),
@@ -42,27 +43,23 @@ int ElectrodeButton::getChannelNum()
4243

4344
void ElectrodeButton::paintButton (Graphics& g, bool isMouseOver, bool isButtonDown)
4445
{
45-
if (getToggleState() == true)
46-
g.setColour (defaultColour);
47-
else
48-
g.setColour (Colours::darkgrey);
46+
Colour bgColour = findColour (ThemeColours::widgetBackground);
4947

50-
if (isMouseOver)
51-
g.setColour (Colours::white);
48+
if (getToggleState())
49+
bgColour = findColour (ThemeColours::highlightedFill);
5250

53-
if (! isEnabled())
54-
g.setColour (Colours::black);
51+
auto baseColour = bgColour.withMultipliedAlpha (isEnabled() ? 1.0f : 0.5f);
5552

56-
g.fillRect (0, 0, getWidth(), getHeight());
53+
if (isButtonDown || isMouseOver)
54+
baseColour = baseColour.contrasting (isButtonDown ? 0.2f : 0.1f);
5755

58-
g.setColour (Colours::black);
56+
g.setColour (baseColour);
57+
g.fillRect (0, 0, getWidth(), getHeight());
5958

59+
g.setColour (findColour (ThemeColours::outline).withAlpha (isEnabled() ? 1.0f : 0.5f));
6060
g.drawRect (0, 0, getWidth(), getHeight(), 1.0);
6161

62-
if (! isEnabled())
63-
{
64-
g.setColour (Colours::grey);
65-
}
62+
g.setColour (baseColour.contrasting().withAlpha (isEnabled() ? 1.0f : 0.5f));
6663

6764
if (chan < 100)
6865
g.setFont (10.f);

Source/Processors/Editors/GenericEditor.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ void GenericEditor::addCustomParameterEditor (ParameterEditor* ed, int xPos_, in
287287

288288
void GenericEditor::refreshColours()
289289
{
290-
291290
if (getProcessor()->isSource())
292291
backgroundColour = getLookAndFeel().findColour (ProcessorColour::IDs::SOURCE_COLOUR);
293292
else if (getProcessor()->isSink())
@@ -674,8 +673,7 @@ void GenericEditor::update (bool isEnabled_)
674673

675674
updateSelectedStream (getCurrentStream());
676675

677-
updateVisualizer(); // does nothing unless this method
678-
// has been implemented
676+
updateVisualizer(); // does nothing unless this method has been implemented
679677
}
680678

681679
void GenericEditor::setTTLState (uint16 streamId, int bit, bool state)
@@ -897,9 +895,9 @@ void UtilityButton::paintButton (Graphics& g, bool isMouseOver, bool isButtonDow
897895
g.setFont (font);
898896

899897
if (! isEnabled || isButtonDown)
900-
g.setColour (findColour (ThemeColours::defaultText).withAlpha (0.4f));
898+
g.setColour (baseColour.contrasting().withAlpha (0.4f));
901899
else
902-
g.setColour (findColour (ThemeColours::defaultText));
900+
g.setColour (baseColour.contrasting());
903901

904902
g.drawFittedText (label, 1, 1, getWidth() - 2, getHeight() - 2, Justification::centred, 2, 1.0f);
905903
}
@@ -1168,7 +1166,6 @@ void GenericEditor::updateSelectedStream (uint16 streamId)
11681166
{
11691167
if (streamAvailable)
11701168
{
1171-
11721169
auto stream = getProcessor()->getDataStream (streamId);
11731170

11741171
if (stream->hasParameter (parameterName))

0 commit comments

Comments
 (0)