Backdrop Class Reference

The Backdrop JavaScript global object. Get, set and add backdrops. More...

Public Slots

QScriptValue backdrops (String &groupPath)
 Returns the backdrops of a group. More...
 
bool setBackdrops (String &groupPath, QScriptValue &backdrops)
 Sets the backdrops for the specified group. More...
 
QScriptValue addBackdrop (String &groupPath, QScriptValue &backdrop)
 Adds a single backdrop. The new backdrop is displayed on top of all the others. More...
 
bool removeBackdrop (QScriptValue &backdrop)
 Removes a single backdrop. More...
 
bool removeBackdrop (String &groupPath, uint idx)
 Removes a single backdrop. More...
 
QScriptValue nodes (QScriptValue &backdrop)
 Provides a list of all nodes contained within a backdrop. More...
 
bool contains (QScriptValue &backdrop, QScriptValue &node)
 Returns true if a node is contained in the backdrop. More...
 

Detailed Description

The Backdrop JavaScript global object. Get, set and add backdrops.

The Backdrop methods sometimes use backdrop JavaScript objects which are described as follows:

{
"position" : {"x":-1030, "y":-1191, "w":376, "h":284},
"title" : {"text":"HAIR", "color":4278190080,"size":14, "font":"Arial"},
"description" : {"text":"This backdrop include all the modules of hair.\n", "color":4278190080, "size":14, "font":"Arial"},
"color" : 4286859713
}

Color is a integer representation of a RGBA value. It can be obtained with the following computation.

function fromRGBAtoInt(r, g, b, a)
{
return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff);
}

Here's an example demonstrating how to customize a backdrop

// Get every backdrop in my group.
var myGroupPath = "Top/MyGroup";
var myBackdrops = Backdrop.backdrops(myGroupPath);
for(var i=0; i<myBackdrops.length; i++)
{
if(myBackdrops[i].title.text == "MyBackdrop")
{
myBackdrops[i].color = fromRGBAtoInt(0, 0, 255, 255);
}
}
// Replace the original backdrops with their edited version.
Backdrop.setBackdrops(myGroupPath, myBackdrops);

Member Function Documentation

◆ addBackdrop

QScriptValue Backdrop::addBackdrop ( String &  groupPath,
QScriptValue &  backdrop 
)
slot

Adds a single backdrop. The new backdrop is displayed on top of all the others.

var myBackdrop =
{
"position" : {"x": -100, "y" :-100, "w":300, "h":300},
"title" : {"text" : "My Title", "color" : fromRGBAtoInt(255, 100, 100, 255), "size" : 14, "font" : "Arial"},
"description" : {"text" : "This is a new backdrop that will include the node covered by its area.\n", "color" : fromRGBAtoInt(100, 255, 100, 255), "size" : 14, "font" : "Arial"},
"color" : fromRGBAtoInt(100, 100, 0, 255)
};
Backdrop.addBackdrop("Top/MyGroup", myBackdrop);
Parameters
groupPath: The full qualified group node path.
backdrop: A backdrop JavaScript object, as described in the Backdrop class description.
Returns
Returns the backdrop object that was added to the group, similar to the provided backdrop, but contains the group and can be used to reference the backdrop in other methods.

◆ backdrops

QScriptValue Backdrop::backdrops ( String &  groupPath)
slot

Returns the backdrops of a group.

This method returns an array of JavaScript objects where each object represent a single backdrop. Since backdrop do not have keys/unique ID, all backdrops are returned in the order they are defined in the group. The group node's path must be provided as input.

Parameters
groupPath: The full qualified group node path.
Returns
Returns an array of backdrop object.

◆ contains

bool Backdrop::contains ( QScriptValue &  backdrop,
QScriptValue &  node 
)
slot

Returns true if a node is contained in the backdrop.

Parameters
backdrop: The backdrop object, provided from Backdrop.backdrops( groupPath ).
node: The node or nodes to search for within the backdrop.
Returns
Returns true if all nodes are contained in the backdrop, false otherwise.

◆ nodes

QScriptValue Backdrop::nodes ( QScriptValue &  backdrop)
slot

Provides a list of all nodes contained within a backdrop.

Parameters
backdrop: The backdrop object, provided from Backdrop.backdrops( groupPath ).
Returns
Returns the list of nodes contained within the backdrop.

◆ removeBackdrop [1/2]

bool Backdrop::removeBackdrop ( QScriptValue &  backdrop)
slot

Removes a single backdrop.

Parameters
backdrop: A backdrop JavaScript object, as described in the Backdrop class description.

◆ removeBackdrop [2/2]

bool Backdrop::removeBackdrop ( String &  groupPath,
uint  idx 
)
slot

Removes a single backdrop.

Parameters
backdrop: A backdrop JavaScript object, as described in the Backdrop class description.
idx: Remove the backdrop at the given index in the group's backdrop list.

◆ setBackdrops

bool Backdrop::setBackdrops ( String &  groupPath,
QScriptValue &  backdrops 
)
slot

Sets the backdrops for the specified group.

This replaces all the backdrops in the group. The backdrop is in the format as the array returned by 'Backdrop.backdrops(groupPath). The code will parse the JavaScript object, as described in the Backdrop class description.

Parameters
groupPath: The full qualified group node path.
backdrops: An array of backdrop objects or a single backdrop object. See the Backdrop class description for information on the backdrop object.
Returns
Returns true if the operation was done on a valid group.