Skip to content

UXRscDoc

UXRscDoc is a GEM resource held as objects: what Rocks edits and what UXRsc loads from. From 0.7 (earlier it was part of Rocks).

#import "UXRscModel.xc"

A document is a list of trees. Each tree is a root UXRscObject with nested children, in the classic OBJECT fields: type, flags, state, geometry relative to the parent, and a payload by type (a string, a TEDINFO, a box colour word, an icon).

A form is one piece of UI as an application sees it. When a form has more than one layout, it is a UXRscForm whose variants each hold a whole tree for one theme: a form factor and, on a device, an orientation. The trees are separate designs. What ties them together is the logical id each control carries, which is the same in every layout that has the control.

Beside the trees is the rsc graph:

field
classOverridesUXRscClassOverride: a control whose class is not the one its GEM type implies
topObjectsUXRscTopObject: the non-view objects a form loads with
connectionsUXRscConnection: outlets and actions, each scoped to layout themes
extSectionsUXRscExtSection: chunk sections this build does not interpret, kept for re-saving
ownerClassFile’s Owner’s class, so a designer can list its outlets and actions; "" when unset
attrsUXRscAttr: settings a control has no OBJECT field for, such as a slider’s range

On disk the trees are a classic .rsc, readable by any GEM AES, and the graph is the rsc chunk after them.

treeCount · treeAt · deepCopy · formIdOf · ensureLogicalId · refFor · classOf · setClassOf · addTopObject · topObjectById · removeTopObject · removeConnectionsTo · refHits · attrIn · setAttrIn · attrOf · setAttrOf · autoresizeOf · setAutoresizeOf · themeOf · maskFrom · maskLetters · seq · addTree · indexOfTree · formCount · formAt · formOf · formById · addVariant · variantSuffix · emptyDialog · flatten

UXRscDoc* deepCopy(void)

A copy that can be edited without touching the original: every tree, form and rsc-graph record is new. Strings and image bytes are shared, because an edit replaces them instead of writing into them. An editor keeps these for undo.

i32 formIdOf(UXRscTree* t)

The id a tree’s form is loaded by: its form’s, or for a tree in no form the tree’s own index.

i32 ensureLogicalId(UXRscTree* t, UXRscObject* o)

The control’s logical id, giving it one first if it has none. A new id is unused in every layout of the form.

UXRscRef* refFor(UXRscTree* t, UXRscObject* o)

A reference to a control by logical id, which holds in every layout of its form. A connection or a class override names a control this way.

u8* classOf(UXRscTree* t, UXRscObject* o)

The class the document gives a control, or null for the one its type implies (UXRsc.defaultClassFor).

void setClassOf(UXRscTree* t, UXRscObject* o, u8* cls)

Gives a control a class. Null or "" removes the override.

UXRscTopObject* addTopObject(u8* cls, u8* label)

Adds one of the document’s objects, with the next free id.

UXRscTopObject* topObjectById(i32 id)
void removeTopObject(i32 id)

Removes the object and every connection to or from it.

void removeConnectionsTo(UXRscRef* r)

Removes every connection with r at either end.

static bool refHits(UXRscRef* a, UXRscRef* r)

Whether a names what r names.

u8* attrIn(i32 formId, i32 logicalId, i32 theme, u8* key)

A control’s attribute in a theme: the theme’s own value if it varies it, else the shared one, else null. theme is a theme bit, or UXR_ATTR_SHARED.

void setAttrIn(i32 formId, i32 logicalId, i32 theme, u8* key, u8* value)

Sets it; null removes it.

u8* attrOf(UXRscTree* t, UXRscObject* o, u8* key)

The shared value, for a control in a tree.

i32 autoresizeOf(UXRscTree* t, UXRscObject* o)

How the control follows its container when that is resized, in layout t: a UXView autoresize mask, 0 when it is pinned to the top left. It is the control’s autoresize attribute in that layout’s theme. Positions and sizes belong to each layout, so the value is never shared.

void setAutoresizeOf(UXRscTree* t, UXRscObject* o, i32 mask)

Sets it; 0 removes the attribute.

u32 themeOf(UXRscTree* t)

The theme bit of the layout t: its variant’s form factor and orientation, or the any theme when the tree is not a variant.

static i32 maskFrom(u8* s)

The mask an autoresize value names. The value is letters: L, R, T and B for the margins kept (UX_ANCHOR_LEFT, RIGHT, TOP, BOTTOM), W and H for the sizes that stretch (UX_FLEX_WIDTH, UX_FLEX_HEIGHT).

