Skip to content

Commit 881f3f8

Browse files
colours
1 parent 0fd4a5a commit 881f3f8

12 files changed

Lines changed: 99 additions & 40 deletions

source/GUIelements/ArrayAssignerButtons/ArrayAssignerButton.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ void ArrayAssignerButton::drawShiftDownShape(juce::Graphics &g, juce::Rectangle<
3838
drawPattern(g, bounds, shiftDownShape);
3939

4040
}
41+
void ArrayAssignerButton::drawArrowLeftShape(juce::Graphics &g, juce::Rectangle<int> bounds) {
42+
drawPattern(g, bounds, arrowLeftShape);
43+
}
44+
void ArrayAssignerButton::drawArrowRightShape(juce::Graphics &g, juce::Rectangle<int> bounds) {
45+
drawPattern(g, bounds, arrowRightShape);
46+
}
4147

4248

4349
void ArrayAssignerButton::paintButton (juce::Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) {
@@ -81,5 +87,11 @@ void ArrayAssignerButton::paintButton (juce::Graphics& g, bool shouldDrawButtonA
8187
case SHIFT_DOWN:
8288
drawShiftDownShape(g, bounds);
8389
break;
90+
case ARROW_LEFT:
91+
drawArrowLeftShape(g, bounds);
92+
break;
93+
case ARROW_RIGHT:
94+
drawArrowRightShape(g, bounds);
95+
break;
8496
}
8597
}

source/GUIelements/ArrayAssignerButtons/ArrayAssignerButton.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ enum ButtonDesigns {
1212
RESET,
1313
RANDOM,
1414
SHIFT_UP,
15-
SHIFT_DOWN
15+
SHIFT_DOWN,
16+
ARROW_LEFT,
17+
ARROW_RIGHT
1618
};
1719

1820
class ArrayAssignerButton : public juce::Button
@@ -31,6 +33,8 @@ class ArrayAssignerButton : public juce::Button
3133
void drawRandomShape(juce::Graphics &g, juce::Rectangle<int> bounds);
3234
void drawShiftUpShape(juce::Graphics &g, juce::Rectangle<int> bounds);
3335
void drawShiftDownShape(juce::Graphics &g, juce::Rectangle<int> bounds);
36+
void drawArrowLeftShape(juce::Graphics &g, juce::Rectangle<int> bounds);
37+
void drawArrowRightShape(juce::Graphics &g, juce::Rectangle<int> bounds);
3438

3539
void mouseUp (const juce::MouseEvent &) override;
3640

@@ -156,6 +160,29 @@ class ArrayAssignerButton : public juce::Button
156160
0, 0, 0, 0, 0, 0, 0, 0, 0
157161
};
158162

163+
const std::array<char, buttonPixelDims * buttonPixelDims> arrowLeftShape {
164+
0, 0, 0, 0, 0, 1, 0, 0, 0,
165+
0, 0, 0, 0, 1, 0, 0, 0, 0,
166+
0, 0, 0, 1, 0, 0, 0, 0, 0,
167+
0, 0, 1, 0, 0, 0, 0, 0, 0,
168+
0, 1, 0, 0, 0, 0, 0, 0, 0,
169+
0, 0, 1, 0, 0, 0, 0, 0, 0,
170+
0, 0, 0, 1, 0, 0, 0, 0, 0,
171+
0, 0, 0, 0, 1, 0, 0, 0, 0,
172+
0, 0, 0, 0, 0, 1, 0, 0, 0
173+
};
174+
const std::array<char, buttonPixelDims * buttonPixelDims> arrowRightShape {
175+
0, 0, 0, 1, 0, 0, 0, 0, 0,
176+
0, 0, 0, 0, 1, 0, 0, 0, 0,
177+
0, 0, 0, 0, 0, 1, 0, 0, 0,
178+
0, 0, 0, 0, 0, 0, 1, 0, 0,
179+
0, 0, 0, 0, 0, 0, 0, 1, 0,
180+
0, 0, 0, 0, 0, 0, 1, 0, 0,
181+
0, 0, 0, 0, 0, 1, 0, 0, 0,
182+
0, 0, 0, 0, 1, 0, 0, 0, 0,
183+
0, 0, 0, 1, 0, 0, 0, 0, 0
184+
};
185+
159186
};
160187

161188
#endif //MAIM_ARRAYASSIGNERBUTTON_H

source/GUIelements/EncoderSelector.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@ void EncoderSelector::paint (juce::Graphics& g)
3030
lnf->drawEncoderSelector (g, *this);
3131
}
3232

