JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce_LiveConstantEditor.h File Reference
This graph shows which files directly or indirectly include this file:

Namespaces

 juce
 

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...
 

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);
}
juce::gl::f
GLdouble f
Definition: juce_gl.h:685
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:298
juce::gl::g
GLboolean GLboolean g
Definition: juce_gl.h:1931
juce::gl::fontSize
GLenum GLsizeiptr fontSize
Definition: juce_gl.h:9841