Skip to content

Object Structure Tutorial

Benedict Allen edited this page Nov 15, 2015 · 4 revisions

Object Structure Tutorial

Overview

The object structure of Sheets looks like this:

Application
    Screen
        Sheet

The root node of any application is an Application. Applications contain Screens, which in turn contain Sheets. Sheets are the graphical components of an application. Screens are what put the Sheets onto various displays, and the Application is the thing that manages everything, including events.

In addition to this, Sheets can contain other Sheets. A notable example of this is the Container class. It is specifically designed to correctly render and handle child elements, and offers almost no functionality on its own. This allows for wide, diverse, and complex object structures.

Parenting

An object's 'parent' is the object that contains it, for example, the Application that contains a Screen, or the Container than contains a Sheet. Its parent can be accessed with .parent. An object's 'children' is the set of objects that it contains, for example every Sheet a Container contains.

The terms 'parent' and 'child' will be used extensively throughout the tutorials, so it's good to get a good grasp of what they mean now.

Take the following structure as an example:

Application
    Screen
        Container 1
            Button
        Container 2
            ScrollContainer
                Text 1
                Text 2
                Checkbox
                Button

The ScrollContainer's parent is Container 2, and Container 2's first child is the ScrollContainer.

Order of children

The order in which children are shown is important. All children with the same z value are in a "last added, last drawn, first to get events" order, and children with different z values are in a "higher z, last drawn, first to get events" order. Essentially, children with lower Z index values are drawn at first (to make them appear behind others) and get events last (because objects above the current object should receive events first). If two or more children share the same Z index value, they are ordered in the same way they were added. To speed things up, the order of children is only calculated when a child is added, removed, or has its z changed.

Clone this wiki locally