33-
void EncoderSelector::mouseUp (const juce::MouseEvent& e)
33+
void EncoderSelector::mouseUp (const juce::MouseEvent&)
3434
{
3535
const auto numOptions = optionNames.size();
36-
if (numOptions == 0 || getHeight() <= 0)
36+
if (numOptions == 0)
3737
return;
3838

39-
const auto row = juce::jlimit (0, numOptions - 1,
40-
static_cast<int> ((static_cast<float> (e.y) / static_cast<float> (getHeight())) * (float) numOptions));
41-
42-
if (row != selectedIndex)
43-
attachment->setValueAsCompleteGesture ((float) row);
39+
const auto nextIndex = (selectedIndex + 1) % numOptions;
40+
attachment->setValueAsCompleteGesture ((float) nextIndex);
4441
}

source/GUIelements/MaimColours.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace MaimColours {
1818
const juce::Colour SPLASH_COLOR_LIGHT = juce::Colours::lightblue;
1919
const juce::Colour CONTRAST_COLOR_DARK = juce::Colours::darkorange;
2020
const juce::Colour CONTRAST_COLOR_LIGHT = juce::Colours::orange;
21+
const juce::Colour OPUS_COLOR_DARK = juce::Colours::purple;
22+
const juce::Colour OPUS_COLOR_LIGHT = juce::Colours::purple.withLightness ( 0.8f);
2123
};
2224

2325
#endif //MAIM_MAIMCOLOURS_H

source/GUIelements/MaimLookAndFeel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ void MaimLookAndFeel::drawEncoderSelector(juce::Graphics& g, EncoderSelector& se
327327
const auto rowBottom = bounds.getY() + bounds.getHeight() * (i + 1) / numOptions;
328328
const auto row = bounds.withY(rowTop).withBottom(rowBottom);
329329
const auto selected = (i == selectedIndex);
330-
331-
g.setColour(selected ? MaimColours::SPLASH_COLOR_LIGHT : MaimColours::BEVEL_LIGHT);
330+
const auto colour = (i == 0) ? MaimColours::CONTRAST_COLOR_LIGHT.withLightness (0.65) : (i == 1) ? MaimColours::SPLASH_COLOR_LIGHT : MaimColours::OPUS_COLOR_LIGHT;
331+
g.setColour(selected ? colour : MaimColours::BEVEL_LIGHT);
332332
g.fillRect(row);
333333
g.setColour(selected ? MaimColours::BEVEL_DARK : MaimColours::BEVEL_BLACK);
334334
g.drawText(optionNames[i], row, juce::Justification::centred, false);

source/GUIelements/PresetsSection.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "StageWindow.h"
1616
#include "../PluginProcessor.h"
1717
#include "../PresetManager.h"
18+
#include "ArrayAssignerButtons/ArrayAssignerButton.h"
1819

1920
//==============================================================================
2021
/*
@@ -36,8 +37,8 @@ class PresetsSection : public StageWindow
3637

3738
juce::Label sectionName;
3839
juce::ComboBox presetBox;
39-
juce::TextButton previousPresetButton {"<"};
40-
juce::TextButton nextPresetButton {">"};
40+
ArrayAssignerButton previousPresetButton {"previous", ARROW_LEFT};
41+
ArrayAssignerButton nextPresetButton {"next", ARROW_RIGHT};
4142
juce::TextButton saveButton {"Save"};
4243

4344
juce::Array<juce::File> presetFiles;

source/GUIelements/ReassignmentSection.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ ReassignmentSection::ReassignmentSection (juce::AudioProcessorValueTreeState& p,
6060
itemVals[static_cast<size_t>(i)] = parameters[static_cast<size_t>(i)]->get();
6161
}
6262
steps = s;
63-
64-
startTimerHz(30);
65-
needsRepainting = false;
66-
6763
}
6864

6965
ReassignmentSection::~ReassignmentSection()
@@ -206,15 +202,14 @@ void ReassignmentSection::paint (juce::Graphics& g)
206202
g.fillRect(left, top, right - left, bottom - top);
207203
}
208204

209-
g.setColour(MaimColours::SPLASH_COLOR_DARK.withAlpha(0.7f));
205+
g.setColour(themeDarkColour.withAlpha(0.7f));
210206
for (int i = 0; i < static_cast<int>(itemVals.size()); ++i) {
211207
int left = activeArea.getX() + singleLineWidth * i;
212208
int right = activeArea.getX() + singleLineWidth * (i + 1);
213209
int top = getValScreenY(itemVals[static_cast<size_t>(i)] + 1);
214210
int bottom = getValScreenY(itemVals[static_cast<size_t>(i)]);
215211
g.fillRect(left, top, right - left, bottom - top);
216212
}
217-
needsRepainting = false;
218213
}
219214

220215
void ReassignmentSection::resized()
@@ -256,9 +251,6 @@ void ReassignmentSection::parameterChanged (const juce::String &, float)
256251
upButton.setVisible(!isOpus);
257252
downButton.setVisible(!isOpus);
258253
mp3OnlyLabel.setVisible(isOpus);
259-
260-
261-
needsRepainting = true;
262254
}
263255

264256
void ReassignmentSection::buildItemValsFromParams()
@@ -268,13 +260,6 @@ void ReassignmentSection::buildItemValsFromParams()
268260
}
269261
}
270262

271-
void ReassignmentSection::timerCallback()
272-
{
273-
if (needsRepainting) {
274-
repaint();
275-
}
276-
}
277-
278263
void ReassignmentSection::buttonClicked (juce::Button * b)
279264
{
280265
if (b == &resetButton) {

source/GUIelements/ReassignmentSection.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
*/
2727
class ReassignmentSection :
2828
public StageWindow,
29-
public juce::Timer,
3029
public juce::AudioProcessorValueTreeState::Listener,
3130
public juce::Button::Listener
3231
{
@@ -66,7 +65,6 @@ class ReassignmentSection :
6665

6766
void parameterChanged (const juce::String &parameterID, float newValue) override;
6867
void buildItemValsFromParams();
69-
void timerCallback() override;
7068

7169
juce::Rectangle<int> activeAreaBorder;
7270
juce::Rectangle<int> activeArea;
@@ -77,8 +75,6 @@ class ReassignmentSection :
7775
void setValue(const int index, const int newVal);
7876
std::vector<int> itemVals;
7977

80-
81-
std::atomic<bool> needsRepainting;
8278
int steps;
8379
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ReassignmentSection)
8480
};

