JUCE: misc

JUCE

Macros
misc
juce_gui_extra

## Macros
#define | JUCE_LIVE_CONSTANT(initialValue) (juce::LiveConstantEditor::getValue (__FILE__, __LINE__ - 1, initialValue).get())
| This macro wraps a primitive constant value in some cunning boilerplate code that allows its value to be interactively tweaked in a popup window while your application is running. More...

## Detailed Description

## Macro Definition Documentation

## ◆ JUCE_LIVE_CONSTANT

#define JUCE_LIVE_CONSTANT | ( |  | initialValue | ) | (juce::LiveConstantEditor::getValue (__FILE__, __LINE__ - 1, initialValue).get())

This macro wraps a primitive constant value in some cunning boilerplate code that allows its value to be interactively tweaked in a popup window while your application is running.

In a release build, this macro disappears and is replaced by only the constant that it wraps, but if JUCE_ENABLE_LIVE_CONSTANT_EDITOR is enabled, it injects a class wrapper that automatically pops-up a window containing an editor that allows the value to be tweaked at run-time. The editor window will also force all visible components to be resized and repainted whenever a value is changed, so that if you use this to wrap a colour or layout parameter, you'll be able to immediately see the effects of changing it.

The editor will also load the original source-file that contains each JUCE_LIVE_CONSTANT macro, and will display a preview of the modified source code as you adjust the values.

Things to note:

- Only one of these per line! The FILE and LINE macros are used to identify the value, so things will get confused if you have more than one per line
- Obviously because it needs to load the source code based on the FILE macro, it'll only work if the source files are stored locally in the same location as they were when you compiled the program.
- It's only designed to cope with simple types: primitives, string literals, and the Colour class, so if you try using it for other classes or complex expressions, good luck!
- The editor window will get popped up whenever a new value is used for the first time. You can close the window, but there's no way to get it back without restarting the app!

e.g. in this example the colours, font size, and text used in the paint method can all be adjusted live:

void MyComp::paint (Graphics& g) override
{
g.fillAll (JUCE_LIVE_CONSTANT (Colour (0xffddddff)));
Colour fontColour = JUCE_LIVE_CONSTANT (Colour (0xff005500));
float fontSize = JUCE_LIVE_CONSTANT (16.0f);
g.setColour (fontColour);
g.setFont (fontSize);
g.drawFittedText (JUCE_LIVE_CONSTANT ("Hello world!"),
getLocalBounds(), Justification::centred, 2);
}
Colour
Represents a colour, also including a transparency value.
Definition: juce_Colour.h:39
JUCE_LIVE_CONSTANT
#define JUCE_LIVE_CONSTANT(initialValue)
This macro wraps a primitive constant value in some cunning boilerplate code that allows its value to...
Definition: juce_LiveConstantEditor.h:300
Graphics
A graphics context, used for drawing a component or image.
Definition: juce_GraphicsContext.h:46
Graphics::fillAll
void fillAll() const
Fills the context's entire clip region with the current colour or brush.
Justification::centred
@ centred
Indicates that the item should be centred vertically and horizontally.
Definition: juce_Justification.h:140
Graphics::setFont
void setFont(const Font &newFont)
Changes the font to use for subsequent text-drawing functions.
Graphics::drawFittedText
void drawFittedText(const String &text, int x, int y, int width, int height, Justification justificationFlags, int maximumNumberOfLines, float minimumHorizontalScale=0.0f) const
Tries to draw a text string inside a given space.
Graphics::setColour
void setColour(Colour newColour)
Changes the current drawing colour.