Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The roSGNode object is the BrightScript equivalent of Scene Graph XML file node creation. To create an roSGNode object for a specific node class, call:

CreateObject("roSGNode", "nodetype")

Where nodetype is a string specifying the node class to be created. For example, the following creates an object of the Scene Graph Poster node class:

CreateObject("roSGNode", "Poster")

Reference information on all Scene Graph node classes can be found in Scene Graph Reference.

Prior to creating an roSGScreen object and calling its show() function, creating roSGNode objects and using their interfaces is not guaranteed to work correctly. If you need to create some roSGNode objects and/or use roSGNode interfaces prior to calling an roSGScreen object show() function, you can use an roSGScreen object createScene() function to create an instance of a Scene Graph XML component that does any required setup and initialization prior to the roSGScreen object being displayed (TBD see below for more details about XML components TBD below is where exactly? TBD).

TBD put best practices BrightScript code here? TBD

Supported Interfaces

roSGNode objects implement five main interfaces:

  • ifSGNodeChildren - used to query and manipulate the child-parent relationship of nodes
  • ifSGNodeField - used to query and manipulate fields of a node
  • ifSGNodeDict - used to lookup a node from its ID (the value of its id field), and query the node class metadata
  • ifSGNodeFocus - used to query and manipulate the keyboard focus of the Scene Graph
  • ifSGNodeBoundingRect - used to query the bounding rectangle of the node

In addition, roSGNode implements ifAssociativeArray as wrapper for ifSGNodeFIeld so that the convenient node.field notation may be using for setting, getting, and observing fields TBD if style TBD.

The following describes each of these interfaces in detail.

ifSGNodeChildren

TBD  Note that functions that cause a node to be removed or replaced in the Scene Graph can cause that node to be destroyed entirely if there are no more references to it. TBD

Supported Methods

TBD

Description of Methods 

appendChild(child as roSGNode)

TBD Add child node to the end of the subject node's list of children so that it is traversed last (of those children) during render. TBD

createChild(nodeType as String) as Object

TBD Create a child Node of type nodeType and add it to the end of the subject Node's list of children. TBD

insertChild(child as roSGNode, index as Integer)

TBD Insert 'child' node at position index in the subject node's list of children so that this is the position that child is traversed during render. TBD

removeChild(child as roSGNode)

TBD Find child in the subject node's list of children, and if found, remove it from the list. The match is made on the basis of actual object identity, i.e., the value of the pointer. TBD

removeChildIndex(index as Integer)

TBD If the subject node has a child in the index position, remove that child from the subject node's list of children. TBD

replaceChild(newChild as roSGNode, index as Integer)

TBD If the subject node has a child in the index position, replace that child with newChild in the subject node's list of children, otherwise do nothing. TBD

getChild(index as Integer) as roSGNode

TBD If the subject node has a child at the index position, return it, otherwise return invalid. TBD

getParent() as roSGNode

TBD If the subject node has been added to a parent node's list of children, return the parent node, otherwise return invalid. TBD

getChildCount() as Integer

TBD Return the current number of children in the subject node's list. This is always non-negative. TBD

ifSGNodeField

TBD

Member Functions

TBD

hasField(name as String) as Boolean

TBD Return true if the subject node has a field whose name exactly matches name or whose fully lowercase analog is identical to that of name. Return false otherwise. TBD

getField(name as String) as Object

TBD Return the approproiately typed value corresponding to the subject nodes's field named name. (Note: getField() can also be called using node.field syntax (i.e. rect.getField("translation" is equivalent to rect.translation) ) TBD

setField(name as String, value as Object)

TBD Set the value of subject node's field named name to value. This will fail and stop script execution if value is not of the appropriate type. (Note: setField() can also be called using node.field syntax (i.e. rect.setField("opacity", 0.5) is equivalent to rect.opacity = 0.5) TBD

setFields(aa as Object)

TBD Set the values of subject node's fields indicated by the corresponding key. TBD

observeField(name as String,  port as roMessagePort)

TBD This will create a connection from the subject node's field named name to the given port. A "roSGNodeEvent" with the node's id and the field's name will be posted to 'port' each time the corresponding field's value changes. TBD

unobserveField(name as String)

TBD Remove the previously established connections between the node's field names name and all ports which were observing that node's field. TBD

ifSGNodeDict

TBD 

Member Functions

TBD

findNode(name as String) as Object

TBD Return the node that is a descendant of the subject node and whose id Field is set to name. (Note: the intent is for id to be unique in this context, but the first node matched in a top-down, first child to last child traversal will be returned). TBD

subtype() as String

TBD Return the subtype of the subject node as specified when it was created. TBD

parentSubtype(nodeType as String) as String

TBD Return the subtype of the parent of nodeType in the Scene Graph class hierarchy. (Note: this call does not actually reference the subject node). TBD

isSubtype(nodeType as String) as Boolean

TBD Return true if the subtype of the subject node is a descendant of the subtype nodeType in the Scene Graph class hierarchy. (Note: this call does actually reference the subject node). TBD

ifSGNodeFocus

TBD 

Member Functions

TBD

setFocus(on as Boolean) as Boolean

TBD If on is true, set the current UI focus to the subject node, also automatically removing it from the node on which it was previously set. If on is false, remove focus from the subject node if it had it. setFocus(false) is rarely necessary, and can lead to unexpected behavior. TBD

hasFocus() as Boolean

TBD Return true if the subject node has the UI focus and false otherwise. TBD

isInFocusChain() as Boolean

TBD Return true if the subject node or any of its descendants in the Scene Graph has the UI focus. TBD

ifSGNodeBoundingRect

TBD 

Member Functions

TBD

localBoundingRect() as Object

TBD Return the node's local bounding rectangle as an associative array with four elements:  

  • 'x' – the x-coordinate of the origin of the local bounding rectangle
  • 'y' – the y-coordinate of the origin of the local bounding rectangle
  • 'width' – the width of the local bounding rectangle
  • 'height' – the height of the local bounding rectangle

The local bounding rectangle of a node is the axis-aligned rectangle that includes the union of the bounding rectangle of the geometry of the node and the bounding rectangles of all of the node's children transformed into the local coordinate system of the node TBD

boundingRect() as Object

TBD Return the node's bounding rectangle as an associative array with four elements:

  • 'x' – the x-coordinate of the origin of the bounding rectangle
  • 'y' – the y-coordinate of the origin of the bounding rectangle
  • 'width' – the width of the bounding rectangle
  • 'height' – the height of the bounding rectangle

The bounding rectangle of a node is the axis-aligned rectangle computed by transforming the local bounding rectangle of the node by the node's transformation matrix. The resulting rectangle corresponds to the node's local bounding rectangle transformed into its parent node's local coordinate system. TBD

 

  • No labels