Docs

ScriptPanel


Class methods

addChildPanel

Adds a child panel to this panel.

ScriptPanel.addChildPanel()


This function will create and return an anonymous panel and add it to the panel as child component (similar to setting the parentComponent property). However there are two important differences:

  1. You can call this function any time and add (and remove) these panels after the onInit callback.
  2. The panels that you create with this method will not be listed in the component list (and therefore can not store / restore their value with user presets et al).

The main use case for this method is to create dynamic components which have a varying amount of sub-elements: tables with modulation connections, effect slots, and basically anything that has a dynamic amount that can be changed in your script.

Be aware that these panels are not accessible to the interface designer, so you have to set every property using scripting API calls.

You can call this method again on the new panel and create a nested architecture of child panels. In order to delete the panel (and any child panel), use the removeFromParent() method.

For an example use case, take a look at the Horizontal List Recipe

addToMacroControl

Adds the knob / button to a macro controller (from 0 to 7).

ScriptPanel.addToMacroControl(int macroIndex)



changed

Call this to indicate that the value has changed (the onControl callback will be executed.

ScriptPanel.changed()



closeAsPopup

Closes the popup manually.

ScriptPanel.closeAsPopup()



get

returns the value of the property.

ScriptPanel.get(String propertyName)



getAllProperties

Returns a list of all property IDs as array.

ScriptPanel.getAllProperties()



getAnimationData

Returns a JSON object containing the data of the animation object.

ScriptPanel.getAnimationData()


This method will return an object containing the properties of the current animation in this panel:

Property Description
active whether an animation is active. This might be false if the animation couldn't be loaded.
currentFrame the current frame that is displayed. You can use this in the timer callback to increase it in order to create a moving image.
numFrames the total number of frames in this animation.
frameRate the suggested framerate. You don't need to use this value, but you might want to call Panel.startTimer(1000.0 / data.frameRate) with it.

These properties will be updated if you load another animation or change the frame, so you just need to call this method once and then access its properties.


getChildPanelList

Returns a list of all panels that have been added as child panel.

ScriptPanel.getChildPanelList()


This creates an array with references to all panels that have been created using addChildPanel() . Be aware that this only takes one level of hierarchy into account, so if you have nested child panels, the list will only contain the top level panels.

See addChildPanel() , getParentPanel() and removeFromParent()

getGlobalPositionX

Returns the absolute x-position relative to the interface.

ScriptPanel.getGlobalPositionX()



getGlobalPositionY

Returns the absolute y-position relative to the interface.

ScriptPanel.getGlobalPositionY()



getHeight

Returns the height of the component.

ScriptPanel.getHeight()



getParentPanel

Returns the panel that this panel has been added to with addChildPanel.

ScriptPanel.getParentPanel()



getValue

Returns the current value.

ScriptPanel.getValue()



getValueNormalized

Returns the normalized value.

ScriptPanel.getValueNormalized()



getWidth

Returns the width of the component.

ScriptPanel.getWidth()



isVisibleAsPopup

Returns true if the popup is currently showing.

ScriptPanel.isVisibleAsPopup()



loadImage

Loads a image which can be drawn with the paint function later on.

ScriptPanel.loadImage(String imageName, String prettyName)



removeFromParent

Removes the panel from its parent panel if it was created with addChildPanel().

ScriptPanel.removeFromParent()


If you want to remove a panel from the interface that has been created with addChildPanel() , call this method and it will remove the panel from the parent and update the UI.

repaint

Triggers an asynchronous repaint.

ScriptPanel.repaint()



repaintImmediately

Calls the paint routine immediately.

ScriptPanel.repaintImmediately()



set

Sets the property.

ScriptPanel.set(String propertyName, var value)



setAnimation

Sets an JSON animation.

ScriptPanel.setAnimation(String base64LottieAnimation)


You can use Lottie animation files to be displayed in a ScriptPanel.

Just load an animation into the Lottie Developer Panel , compress it to a Base64 string and give it to this method and you can start using the frames inside the animation with setAnimationFrame .

Be aware that there is no built in animation functionality, but you can easily create "moving images" by using the timer callback for it.

setAnimationFrame

Sets a frame to be displayed.

ScriptPanel.setAnimationFrame(int numFrame)


Once you've loaded an animation into the panel with setAnimation , you can call this method and supply the frame index you want to display.
Calling this method will pick the frame and immediately repaint the panel.

In order to find out, which frame you want to display, use the getAnimationData method which returns an object with the animation specs.


setColour

sets the colour of the component (BG, IT1, IT2, TXT).

ScriptPanel.setColour(int colourId, int colourAs32bitHex)



setControlCallback

Pass a inline function for a custom callback event.

ScriptPanel.setControlCallback(var controlFunction)



setDraggingBounds

If allowedDragging is enabled, it will define the boundaries where the panel can be dragged.

ScriptPanel.setDraggingBounds(var area)



setImage

Disables the paint routine and just uses the given (clipped) image.

ScriptPanel.setImage(String imageName, int xOffset, int yOffset)



setIsModalPopup

If this is set to true, the popup will be modal with a dark background that can be clicked to close.

ScriptPanel.setIsModalPopup(bool shouldBeModal)



setLoadingCallback

Sets a loading callback that will be called when the preloading starts or finishes.

ScriptPanel.setLoadingCallback(var loadingCallback)


The loading of samples will be executed asynchronously on a background thread (in fact the same thread used for streaming the samples).

If you call Sampler.loadSampleMap() or any other function that changes the sample content, it will kill all voices, load it on the background thread.

If you want your UI to reflect this behaviour, you can use a ScriptPanel as "loading indicator". Just register a function with this method and change the appearance accordingly:

// Example: Preloading callback
// this code will add a panel which will flash white during the preloading of new samples.

const var panel = Content.addPanel("Panel", 0, 0);

panel.data.colour = Colours.grey;

panel.setPaintRoutine(function(g)
{
	g.fillAll(this.data.colour);
});

// This function will be executed whenever the preload state changes
panel.setLoadingCallback(function(isPreloading)
{
	if(isPreloading)
        this.data.colour = Colours.white;
    else
        this.data.colur = Colours.grey;
        
    // Update the UI
    this.repaint();
});


setMouseCallback

Sets a mouse callback.

ScriptPanel.setMouseCallback(var mouseCallbackFunction)



setMouseCursor

Sets a Path as mouse cursor for this panel.

ScriptPanel.setMouseCursor(var pathIcon, var colour, var hitPoint)



setPaintRoutine

Sets a paint routine (a function with one parameter).

ScriptPanel.setPaintRoutine(var paintFunction)



setPopupData

Sets a FloatingTile that is used as popup. The position is a array [x , y, width, height] that is used for the popup dimension

ScriptPanel.setPopupData(var jsonData, var position)



setPosition

Sets the position of the component.

ScriptPanel.setPosition(int x, int y, int w, int h)



setPropertiesFromJSON

Restores all properties from a JSON object.

ScriptPanel.setPropertiesFromJSON( var jsonData)



setTimerCallback

Sets a timer callback.

ScriptPanel.setTimerCallback(var timerCallback)



setTooltip

Shows a informative text on mouse hover.

ScriptPanel.setTooltip( String tooltip)



setValue

Sets the current value

ScriptPanel.setValue(var newValue)



setValueNormalized

Sets the current value from a range 0.0 ... 1.0.

ScriptPanel.setValueNormalized(double normalizedValue)



setValueWithUndo

Sets the current value and adds it to the undo list. Don't call this from onControl!

ScriptPanel.setValueWithUndo(var newValue)



setValueWithUndo

Sets a new value, stores this action in the undo manager and calls the control callbacks.

ScriptPanel.setValueWithUndo(var oldValue, var newValue, var actionName)



showAsPopup

Opens the panel as popup.

ScriptPanel.showAsPopup(bool closeOtherPopups)



showControl

Hides / Shows the control.

ScriptPanel.showControl(bool shouldBeVisible)



updateContentPropertyInternal

This updates the internal content data object from the script processor.

ScriptPanel.updateContentPropertyInternal(int propertyId,  var newValue)