source/GUIelements/StageWindow.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include "StageWindow.h"
1212

13+
#include "../parameterIds.h"
14+
1315
//==============================================================================
1416
void StageWindow::setUsableBounds()
1517
{
@@ -68,3 +70,28 @@ void StageWindow::paint (juce::Graphics& g)
6870
{
6971
prepare_background(g);
7072
}
73+
74+
void StageWindow::timerCallback()
75+
{
76+
auto p = parameters.getParameter(ENCODER_PARAM_ID)->getValue();
77+
if (p < 0.3) // blade
78+
{
79+
themeDarkColour = MaimColours::CONTRAST_COLOR_DARK;
80+
themeLightColour = MaimColours::CONTRAST_COLOR_LIGHT.withLightness (0.9f);
81+
contrastLightColour = MaimColours::SPLASH_COLOR_LIGHT;
82+
contrastDarkColour = MaimColours::SPLASH_COLOR_DARK;
83+
} else if (p < 0.6) // lame
84+
{
85+
themeDarkColour = MaimColours::SPLASH_COLOR_DARK;
86+
themeLightColour = MaimColours::SPLASH_COLOR_LIGHT;
87+
contrastLightColour = MaimColours::CONTRAST_COLOR_LIGHT;
88+
contrastDarkColour = MaimColours::CONTRAST_COLOR_DARK;
89+
} else // opus
90+
{
91+
themeDarkColour = MaimColours::OPUS_COLOR_DARK;
92+
themeLightColour = MaimColours::OPUS_COLOR_LIGHT;
93+
contrastLightColour = MaimColours::CONTRAST_COLOR_LIGHT;
94+
contrastDarkColour = MaimColours::BEVEL_WHITE;
95+
}
96+
repaint();
97+
}

source/GUIelements/StageWindow.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
//==============================================================================
1818
/*
1919
*/
20-
class StageWindow : public juce::Component
20+
class StageWindow : public juce::Component, public juce::Timer
2121
{
2222
public:
23-
StageWindow(juce::AudioProcessorValueTreeState& p) : parameters(p) {}
23+
StageWindow(juce::AudioProcessorValueTreeState& p) : parameters(p)
24+
{
25+
startTimerHz (60);
26+
}
2427
// virtual ~StageWindow();
2528

2629

@@ -41,6 +44,11 @@ class StageWindow : public juce::Component
4144
const juce::Colour TEXT_COLOR = juce::Colours::black;
4245
const juce::Colour BORDER_COLOR = juce::Colours::darkblue;
4346

47+
juce::Colour themeDarkColour;
48+
juce::Colour themeLightColour;
49+
juce::Colour contrastDarkColour;
50+
juce::Colour contrastLightColour;
51+
4452
void prepare_background(juce::Graphics& g);
4553
juce::Rectangle<int> draw_beveled_rectangle(juce::Graphics& g, juce::Rectangle<int> rect, bool raised);
4654

@@ -53,4 +61,6 @@ class StageWindow : public juce::Component
5361
const int LINE_WIDTH = 2; // For bevel
5462

5563
juce::AudioProcessorValueTreeState& parameters;
64+
private:
65+
void timerCallback() override;
5666
};

0 commit comments

Comments
 (0)