Skip to content

Commit 8167b33

Browse files
committed
Apply theme colours
1 parent 8d372bf commit 8167b33

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

Diff for: Source/SpectrumCanvas.cpp

+17-5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ SpectrumCanvas::SpectrumCanvas(SpectrumViewer* n)
3636
viewport = std::make_unique<Viewport>();
3737
viewport->setViewedComponent(canvasPlot.get(), true);
3838
viewport->setScrollBarsShown(true, true);
39+
viewport->setScrollBarThickness (12);
3940
addAndMakeVisible(viewport.get());
4041
}
4142

@@ -205,6 +206,16 @@ void CanvasPlot::resized()
205206
clearButton->setBounds(plt.getRight() - 80, plt.getBottom() - 90, 60, 20);
206207
}
207208

209+
void CanvasPlot::lookAndFeelChanged()
210+
{
211+
plt.setBackgroundColour(findColour(ThemeColours::componentParentBackground));
212+
plt.setGridColour(findColour(ThemeColours::defaultText));
213+
plt.setAxisColour(findColour(ThemeColours::defaultText));
214+
215+
chanColors[0] = findColour(ThemeColours::controlPanelText).withAlpha(0.6f);
216+
plt.plot(xvalues, currPower[0], chanColors[0], 1.0f);
217+
}
218+
208219
void CanvasPlot::updateActiveChans()
209220
{
210221
activeChannels = processor->getActiveChans();
@@ -398,7 +409,7 @@ void CanvasPlot::drawSpectrogram(std::vector<float> chanData)
398409

399410
void CanvasPlot::paint(Graphics& g)
400411
{
401-
g.fillAll(Colour(28,28,28));
412+
g.fillAll(findColour (ThemeColours::componentBackground));
402413

403414
if(displayType == POWER_SPECTRUM)
404415
{
@@ -408,7 +419,7 @@ void CanvasPlot::paint(Graphics& g)
408419
int left = getWidth() - legendWidth - 10;
409420
int top = 60;
410421

411-
g.setFont(Font("Fira Code", "SemiBold", 16.0f));
422+
g.setFont(FontOptions("Inter", "Semi Bold", 16.0f));
412423

413424
for(int i = 0; i < activeChannels.size(); i++)
414425
{
@@ -420,7 +431,7 @@ void CanvasPlot::paint(Graphics& g)
420431
, 30
421432
, 30);
422433

423-
g.setColour(Colours::lightgrey);
434+
g.setColour(findColour(ThemeColours::controlPanelText));
424435
String chan = processor->getChanName(activeChannels[i]);
425436
g.drawFittedText(chan
426437
, left + 45
@@ -430,14 +441,14 @@ void CanvasPlot::paint(Graphics& g)
430441
, Justification::centredLeft
431442
, 1);
432443

433-
g.setColour(Colours::grey);
444+
g.setColour(findColour(ThemeColours::defaultFill));
434445
g.drawRect(left, top + 10, 30, 30, 2);
435446

436447
}
437448
}
438449
else
439450
{
440-
g.setColour(Colours::white);
451+
g.setColour(findColour(ThemeColours::controlPanelText));
441452

442453
int w = 50;
443454
int h = getHeight();
@@ -449,6 +460,7 @@ void CanvasPlot::paint(Graphics& g)
449460
int ticklabelWidth = 60;
450461
int tickLabelHeight = 20;
451462

463+
g.setFont(FontOptions("Inter", "Regular", 14.0f));
452464

453465
for (int k = 0; k <= 10; k++)
454466
{

Diff for: Source/SpectrumCanvas.h

+12-9
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3333

3434
class SpectrumCanvas;
3535

36-
const std::vector<Colour> chanColors = { Colour(200, 200, 200)
37-
, Colour(230, 159, 0)
38-
, Colour(86, 180, 233)
39-
, Colour(0, 158, 115)
40-
, Colour(240, 228, 66)
41-
, Colour(0, 114, 178)
42-
, Colour(242, 66, 53)
43-
, Colour(204, 121, 167) };
44-
4536
// Component for housing power spectrum & spectrograph plots
4637
class CanvasPlot : public Component
4738
, public Button::Listener
@@ -60,6 +51,9 @@ class CanvasPlot : public Component
6051
/** Updates component boundaries */
6152
void resized() override;
6253

54+
/** Called when the look and feel changes */
55+
void lookAndFeelChanged() override;
56+
6357
void updateActiveChans();
6458

6559
void setFrequencyRange(int freqStart, int freqEnd, float freqStep);
@@ -85,6 +79,15 @@ class CanvasPlot : public Component
8579

8680
private:
8781

82+
std::vector<Colour> chanColors = { Colour(200, 200, 200)
83+
, Colour(230, 159, 0)
84+
, Colour(86, 180, 233)
85+
, Colour(0, 158, 115)
86+
, Colour(240, 228, 66)
87+
, Colour(0, 114, 178)
88+
, Colour(242, 66, 53)
89+
, Colour(204, 121, 167) };
90+
8891
std::unique_ptr<UtilityButton> clearButton;
8992

9093
SpectrumViewer* processor;

0 commit comments

Comments
 (0)