public class LazyGui
extends java.lang.Object
Constructor and Description |
---|
LazyGui(processing.core.PApplet sketch)
Main constructor for the LazyGui object which acts as a central hub for all GUI related methods.
|
LazyGui(processing.core.PApplet sketch,
LazyGuiSettings settings)
Constructor for the LazyGui object which acts as a central hub for all GUI related methods.
|
Modifier and Type | Method and Description |
---|---|
boolean |
button(java.lang.String path)
Gets the value of a button control element and sets it to false.
|
void |
clearFolder()
Clears the global path prefix stack, removing all its elements.
|
PickerColor |
colorPicker(java.lang.String path)
Gets the color value of a color picker control element.
|
PickerColor |
colorPicker(java.lang.String path,
float grayNorm)
Gets the color value of a color picker control element.
|
PickerColor |
colorPicker(java.lang.String path,
float hueNorm,
float saturationNorm,
float brightnessNorm)
Gets the color value of a color picker control element.
|
PickerColor |
colorPicker(java.lang.String path,
float hueNorm,
float saturationNorm,
float brightnessNorm,
float alphaNorm)
Gets the color value of a color picker control element.
|
PickerColor |
colorPicker(java.lang.String path,
int hex)
Gets the color value of a color picker control element.
|
void |
colorPickerHueAdd(java.lang.String path,
float hueToAdd)
Adds hue to the color picker, looping it correctly in both directions at the [0,1] boundary.
|
void |
colorPickerSet(java.lang.String path,
int hex)
Sets the color picker to a given hex value.
|
ColorPoint |
colorPoint(int color,
float pos)
Helper function for calling `gui.gradient(String path, ColorPoint...
|
void |
createSave()
Creates a new, sequentially numbered save file in the gui save folder inside the sketch data folder.
|
void |
createSave(java.lang.String path)
Creates a new save file or overwrites an existing one while auto-detecting whether the parameter is a relative or an absolute path to it on disk.
|
void |
draw()
Updates and draws the GUI on the main processing canvas.
|
void |
draw(processing.core.PGraphics targetCanvas)
Updates and draws the GUI on the specified parameter canvas, assuming its size is identical to the main sketch size.
|
java.lang.String |
getFolder()
Gets the current path prefix stack, inserting a forward slash after each folder name in the stack.
|
processing.core.PGraphics |
getGuiCanvas()
Utility method for displaying the GUI before draw() ends for the purposes of recording.
|
processing.core.PFont |
getMainFont()
Gets the main font as currently used by the GUI.
|
processing.core.PFont |
getSideFont()
Gets the side font as currently used by the GUI.
|
java.lang.String |
getVersion()
Returns the current version of the library as a string in the format v{major}.{minor}.{patch} according to semantic versioning.
|
processing.core.PGraphics |
gradient(java.lang.String path)
Gets a gradient as an image with size matching the main processing sketch size.
|
processing.core.PGraphics |
gradient(java.lang.String path,
ColorPoint... colorPoints)
Gets a gradient as an image with size matching the main processing sketch size.
|
processing.core.PGraphics |
gradient(java.lang.String path,
int defaultHexColor)
Gets a gradient as an image with size matching the main processing sketch size.
|
processing.core.PGraphics |
gradient(java.lang.String path,
int[] defaultColors)
Gets a gradient as an image with size matching the main processing sketch size.
|
PickerColor |
gradientColorAt(java.lang.String path,
float position)
Gets a single color from a gradient at the specified position in the range [0, 1].
|
boolean |
hasChanged()
Returns whether the current folder or any of its recursively nested children changed last frame.
|
boolean |
hasChanged(java.lang.String path)
Returns whether a control element value, folder or any of its recursively nested children changed last frame.
|
void |
hide(java.lang.String path)
Hide any chosen element or folder except the root window.
|
void |
hideCurrentFolder()
Hides the folder at the current path prefix stack.
|
void |
hideGui()
Hides the GUI completely and skips displaying it.
|
void |
hideGuiToggle()
Hides the gui if it was visible.
|
static float |
hueModulo(float hue)
Hue values loop at the 1 - 0 border both in the positive and negative direction, just like two pi loops back to 0.
|
boolean |
isMouseOutsideGui()
Utility function to tell if the latest mouse event collided and interacted with the GUI.
|
boolean |
isMouseOverGui()
Utility function to tell if the latest mouse event collided and interacted with the GUI.
|
void |
loadSave(java.lang.String path)
Loads a save file from disk, overwriting the current values in the running gui whose gui paths match with the saved elements.
|
void |
plotSet(java.lang.String path,
float xyz)
Sets the vector value of a 2D grid control element with an extra z slider.
|
void |
plotSet(java.lang.String path,
float x,
float y)
Sets the vector value of a 2D control element.
|
void |
plotSet(java.lang.String path,
float x,
float y,
float z)
Sets the vector value of a 2D grid control element with an extra z slider.
|
void |
plotSet(java.lang.String path,
processing.core.PVector valueToSet)
Sets the vector value of a 2D grid control element with an extra z slider.
|
processing.core.PVector |
plotXY(java.lang.String path)
Gets the vector value of a 2D grid control element.
|
processing.core.PVector |
plotXY(java.lang.String path,
float defaultXY)
Gets the vector value of a 2D grid control element.
|
processing.core.PVector |
plotXY(java.lang.String path,
float defaultX,
float defaultY)
Gets the vector value of a 2D grid control element.
|
processing.core.PVector |
plotXY(java.lang.String path,
processing.core.PVector defaultXY)
Gets the vector value of a 2D grid control element.
|
processing.core.PVector |
plotXYZ(java.lang.String path)
Gets the vector value of a 2D grid control element with an extra z slider.
|
processing.core.PVector |
plotXYZ(java.lang.String path,
float defaultXYZ)
Gets the vector value of a 2D grid control element with an extra z slider.
|
processing.core.PVector |
plotXYZ(java.lang.String path,
float defaultX,
float defaultY,
float defaultZ)
Gets the vector value of a 2D grid control element with an extra z slider.
|
processing.core.PVector |
plotXYZ(java.lang.String path,
processing.core.PVector defaultXYZ)
Gets the vector value of a 2D grid control element with an extra z slider.
|
void |
popFolder()
Pops the last pushed folder name from the global path prefix stack.
|
void |
pushFolder(java.lang.String folderName)
Pushes a folder name to the global path prefix stack.
|
java.lang.String |
radio(java.lang.String path,
java.util.List<java.lang.String> options)
Gets the currently selected string from a list of options in a gui control element.
|
java.lang.String |
radio(java.lang.String path,
java.util.List<java.lang.String> options,
java.lang.String defaultOption)
Gets the currently selected string from a list of options in a gui control element.
|
java.lang.String |
radio(java.lang.String path,
java.lang.String[] options)
Gets the currently selected string from an array of options in a gui control element.
|
java.lang.String |
radio(java.lang.String path,
java.lang.String[] options,
java.lang.String defaultOption)
Gets the currently selected string from an array of options in a gui control element.
|
void |
radioSet(java.lang.String path,
java.lang.String optionToSet)
Sets the radio element value to a given parameter.
|
void |
radioSetOptions(java.lang.String path,
java.util.List<java.lang.String> optionsToSet)
Sets the radio options to a given list of strings, overwriting any existing list.
|
void |
radioSetOptions(java.lang.String path,
java.lang.String[] optionsToSet)
Sets the radio options to a given array of strings, overwriting any existing list.
|
void |
show(java.lang.String path)
Makes any control element or folder visible again if it has been hidden by the hide() function.
|
void |
showCurrentFolder()
Shows the folder at the current path prefix stack.
|
void |
showGui()
Shows the GUI if it was hidden with 'h' or hideGui().
|
float |
slider(java.lang.String path)
Gets the value of a float slider control element.
|
float |
slider(java.lang.String path,
float defaultValue)
Gets the value of a float slider control element.
|
float |
slider(java.lang.String path,
float defaultValue,
float min,
float max)
Gets the value of a float slider control element.
|
void |
sliderAdd(java.lang.String path,
float amountToAdd)
Adds a float to the value of a float or int slider control element manually at runtime without requiring user interaction.
|
int |
sliderInt(java.lang.String path)
Gets the value of an integer slider control element.
|
int |
sliderInt(java.lang.String path,
int defaultValue)
Gets the value of an integer slider control element.
|
int |
sliderInt(java.lang.String path,
int defaultValue,
int min,
int max)
Gets the value of an integer slider control element.
|
void |
sliderIntSet(java.lang.String path,
int value)
Sets the value of an integer slider control element manually at runtime without requiring user interaction.
|
void |
sliderSet(java.lang.String path,
float value)
Sets the value of a float slider control element manually at runtime without requiring user interaction.
|
java.lang.String |
text(java.lang.String path)
Gets the current value of a text input element.
|
java.lang.String |
text(java.lang.String path,
java.lang.String content)
Gets the current value of an editable text field element.
|
void |
textSet(java.lang.String path,
java.lang.String content)
Sets the current value of an editable text field element.
|
boolean |
toggle(java.lang.String path)
Gets the current value of a toggle control element.
|
boolean |
toggle(java.lang.String path,
boolean defaultValue)
Gets the current value of a toggle control element.
|
void |
toggleSet(java.lang.String path,
boolean value)
Sets the value of a boolean toggle control element.
|
public LazyGui(processing.core.PApplet sketch)
new LazyGui(this)
.
Registers itself at end of the draw() method and displays the GUI whenever draw() ends.sketch
- the sketch that uses this gui, should be 'this' from the calling sidepublic LazyGui(processing.core.PApplet sketch, LazyGuiSettings settings)
new LazyGui(this)
.
Registers itself at end of the draw() method and displays the GUI whenever draw() ends.sketch
- main processing sketch class to display the GUI on and use keyboard and mouse input fromsettings
- settings to apply (loading a save on startup will overwrite them)LazyGuiSettings
public processing.core.PGraphics getGuiCanvas()
public void draw()
draw(PGraphics)
internally with the default sketch PGraphics.draw(PGraphics)
public void draw(processing.core.PGraphics targetCanvas)
Resets any potential hint(DISABLE_DEPTH_TEST) to the default hint(ENABLE_DEPTH_TEST) when done, because it needs the DISABLE_DEPTH_TEST to draw the GUI over 3D scenes and has currently no way to save or query the original hint state.
targetCanvas
- canvas to draw the GUI onpublic boolean isMouseOutsideGui()
public boolean isMouseOverGui()
public float slider(java.lang.String path)
path
- forward slash separated unique path to the control elementpublic float slider(java.lang.String path, float defaultValue)
path
- forward slash separated unique path to the control elementdefaultValue
- default value to set the slider topublic float slider(java.lang.String path, float defaultValue, float min, float max)
path
- forward slash separated unique path to the control elementdefaultValue
- the default value, ideally between min and maxmin
- the value cannot go below this, min < max must be truemax
- the value cannot go above this, max > min must be truepublic void sliderSet(java.lang.String path, float value)
path
- forward slash separated unique path to the control elementvalue
- value to set the float slider at the path topublic void sliderAdd(java.lang.String path, float amountToAdd)
path
- forward slash separated unique path to the control elementamountToAdd
- value to set the float slider at the path topublic int sliderInt(java.lang.String path)
path
- forward slash separated unique path to the control elementpublic int sliderInt(java.lang.String path, int defaultValue)
path
- forward slash separated unique path to the control elementdefaultValue
- default value to set the slider topublic int sliderInt(java.lang.String path, int defaultValue, int min, int max)
path
- forward slash separated unique path to the control elementdefaultValue
- the default value, ideally between min and maxmin
- the value cannot go below this, min < max must be truemax
- the value cannot go above this, max > min must be truepublic void sliderIntSet(java.lang.String path, int value)
path
- forward slash separated unique path to the control elementvalue
- value to set the float slider at the path topublic processing.core.PVector plotXY(java.lang.String path)
path
- forward slash separated unique path to the plot control elementpublic processing.core.PVector plotXY(java.lang.String path, float defaultXY)
path
- forward slash separated unique path to the plot control elementdefaultXY
- default xy valuepublic processing.core.PVector plotXY(java.lang.String path, float defaultX, float defaultY)
path
- forward slash separated unique path to the plot control elementdefaultX
- default x valuedefaultY
- default y valuepublic processing.core.PVector plotXY(java.lang.String path, processing.core.PVector defaultXY)
path
- forward slash separated unique path to the plot control elementdefaultXY
- default xy values, z value is ignoredpublic processing.core.PVector plotXYZ(java.lang.String path)
path
- forward slash separated unique path to the plot control elementpublic processing.core.PVector plotXYZ(java.lang.String path, float defaultXYZ)
path
- forward slash separated unique path to the plot control elementdefaultXYZ
- default xyz valuespublic processing.core.PVector plotXYZ(java.lang.String path, float defaultX, float defaultY, float defaultZ)
path
- forward slash separated unique path to the plot control elementdefaultX
- default x valuedefaultY
- default y valuedefaultZ
- default z valuepublic processing.core.PVector plotXYZ(java.lang.String path, processing.core.PVector defaultXYZ)
path
- forward slash separated unique path to the plot control elementdefaultXYZ
- default xyz valuespublic void plotSet(java.lang.String path, float xyz)
path
- forward slash separated unique path to the plot control elementxyz
- value to set to each axispublic void plotSet(java.lang.String path, float x, float y)
path
- forward slash separated unique path to the plot control elementx
- x value to sety
- y value to setpublic void plotSet(java.lang.String path, float x, float y, float z)
path
- forward slash separated unique path to the plot control elementx
- x value to sety
- y value to setz
- z value to setpublic void plotSet(java.lang.String path, processing.core.PVector valueToSet)
path
- forward slash separated unique path to the plot control elementvalueToSet
- vector value to setpublic boolean toggle(java.lang.String path)
path
- forward slash separated unique path to the control element.public boolean toggle(java.lang.String path, boolean defaultValue)
path
- forward slash separated unique path to the control elementdefaultValue
- default value of the togglepublic void toggleSet(java.lang.String path, boolean value)
path
- forward slash separated unique path to the control elementvalue
- current value of the togglepublic boolean button(java.lang.String path)
if(gui.button("actions/print")){ println("hello world"); }
path
- forward slash separated unique path to the control elementpublic java.lang.String radio(java.lang.String path, java.util.List<java.lang.String> options)
path
- forward slash separated unique path to the control elementoptions
- list of options to displaypublic java.lang.String radio(java.lang.String path, java.util.List<java.lang.String> options, java.lang.String defaultOption)
path
- forward slash separated unique path to the control elementoptions
- list of options to displaydefaultOption
- default option to select, which must also be found in the options, or it will be ignoredpublic java.lang.String radio(java.lang.String path, java.lang.String[] options)
path
- forward slash separated unique path to the control elementoptions
- list of options to displaypublic java.lang.String radio(java.lang.String path, java.lang.String[] options, java.lang.String defaultOption)
path
- forward slash separated unique path to the control elementoptions
- list of options to displaydefaultOption
- default option to select, must also be found in options, or it is ignoredpublic void radioSet(java.lang.String path, java.lang.String optionToSet)
path
- forward slash separated unique path to the control elementoptionToSet
- string option to set the radio element topublic void radioSetOptions(java.lang.String path, java.util.List<java.lang.String> optionsToSet)
path
- forward slash separated unique path to the control elementoptionsToSet
- list of options to setpublic void radioSetOptions(java.lang.String path, java.lang.String[] optionsToSet)
path
- forward slash separated unique path to the control elementoptionsToSet
- list of options to setpublic PickerColor colorPicker(java.lang.String path)
path
- forward slash separated unique path to the control elementpublic PickerColor colorPicker(java.lang.String path, float grayNorm)
path
- forward slash separated unique path to the control elementgrayNorm
- default brightness in the range [0,1]public PickerColor colorPicker(java.lang.String path, float hueNorm, float saturationNorm, float brightnessNorm)
path
- forward slash separated unique path to the control elementhueNorm
- default hue in the range [0,1]saturationNorm
- default saturation in the range [0,1]brightnessNorm
- default brightness in the range [0,1]public PickerColor colorPicker(java.lang.String path, float hueNorm, float saturationNorm, float brightnessNorm, float alphaNorm)
path
- forward slash separated unique path to the control elementhueNorm
- default hue in the range [0,1]saturationNorm
- default saturation in the range [0,1]brightnessNorm
- default brightness in the range [0,1]alphaNorm
- default alpha in the range [0,1]public PickerColor colorPicker(java.lang.String path, int hex)
path
- forward slash separated unique path to the control elementhex
- hex color as an integer like 0xFF123456, also works with processing 'color' typepublic void colorPickerSet(java.lang.String path, int hex)
path
- forward slash separated unique path to the control elementhex
- hex color to set, also works with processing 'color' typepublic void colorPickerHueAdd(java.lang.String path, float hueToAdd)
path
- forward slash separated unique path to the control elementhueToAdd
- hue to add, with the hue value being normalized to the range [0,1]public static float hueModulo(float hue)
hue
- value to transfer to the [0-1] range without changing apparent color valuepublic java.lang.String text(java.lang.String path)
path
- forward slash separated unique path to the control elementpublic java.lang.String text(java.lang.String path, java.lang.String content)
path
- forward slash separated unique path to the control elementcontent
- default value for the text contentpublic void textSet(java.lang.String path, java.lang.String content)
path
- forward slash separated unique path to the control elementcontent
- default value for the text contentpublic processing.core.PGraphics gradient(java.lang.String path)
path
- forward slash separated unique path to the control elementpublic processing.core.PGraphics gradient(java.lang.String path, int defaultHexColor)
path
- forward slash separated unique path to the control elementdefaultHexColor
- the same default color for the 4 default color stopspublic processing.core.PGraphics gradient(java.lang.String path, int[] defaultColors)
path
- forward slash separated unique path to the control elementdefaultColors
- default color array for all the colors in the gradient
if you're pasting colors in the format of #ef8e38 try replacing # with 0xFFpublic ColorPoint colorPoint(int color, float pos)
color
- hex color such as 0xFF123456, also works with processing 'color' typepos
- floating point position on the gradient between 0 and 1public processing.core.PGraphics gradient(java.lang.String path, ColorPoint... colorPoints)
path
- forward slash separated unique path to the control elementcolorPoints
- varargs of ColorPoint - the position should be between 0 and 1public PickerColor gradientColorAt(java.lang.String path, float position)
path
- forward slash separated unique path to the control elementposition
- normalized position in the [0, 1] range you'd like to know the color ofpublic boolean hasChanged()
public boolean hasChanged(java.lang.String path)
path
- forward slash separated unique path to the control elementpublic void pushFolder(java.lang.String folderName)
folderName
- one folder's name to push to the stackgetFolder()
public void popFolder()
public void clearFolder()
public java.lang.String getFolder()
public void hide(java.lang.String path)
path
- path to the control or folder being hidden - it will get prefixed by the current path prefix stack to get the full pathpublic void hideCurrentFolder()
hide(String path)
public void show(java.lang.String path)
path
- path to the control element or folder being hidden - it will get prefixed by the current path prefix stack to get the full pathpublic void showCurrentFolder()
show(String path)
public void createSave()
public void createSave(java.lang.String path)
path
- name of the new save file or its entire absolute path, ".json" file type suffix is optional and will be appended if missingpublic void loadSave(java.lang.String path)
path
- name of the existing save file inside the save folder or its entire absolute path, ".json" file type suffix is optional and will be appended if missingpublic processing.core.PFont getMainFont()
public processing.core.PFont getSideFont()
public void hideGui()
public void hideGuiToggle()
public void showGui()
public java.lang.String getVersion()