1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-24 01:54:22 +00:00

Added an optional notification argument to ColourSelector::setCurrentColour()

This commit is contained in:
jules 2016-08-11 11:12:06 +01:00
parent cbdf707116
commit 3104cbe147
2 changed files with 17 additions and 13 deletions

View file

@ -336,7 +336,7 @@ ColourSelector::ColourSelector (const int sectionsToShow, const int edge, const
addAndMakeVisible (hueSelector = new HueSelectorComp (*this, h, gapAroundColourSpaceComponent));
}
update();
update (sendNotification);
}
ColourSelector::~ColourSelector()
@ -351,14 +351,14 @@ Colour ColourSelector::getCurrentColour() const
return ((flags & showAlphaChannel) != 0) ? colour : colour.withAlpha ((uint8) 0xff);
}
void ColourSelector::setCurrentColour (Colour c)
void ColourSelector::setCurrentColour (Colour c, NotificationType notification)
{
if (c != colour)
{
colour = ((flags & showAlphaChannel) != 0) ? c : c.withAlpha ((uint8) 0xff);
updateHSV();
update();
update (notification);
}
}
@ -370,7 +370,7 @@ void ColourSelector::setHue (float newH)
{
h = newH;
colour = Colour (h, s, v, colour.getFloatAlpha());
update();
update (sendNotification);
}
}
@ -384,7 +384,7 @@ void ColourSelector::setSV (float newS, float newV)
s = newS;
v = newV;
colour = Colour (h, s, v, colour.getFloatAlpha());
update();
update (sendNotification);
}
}
@ -394,14 +394,14 @@ void ColourSelector::updateHSV()
colour.getHSB (h, s, v);
}
void ColourSelector::update()
void ColourSelector::update (NotificationType notification)
{
if (sliders[0] != nullptr)
{
sliders[0]->setValue ((int) colour.getRed());
sliders[1]->setValue ((int) colour.getGreen());
sliders[2]->setValue ((int) colour.getBlue());
sliders[3]->setValue ((int) colour.getAlpha());
sliders[0]->setValue ((int) colour.getRed(), notification);
sliders[1]->setValue ((int) colour.getGreen(), notification);
sliders[2]->setValue ((int) colour.getBlue(), notification);
sliders[3]->setValue ((int) colour.getAlpha(), notification);
}
if (colourSpace != nullptr)
@ -413,7 +413,11 @@ void ColourSelector::update()
if ((flags & showColourAtTop) != 0)
repaint (previewArea);
sendChangeMessage();
if (notification != dontSendNotification)
sendChangeMessage();
if (notification == sendNotificationSync)
dispatchPendingMessages();
}
//==============================================================================

View file

@ -80,7 +80,7 @@ public:
Colour getCurrentColour() const;
/** Changes the colour that is currently being shown. */
void setCurrentColour (Colour newColour);
void setCurrentColour (Colour newColour, NotificationType notificationType = sendNotification);
//==============================================================================
/** Tells the selector how many preset colour swatches you want to have on the component.
@ -153,7 +153,7 @@ private:
void setHue (float newH);
void setSV (float newS, float newV);
void updateHSV();
void update();
void update (NotificationType);
void sliderValueChanged (Slider*) override;
void paint (Graphics&) override;
void resized() override;