static u8* maskLetters(i32 m)

The autoresize value for a mask, in the order LRTBWH; "" for 0.

void setAttrOf(UXRscTree* t, UXRscObject* o, u8* key, u8* value)

Sets the shared value, giving the control a logical id if it has none.

static bool seq(u8* a, u8* b)

Whether two C strings are equal.

i32 treeCount(void)
UXRscTree* treeAt(i32 i)
void addTree(UXRscTree* t)
i32 indexOfTree(UXRscTree* t)

A tree’s position, which is its index in the written file; -1 if it is not in this document.

i32 formCount(void)

The forms with more than one layout. A tree in no form is a form of its own, with one layout for every theme.

UXRscForm* formAt(i32 i)
UXRscForm* formOf(UXRscTree* t)

The form a tree is a layout of, or null.

UXRscForm* formById(i32 formId)
UXRscTree* addVariant(UXRscTree* from, i32 klass, i32 orient)

Adds a layout for a theme to from’s form, seeded as a copy of from. The copy is a one-time seed: later edits to either layout do not reach the other. Controls without a logical id get one first. Returns null if the form already has that theme, or for an orientation on the desktop.

static u8* variantSuffix(i32 klass, i32 orient)

The suffix a layout’s tree name takes after its form’s: _PHONE_P, _TABLET_L, and so on.

static UXRscDoc* emptyDialog(void)

A new document with one empty dialog tree.

Array<UXRscFlatNode>* flatten(UXRscTree* t)

A tree as the classic pre-order array with next, head and tail links, which is what the writer emits.

One object of a tree. type, flags, state, x, y, w, h, text, ted, logicalId and children hold what the OBJECT holds.

static UXRscObject* make(i32 type, i32 x, i32 y, i32 w, i32 h)
void addChild(UXRscObject* c)
UXRscObject* childAt(i32 i)
i32 childCount(void)
UXRscObject* parentOf(UXRscObject* target)
UXRscObject* deepCopy(void)

A copy of the object and its children, logical ids included.

void collect(Array<UXRscObject>* out)

The object and its descendants, in pre-order.

hasStringSpec / hasTedinfo / hasBox / hasIcon / hasBitblk / canHaveChildren

Section titled “hasStringSpec / hasTedinfo / hasBox / hasIcon / hasBitblk / canHaveChildren”
bool hasStringSpec(void)
bool hasTedinfo(void)
bool hasBox(void)
bool hasIcon(void)
bool hasBitblk(void)
bool canHaveChildren(void)

Which payload the type carries, and whether it is a container.

static bool typeHasTedinfo(i32 t)
void seedPayload(void)

Gives a new object the payload its type needs.

A named root object and a kind (dialog, menu, free).

Array<UXRscObject>* allObjects(void)

Every object in pre-order. An object’s position here is its index in the written tree.

UXRscObject* parentOf(UXRscObject* node)
bool absoluteOriginOf(UXRscObject* node, i32* ox, i32* oy)
i32 reparentByGeometry(void)

Moves each object into the innermost container that holds it, after a drag.

bool isMenu(void)
void setNameJoined(u8* base, u8* suffix)
static i32 len(u8* s)

A form with several layouts: formId, name, and variants.

i32 variantCount(void)
UXRscVariant* variantAt(i32 i)
UXRscVariant* find(i32 klass, i32 orient)

The layout for one theme, or null.

UXRscVariant* variantFor(UXRscTree* t)
i32 nextLogicalId(void)

A logical id no layout of the form uses. Ids are not reused.

A UXRscVariant is klass, orient and tree.

One end of a connection: space, a, b.

spaceab
UXR_REF_VIEWa control by position, in a form with one layouttreeobject
UXR_REF_TOPa top-level objectid
UXR_REF_OWNERFile’s Owner
UXR_REF_FIRSTRFirst Responder
UXR_REF_LOGICALa control by logical idformlogical id
static UXRscRef* make(i32 space, i32 a, i32 b)
bool same(UXRscRef* o)

view, a ref, and cls, the class name.

id, cls, and label, the name the designer shows for it.

formId, logicalId, theme, key and value: one setting of a control, kept in the chunk’s ATTR section. Values are text. A record whose theme is a theme bit is that layout’s variation of the setting.

tag and body: a chunk section kept as it was read.