Skip to content

Commit

Permalink
add colour picker icon path
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Jul 21, 2024
1 parent 7078145 commit 783d530
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
31 changes: 26 additions & 5 deletions Source/LumatoneEditorLookAndFeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4

g.setColour(colour);
g.fillPath(getButtonShape(btn));

if (btn.isColourSpecified(LumatoneEditorColourIDs::OutlineColourId))
{
g.setColour(btn.findColour(LumatoneEditorColourIDs::OutlineColourId));
g.strokePath(getButtonShape(btn), PathStrokeType(1.5f));
}
}

void drawButtonText(Graphics& g, TextButton& btn, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
Expand All @@ -371,7 +377,8 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4
if (properties.contains(LumatoneEditorStyleIDs::textButtonIconHashCode))
{
int bkgdColourId = (shouldDrawButtonAsDown) ? TextButton::ColourIds::buttonOnColourId : TextButton::ColourIds::buttonColourId;
drawButtonBackground(g, btn, btn.findColour(bkgdColourId), shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
juce::Colour bkgdColour = btn.findColour(bkgdColourId);
drawButtonBackground(g, btn, bkgdColour, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);

int colourId = shouldDrawButtonAsDown ? TextButton::ColourIds::textColourOnId : TextButton::ColourIds::textColourOffId;
Colour textColour = btn.findColour(colourId);
Expand Down Expand Up @@ -439,7 +446,9 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4
PathStrokeType stroke(1.5f);
stroke.setEndStyle(PathStrokeType::EndCapStyle::rounded);
stroke.setJointStyle(PathStrokeType::JointStyle::curved);

juce::Colour iconColour = textColour;
float iconScale = 1.0f;
int iconXOffset = 0.0;
switch (LumatoneEditorIcon(iconCode))
{
// Using X for now
Expand All @@ -461,13 +470,23 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4
iconPath = saveIconPath;
break;
}
case LumatoneEditorIcon::ColourPicker:
{
iconPath = colourPickerPath;
iconScale = 0.04f;
iconXOffset = iconW * 0.3333f;
iconColour = bkgdColour.contrasting();
stroke.setStrokeThickness(1.0f);
break;
}
default:
break;
}

auto transform = AffineTransform::scale(iconW, iconH).followedBy(AffineTransform::translation(iconX, iconY));
auto transform = AffineTransform::scale(iconW * iconScale, iconH * iconScale)
.followedBy(AffineTransform::translation(iconX + iconXOffset, iconY));
iconPath.applyTransform(transform);
g.setColour(textColour);
g.setColour(iconColour);
g.strokePath(iconPath, stroke);
}

Expand Down Expand Up @@ -846,7 +865,7 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4
if (buttonW > 0)
{
g.setColour(textColour);
g.setFont(getAppFont(LumatoneEditorFont::GothamNarrowLight, buttonH * 0.5f).withHorizontalScale(2.0f));
g.setFont(getAppFont(LumatoneEditorFont::GothamNarrowLight, buttonH * 0.5f).withHorizontalScale(1.5f));
g.drawFittedText("v", realButtonX, 0, box.getHeight(), box.getHeight(), Justification::centred, 1);
}
}
Expand Down Expand Up @@ -1375,6 +1394,7 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4
saveIconPath = getSaveIconPath();
arrowUpIconPath = getArrowPath(Point<float>(0.5f, 0.96f), Point<float>(0.5f, 0.08f), 0.55, 0.333f);
arrowDownIconPath = getArrowPath(Point<float>(0.5f, 0.08f), Point<float>(0.5f, 0.96f), 0.55, 0.667f);
colourPickerPath = getPickerIconPath();
}

/// <summary>
Expand Down Expand Up @@ -1453,6 +1473,7 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4
Path arrowDownIconPath;
// Path ccPolarityDefaultIconPath;
// Path ccPolarityInvertedIconPath;
Path colourPickerPath;

// Default graphics constants
const float buttonRoundedCornerScalar = 0.2f;
Expand Down
24 changes: 23 additions & 1 deletion Source/LumatoneEditorStyleCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,36 @@ static Image getCachedCloneImage()
return cloneImg;
}

static Path getPickerIconPath()
{
const unsigned char pathData[] = {
110,109,106,188,149,65,199,75,13,65,98,47,221,143,65,226,122,26,65,126,106,144,65,33,176,46,65,0,0,151,65,250,126,58,65,108,
4,86,140,65,29,90,82,65,108,90,100,33,65,42,92,207,64,108,106,188,54,65,22,174,159,64,98,84,227,67,65,102,59,183,64,196,32,88,
65,245,253,180,64,84,227,99,65,143,151,154,64,108,207,247,141,65,6,0,128,63,98,70,182,146,65,92,139,172,62,174,71,153,65,0,
0,64,53,60,223,159,65,0,0,64,53,98,52,51,173,65,0,0,64,53,1,0,184,65,248,210,173,63,1,0,184,65,122,190,63,64,98,1,0,184,65,28,4,
110,64,255,212,181,65,194,202,141,64,157,196,177,65,51,8,160,64,108,108,188,149,65,200,75,13,65,99,109,255,255,39,65,0,0,112,
65,108,82,227,249,64,0,0,112,65,108,192,202,59,65,64,53,42,65,108,157,239,35,65,72,225,20,65,108,218,36,22,64,192,202,144,65,
98,248,212,136,63,14,45,156,65,48,51,11,64,71,225,162,65,69,55,153,63,63,53,177,65,98,151,239,135,63,245,40,179,65,242,255,127,
63,73,12,181,65,242,255,127,63,192,202,182,65,98,242,255,127,63,122,20,188,65,178,30,197,63,0,0,192,65,34,6,9,64,0,0,192,65,
98,173,114,24,64,0,0,192,65,16,131,40,64,53,94,191,65,38,92,55,64,182,243,189,65,98,208,34,147,64,198,75,179,65,185,73,176,64,
225,122,188,65,62,53,218,64,168,198,176,65,108,30,133,107,65,72,225,84,65,108,251,169,83,65,80,141,63,65,108,255,255,39,65,0,
0,112,65,99,101,0,0
};

Path path;
path.loadPathFromData (pathData, sizeof (pathData));
return path;
}

enum LumatoneEditorIcon
{
Checkmark = 0x01,
ArrowUp,
ArrowDown,
SaveIcon,
LoadIcon,
CCPolarityIcon
CCPolarityIcon,
ColourPicker
};

enum LumatoneEditorColourIDs
Expand Down

0 comments on commit 783d530

Please sign in to comment.