JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_ColourSelector.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
30{
31 ColourComponentSlider (const String& name) : Slider (name)
32 {
33 setRange (0.0, 255.0, 1.0);
34 }
35
36 String getTextFromValue (double value) override
37 {
38 return String::toHexString ((int) value).toUpperCase().paddedLeft ('0', 2);
39 }
40
41 double getValueFromText (const String& text) override
42 {
43 return (double) text.getHexValue32();
44 }
45};
46
47//==============================================================================
49{
50public:
51 ColourSpaceView (ColourSelector& cs, float& hue, float& sat, float& val, int edgeSize)
52 : owner (cs), h (hue), s (sat), v (val), edge (edgeSize)
53 {
54 addAndMakeVisible (marker);
56 }
57
58 void paint (Graphics& g) override
59 {
60 if (colours.isNull())
61 {
62 auto width = getWidth() / 2;
63 auto height = getHeight() / 2;
64 colours = Image (Image::RGB, width, height, false);
65
66 Image::BitmapData pixels (colours, Image::BitmapData::writeOnly);
67
68 for (int y = 0; y < height; ++y)
69 {
70 auto val = 1.0f - (float) y / (float) height;
71
72 for (int x = 0; x < width; ++x)
73 {
74 auto sat = (float) x / (float) width;
75 pixels.setPixelColour (x, y, Colour (h, sat, val, 1.0f));
76 }
77 }
78 }
79
80 g.setOpacity (1.0f);
81 g.drawImageTransformed (colours,
84 getLocalBounds().reduced (edge).toFloat()),
85 false);
86 }
87
88 void mouseDown (const MouseEvent& e) override
89 {
90 mouseDrag (e);
91 }
92
93 void mouseDrag (const MouseEvent& e) override
94 {
95 auto sat = (float) (e.x - edge) / (float) (getWidth() - edge * 2);
96 auto val = 1.0f - (float) (e.y - edge) / (float) (getHeight() - edge * 2);
97
98 owner.setSV (sat, val);
99 }
100
101 void updateIfNeeded()
102 {
103 if (! approximatelyEqual (lastHue, h))
104 {
105 lastHue = h;
106 colours = {};
107 repaint();
108 }
109
110 updateMarker();
111 }
112
113 void resized() override
114 {
115 colours = {};
116 updateMarker();
117 }
118
119private:
120 ColourSelector& owner;
121 float& h;
122 float& s;
123 float& v;
124 float lastHue = 0;
125 const int edge;
126 Image colours;
127
128 struct ColourSpaceMarker final : public Component
129 {
130 ColourSpaceMarker()
131 {
132 setInterceptsMouseClicks (false, false);
133 }
134
135 void paint (Graphics& g) override
136 {
137 g.setColour (Colour::greyLevel (0.1f));
138 g.drawEllipse (1.0f, 1.0f, (float) getWidth() - 2.0f, (float) getHeight() - 2.0f, 1.0f);
139 g.setColour (Colour::greyLevel (0.9f));
140 g.drawEllipse (2.0f, 2.0f, (float) getWidth() - 4.0f, (float) getHeight() - 4.0f, 1.0f);
141 }
142 };
143
144 ColourSpaceMarker marker;
145
146 void updateMarker()
147 {
148 auto markerSize = jmax (14, edge * 2);
149 auto area = getLocalBounds().reduced (edge);
150
151 marker.setBounds (Rectangle<int> (markerSize, markerSize)
152 .withCentre (area.getRelativePoint (s, 1.0f - v)));
153 }
154
155 JUCE_DECLARE_NON_COPYABLE (ColourSpaceView)
156};
157
158//==============================================================================
160{
161public:
162 HueSelectorComp (ColourSelector& cs, float& hue, int edgeSize)
163 : owner (cs), h (hue), edge (edgeSize)
164 {
165 addAndMakeVisible (marker);
166 }
167
168 void paint (Graphics& g) override
169 {
171 cg.isRadial = false;
172 cg.point1.setXY (0.0f, (float) edge);
173 cg.point2.setXY (0.0f, (float) getHeight());
174
175 for (float i = 0.0f; i <= 1.0f; i += 0.02f)
176 cg.addColour (i, Colour (i, 1.0f, 1.0f, 1.0f));
177
179 g.fillRect (getLocalBounds().reduced (edge));
180 }
181
182 void resized() override
183 {
184 auto markerSize = jmax (14, edge * 2);
185 auto area = getLocalBounds().reduced (edge);
186
187 marker.setBounds (Rectangle<int> (getWidth(), markerSize)
188 .withCentre (area.getRelativePoint (0.5f, h)));
189 }
190
191 void mouseDown (const MouseEvent& e) override
192 {
193 mouseDrag (e);
194 }
195
196 void mouseDrag (const MouseEvent& e) override
197 {
198 owner.setHue ((float) (e.y - edge) / (float) (getHeight() - edge * 2));
199 }
200
201 void updateIfNeeded()
202 {
203 resized();
204 }
205
206private:
207 ColourSelector& owner;
208 float& h;
209 const int edge;
210
211 struct HueSelectorMarker final : public Component
212 {
213 HueSelectorMarker()
214 {
215 setInterceptsMouseClicks (false, false);
216 }
217
218 void paint (Graphics& g) override
219 {
220 auto cw = (float) getWidth();
221 auto ch = (float) getHeight();
222
223 Path p;
224 p.addTriangle (1.0f, 1.0f,
225 cw * 0.3f, ch * 0.5f,
226 1.0f, ch - 1.0f);
227
228 p.addTriangle (cw - 1.0f, 1.0f,
229 cw * 0.7f, ch * 0.5f,
230 cw - 1.0f, ch - 1.0f);
231
232 g.setColour (Colours::white.withAlpha (0.75f));
233 g.fillPath (p);
234
235 g.setColour (Colours::black.withAlpha (0.75f));
236 g.strokePath (p, PathStrokeType (1.2f));
237 }
238 };
239
240 HueSelectorMarker marker;
241
242 JUCE_DECLARE_NON_COPYABLE (HueSelectorComp)
243};
244
245//==============================================================================
247{
248public:
249 SwatchComponent (ColourSelector& cs, int itemIndex)
250 : owner (cs), index (itemIndex)
251 {
252 }
253
254 void paint (Graphics& g) override
255 {
256 auto col = owner.getSwatchColour (index);
257
258 g.fillCheckerBoard (getLocalBounds().toFloat(), 6.0f, 6.0f,
259 Colour (0xffdddddd).overlaidWith (col),
260 Colour (0xffffffff).overlaidWith (col));
261 }
262
263 void mouseDown (const MouseEvent&) override
264 {
265 PopupMenu m;
266 m.addItem (1, TRANS ("Use this swatch as the current colour"));
267 m.addSeparator();
268 m.addItem (2, TRANS ("Set this swatch to the current colour"));
269
270 m.showMenuAsync (PopupMenu::Options().withTargetComponent (this),
271 ModalCallbackFunction::forComponent (menuStaticCallback, this));
272 }
273
274private:
275 ColourSelector& owner;
276 const int index;
277
278 static void menuStaticCallback (int result, SwatchComponent* comp)
279 {
280 if (comp != nullptr)
281 {
282 if (result == 1) comp->setColourFromSwatch();
283 if (result == 2) comp->setSwatchFromColour();
284 }
285 }
286
287 void setColourFromSwatch()
288 {
289 owner.setCurrentColour (owner.getSwatchColour (index));
290 }
291
292 void setSwatchFromColour()
293 {
294 if (owner.getSwatchColour (index) != owner.getCurrentColour())
295 {
296 owner.setSwatchColour (index, owner.getCurrentColour());
297 repaint();
298 }
299 }
300
301 JUCE_DECLARE_NON_COPYABLE (SwatchComponent)
302};
303
304//==============================================================================
306{
307public:
308 ColourPreviewComp (ColourSelector& cs, bool isEditable)
309 : owner (cs)
310 {
311 colourLabel.setFont (labelFont);
313
314 if (isEditable)
315 {
316 colourLabel.setEditable (true);
317
318 colourLabel.onEditorShow = [this]
319 {
320 if (auto* ed = colourLabel.getCurrentTextEditor())
321 ed->setInputRestrictions ((owner.flags & showAlphaChannel) ? 8 : 6, "1234567890ABCDEFabcdef");
322 };
323
324 colourLabel.onEditorHide = [this]
325 {
326 updateColourIfNecessary (colourLabel.getText());
327 };
328 }
329
330 addAndMakeVisible (colourLabel);
331 }
332
333 void updateIfNeeded()
334 {
335 auto newColour = owner.getCurrentColour();
336
337 if (currentColour != newColour)
338 {
339 currentColour = newColour;
340 auto textColour = (Colours::white.overlaidWith (currentColour).contrasting());
341
344 colourLabel.setText (currentColour.toDisplayString ((owner.flags & showAlphaChannel) != 0), dontSendNotification);
345
346 labelWidth = labelFont.getStringWidth (colourLabel.getText());
347
348 repaint();
349 }
350 }
351
352 void paint (Graphics& g) override
353 {
354 g.fillCheckerBoard (getLocalBounds().toFloat(), 10.0f, 10.0f,
355 Colour (0xffdddddd).overlaidWith (currentColour),
356 Colour (0xffffffff).overlaidWith (currentColour));
357 }
358
359 void resized() override
360 {
361 colourLabel.centreWithSize (labelWidth + 10, (int) labelFont.getHeight() + 10);
362 }
363
364private:
365 void updateColourIfNecessary (const String& newColourString)
366 {
368
369 if (newColour != currentColour)
371 }
372
373 ColourSelector& owner;
374
375 Colour currentColour;
376 Font labelFont { 14.0f, Font::bold };
377 int labelWidth = 0;
378 Label colourLabel;
379
381};
382
383//==============================================================================
385 : colour (Colours::white),
386 flags (sectionsToShow),
387 edgeGap (edge)
388{
389 // not much point having a selector with no components in it!
390 jassert ((flags & (showColourAtTop | showSliders | showColourspace)) != 0);
391
392 updateHSV();
393
394 if ((flags & showColourAtTop) != 0)
395 {
396 previewComponent.reset (new ColourPreviewComp (*this, (flags & editableColour) != 0));
397 addAndMakeVisible (previewComponent.get());
398 }
399
400 if ((flags & showSliders) != 0)
401 {
402 sliders[0].reset (new ColourComponentSlider (TRANS ("red")));
403 sliders[1].reset (new ColourComponentSlider (TRANS ("green")));
404 sliders[2].reset (new ColourComponentSlider (TRANS ("blue")));
405 sliders[3].reset (new ColourComponentSlider (TRANS ("alpha")));
406
407 addAndMakeVisible (sliders[0].get());
408 addAndMakeVisible (sliders[1].get());
409 addAndMakeVisible (sliders[2].get());
410 addChildComponent (sliders[3].get());
411
412 sliders[3]->setVisible ((flags & showAlphaChannel) != 0);
413
414 for (auto& slider : sliders)
415 slider->onValueChange = [this] { changeColour(); };
416 }
417
418 if ((flags & showColourspace) != 0)
419 {
420 colourSpace.reset (new ColourSpaceView (*this, h, s, v, gapAroundColourSpaceComponent));
421 hueSelector.reset (new HueSelectorComp (*this, h, gapAroundColourSpaceComponent));
422
423 addAndMakeVisible (colourSpace.get());
424 addAndMakeVisible (hueSelector.get());
425 }
426
427 update (dontSendNotification);
428}
429
430ColourSelector::~ColourSelector()
431{
432 dispatchPendingMessages();
433 swatchComponents.clear();
434}
435
436//==============================================================================
437Colour ColourSelector::getCurrentColour() const
438{
439 return ((flags & showAlphaChannel) != 0) ? colour : colour.withAlpha ((uint8) 0xff);
440}
441
442void ColourSelector::setCurrentColour (Colour c, NotificationType notification)
443{
444 if (c != colour)
445 {
446 colour = ((flags & showAlphaChannel) != 0) ? c : c.withAlpha ((uint8) 0xff);
447
448 updateHSV();
449 update (notification);
450 }
451}
452
453void ColourSelector::setHue (float newH)
454{
455 newH = jlimit (0.0f, 1.0f, newH);
456
457 if (! approximatelyEqual (h, newH))
458 {
459 h = newH;
460 colour = Colour (h, s, v, colour.getFloatAlpha());
461 update (sendNotification);
462 }
463}
464
465void ColourSelector::setSV (float newS, float newV)
466{
467 newS = jlimit (0.0f, 1.0f, newS);
468 newV = jlimit (0.0f, 1.0f, newV);
469
470 if (! approximatelyEqual (s, newS) || ! approximatelyEqual (v, newV))
471 {
472 s = newS;
473 v = newV;
474 colour = Colour (h, s, v, colour.getFloatAlpha());
475 update (sendNotification);
476 }
477}
478
479//==============================================================================
480void ColourSelector::updateHSV()
481{
482 colour.getHSB (h, s, v);
483}
484
485void ColourSelector::update (NotificationType notification)
486{
487 if (sliders[0] != nullptr)
488 {
489 sliders[0]->setValue ((int) colour.getRed(), notification);
490 sliders[1]->setValue ((int) colour.getGreen(), notification);
491 sliders[2]->setValue ((int) colour.getBlue(), notification);
492 sliders[3]->setValue ((int) colour.getAlpha(), notification);
493 }
494
495 if (colourSpace != nullptr)
496 {
497 colourSpace->updateIfNeeded();
498 hueSelector->updateIfNeeded();
499 }
500
501 if (previewComponent != nullptr)
502 previewComponent->updateIfNeeded();
503
504 if (notification != dontSendNotification)
505 sendChangeMessage();
506
507 if (notification == sendNotificationSync)
508 dispatchPendingMessages();
509}
510
511//==============================================================================
512void ColourSelector::paint (Graphics& g)
513{
514 g.fillAll (findColour (backgroundColourId));
515
516 if ((flags & showSliders) != 0)
517 {
518 g.setColour (findColour (labelTextColourId));
519 g.setFont (11.0f);
520
521 for (auto& slider : sliders)
522 {
523 if (slider->isVisible())
524 g.drawText (slider->getName() + ":",
525 0, slider->getY(),
526 slider->getX() - 8, slider->getHeight(),
527 Justification::centredRight, false);
528 }
529 }
530}
531
532void ColourSelector::resized()
533{
534 const int swatchesPerRow = 8;
535 const int swatchHeight = 22;
536
537 const int numSliders = ((flags & showAlphaChannel) != 0) ? 4 : 3;
538 const int numSwatches = getNumSwatches();
539
540 const int swatchSpace = numSwatches > 0 ? edgeGap + swatchHeight * ((numSwatches + 7) / swatchesPerRow) : 0;
541 const int sliderSpace = ((flags & showSliders) != 0) ? jmin (22 * numSliders + edgeGap, proportionOfHeight (0.3f)) : 0;
542 const int topSpace = ((flags & showColourAtTop) != 0) ? jmin (30 + edgeGap * 2, proportionOfHeight (0.2f)) : edgeGap;
543
544 if (previewComponent != nullptr)
545 previewComponent->setBounds (edgeGap, edgeGap, getWidth() - edgeGap * 2, topSpace - edgeGap * 2);
546
547 int y = topSpace;
548
549 if ((flags & showColourspace) != 0)
550 {
551 const int hueWidth = jmin (50, proportionOfWidth (0.15f));
552
553 colourSpace->setBounds (edgeGap, y,
554 getWidth() - hueWidth - edgeGap - 4,
555 getHeight() - topSpace - sliderSpace - swatchSpace - edgeGap);
556
557 hueSelector->setBounds (colourSpace->getRight() + 4, y,
558 getWidth() - edgeGap - (colourSpace->getRight() + 4),
559 colourSpace->getHeight());
560
561 y = getHeight() - sliderSpace - swatchSpace - edgeGap;
562 }
563
564 if ((flags & showSliders) != 0)
565 {
566 auto sliderHeight = jmax (4, sliderSpace / numSliders);
567
568 for (int i = 0; i < numSliders; ++i)
569 {
570 sliders[i]->setBounds (proportionOfWidth (0.2f), y,
571 proportionOfWidth (0.72f), sliderHeight - 2);
572
573 y += sliderHeight;
574 }
575 }
576
577 if (numSwatches > 0)
578 {
579 const int startX = 8;
580 const int xGap = 4;
581 const int yGap = 4;
582 const int swatchWidth = (getWidth() - startX * 2) / swatchesPerRow;
583 y += edgeGap;
584
585 if (swatchComponents.size() != numSwatches)
586 {
587 swatchComponents.clear();
588
589 for (int i = 0; i < numSwatches; ++i)
590 {
591 auto* sc = new SwatchComponent (*this, i);
592 swatchComponents.add (sc);
593 addAndMakeVisible (sc);
594 }
595 }
596
597 int x = startX;
598
599 for (int i = 0; i < swatchComponents.size(); ++i)
600 {
601 auto* sc = swatchComponents.getUnchecked (i);
602
603 sc->setBounds (x + xGap / 2,
604 y + yGap / 2,
605 swatchWidth - xGap,
606 swatchHeight - yGap);
607
608 if (((i + 1) % swatchesPerRow) == 0)
609 {
610 x = startX;
611 y += swatchHeight;
612 }
613 else
614 {
615 x += swatchWidth;
616 }
617 }
618 }
619}
620
621void ColourSelector::changeColour()
622{
623 if (sliders[0] != nullptr)
624 setCurrentColour (Colour ((uint8) sliders[0]->getValue(),
625 (uint8) sliders[1]->getValue(),
626 (uint8) sliders[2]->getValue(),
627 (uint8) sliders[3]->getValue()));
628}
629
630//==============================================================================
631int ColourSelector::getNumSwatches() const
632{
633 return 0;
634}
635
636Colour ColourSelector::getSwatchColour (int) const
637{
638 jassertfalse; // if you've overridden getNumSwatches(), you also need to implement this method
639 return Colours::black;
640}
641
642void ColourSelector::setSwatchColour (int, const Colour&)
643{
644 jassertfalse; // if you've overridden getNumSwatches(), you also need to implement this method
645}
646
647} // namespace juce
Describes the layout and colours that should be used to paint a colour gradient.
bool isRadial
If true, the gradient should be filled circularly, centred around point1, with point2 defining a poin...
void paint(Graphics &g) override
Components can override this method to draw their content.
void resized() override
Called when this component's size has been changed.
void resized() override
Called when this component's size has been changed.
void mouseDown(const MouseEvent &e) override
Called when a mouse button is pressed.
void paint(Graphics &g) override
Components can override this method to draw their content.
void mouseDrag(const MouseEvent &e) override
Called when the mouse is moved while a button is held down.
void mouseDown(const MouseEvent &e) override
Called when a mouse button is pressed.
void mouseDrag(const MouseEvent &e) override
Called when the mouse is moved while a button is held down.
void resized() override
Called when this component's size has been changed.
void paint(Graphics &g) override
Components can override this method to draw their content.
void paint(Graphics &g) override
Components can override this method to draw their content.
void mouseDown(const MouseEvent &) override
Called when a mouse button is pressed.
A component that lets the user choose a colour.
ColourSelector(int flags=(showAlphaChannel|showColourAtTop|showSliders|showColourspace), int edgeGap=4, int gapAroundColourSpaceComponent=7)
Creates a ColourSelector object.
virtual void setSwatchColour(int index, const Colour &newColour)
Called by the selector when the user puts a new colour into one of the swatches.
virtual Colour getSwatchColour(int index) const
Called by the selector to find out the colour of one of the swatches.
Colour getCurrentColour() const
Returns the colour that the user has currently selected.
void setCurrentColour(Colour newColour, NotificationType notificationType=sendNotification)
Changes the colour that is currently being shown.
@ showColourAtTop
if set, a swatch of the colour is shown at the top of the component.
@ editableColour
if set, the colour shows at the top of the component is editable.
@ showSliders
if set, RGB sliders are shown at the bottom of the component.
@ showColourspace
if set, a big HSV selector is shown.
@ showAlphaChannel
if set, the colour's alpha channel can be changed as well as its RGB.
Represents a colour, also including a transparency value.
Definition juce_Colour.h:38
Colour withAlpha(uint8 newAlpha) const noexcept
Returns a colour that's the same colour as this one, but with a new alpha value.
static Colour greyLevel(float brightness) noexcept
Returns an opaque shade of grey.
static Colour fromString(StringRef encodedColourString)
Reads the colour from a string that was created with toString().
String toDisplayString(bool includeAlphaValue) const
Returns the colour as a hex string in the form RRGGBB or AARRGGBB.
The base class for all JUCE user-interface objects.
void setInterceptsMouseClicks(bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
Changes the default return value for the hitTest() method.
int getHeight() const noexcept
Returns the component's height in pixels.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
void setMouseCursor(const MouseCursor &cursorType)
Changes the mouse cursor shape to use when the mouse is over this component.
void repaint()
Marks the whole component as needing to be redrawn.
void setColour(int colourID, Colour newColour)
Registers a colour to be used for a particular purpose.
int getWidth() const noexcept
Returns the component's width in pixels.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
void centreWithSize(int width, int height)
Changes the component's size and centres it within its parent.
void addChildComponent(Component *child, int zOrder=-1)
Adds a child component to this one.
Represents a particular font, including its size, style, etc.
Definition juce_Font.h:42
float getHeight() const noexcept
Returns the total height of this font, in pixels.
int getStringWidth(const String &text) const
Returns the total width of a string as it would be drawn using this font.
@ bold
boldens the font.
Definition juce_Font.h:51
A graphics context, used for drawing a component or image.
void setOpacity(float newOpacity)
Changes the opacity to use with the current colour.
void setGradientFill(const ColourGradient &gradient)
Sets the context to use a gradient for its fill pattern.
void drawImageTransformed(const Image &imageToDraw, const AffineTransform &transform, bool fillAlphaChannelWithCurrentBrush=false) const
Draws an image, having applied an affine transform to it.
void fillRect(Rectangle< int > rectangle) const
Fills a rectangle with the current colour or brush.
void drawEllipse(float x, float y, float width, float height, float lineThickness) const
Draws an elliptical stroke using the current colour or brush.
void fillCheckerBoard(Rectangle< float > area, float checkWidth, float checkHeight, Colour colour1, Colour colour2) const
Fills a rectangle with a checkerboard pattern, alternating between two colours.
void setColour(Colour newColour)
Changes the current drawing colour.
Retrieves a section of an image as raw pixel data, so it can be read or written to.
Definition juce_Image.h:310
void setPixelColour(int x, int y, Colour colour) const noexcept
Sets the colour of a given pixel.
Holds a fixed-size bitmap.
Definition juce_Image.h:58
Rectangle< int > getBounds() const noexcept
Returns a rectangle with the same size as this image.
bool isNull() const noexcept
Returns true if this image is not valid.
Definition juce_Image.h:155
@ RGB
< each pixel is a 3-byte packed RGB colour value.
Definition juce_Image.h:66
@ centred
Indicates that the item should be centred vertically and horizontally.
void setEditable(bool editOnSingleClick, bool editOnDoubleClick=false, bool lossOfFocusDiscardsChanges=false)
Makes the label turn into a TextEditor when clicked.
@ textWhenEditingColourId
The colour for the text when the label is being edited.
Definition juce_Label.h:111
@ textColourId
The colour for the text.
Definition juce_Label.h:107
void setFont(const Font &newFont)
Changes the font to use to draw the text.
std::function< void()> onEditorShow
You can assign a lambda to this callback object to have it called when the label's editor is shown.
Definition juce_Label.h:209
std::function< void()> onEditorHide
You can assign a lambda to this callback object to have it called when the label's editor is hidden.
Definition juce_Label.h:212
String getText(bool returnActiveEditorContents=false) const
Returns the label's current text.
void setJustificationType(Justification justification)
Sets the style of justification to be used for positioning the text.
TextEditor * getCurrentTextEditor() const noexcept
Returns the currently-visible text editor, or nullptr if none is open.
void setText(const String &newText, NotificationType notification)
Changes the label text.
static ModalComponentManager::Callback * forComponent(void(*functionToCall)(int, ComponentType *), ComponentType *component)
This is a utility function to create a ModalComponentManager::Callback that will call a static functi...
@ CrosshairCursor
A pair of crosshairs.
Contains position and status information about a mouse event.
const int x
The x-position of the mouse when the event occurred.
const int y
The y-position of the mouse when the event occurred.
Class used to create a set of options to pass to the show() method.
Creates and displays a popup-menu.
void addSeparator()
Appends a separator to the menu, to help break it up into sections.
void showMenuAsync(const Options &options)
Runs the menu asynchronously.
void addItem(Item newItem)
Adds an item to the menu.
Defines the method used to position some kind of rectangular object within a rectangular viewport.
AffineTransform getTransformToFit(const Rectangle< float > &source, const Rectangle< float > &destination) const noexcept
Returns the transform that should be applied to these source coordinates to fit them into the destina...
@ stretchToFit
If this flag is set, then the source rectangle will be resized to completely fill the destination rec...
Manages a rectangle and allows geometric operations to be performed on it.
Rectangle< float > toFloat() const noexcept
Casts this rectangle to a Rectangle<float>.
Rectangle reduced(ValueType deltaX, ValueType deltaY) const noexcept
Returns a rectangle that is smaller than this one by a given amount.
A slider control for changing a value.
Definition juce_Slider.h:54
Slider()
Creates a slider.
void setRange(double newMinimum, double newMaximum, double newInterval=0)
Sets the limits that the slider's value can take.
The JUCE String class!
Definition juce_String.h:53
String toUpperCase() const
Returns an upper-case version of this string.
String paddedLeft(juce_wchar padCharacter, int minimumLength) const
Returns a copy of this string with the specified character repeatedly added to its beginning until th...
static String toHexString(IntegerType number)
Returns a string representing this numeric value in hexadecimal.
int getHexValue32() const noexcept
Parses the string as a hexadecimal number.
#define TRANS(stringLiteral)
Uses the LocalisedStrings class to translate the given string literal.
#define jassert(expression)
Platform-independent assertion macro.
#define JUCE_DECLARE_NON_COPYABLE(className)
This is a shorthand macro for deleting a class's copy constructor and copy assignment operator.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
#define jassertfalse
This will always cause an assertion failure.
typedef float
JUCE Namespace.
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
Returns true if the two floating-point numbers are approximately equal.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
NotificationType
These enums are used in various classes to indicate whether a notification event should be sent out.
@ dontSendNotification
No notification message should be sent.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
double getValueFromText(const String &text) override
Subclasses can override this to convert a text string to a value.
String getTextFromValue(double value) override
Turns the slider's current value into a text string.