- 1 Overview
- 2 Functions
- 2.1 envoke_build (SPObject)
- 2.2 build (derived)
- 2.3 readAttr (SPObject)
- 2.4 set (derived)
- 2.5 requestDisplayUpdate(unsigned int flags) (SPObject)
- 2.6 updateDisplay(SPCtx *ctx, unsigned flags) (SPObject)
- 2.7 update (derived)
- 2.8 requestModified(unsigned int flags)
- 2.9 emitModified
- 2.10 modified
- 2.11 release
- 2.12 write
- 2.13 attach
- 2.14 updateRepr
The object tree implements an XML-to-display primitive mapping, and provides an object hierarchy that can be modified using the GUI. Changes in the XML tree are automatically propagated to the object tree via observers, but not the other way around—a function called updateRepr() must be explicitly called. Relevant nodes of the object tree contains fully cascaded CSS style information. The object tree also includes clones of objects that are referenced by the <use> element in the XML tree.
SPObject (src/sp-object.h) is the abstract base class for each node in the object tree. Each derived class implements a certain SVG element type or is an abstract base class for a different node type.
SPItem (src/sp-item.h) is a derived class that is the base class for all graphic (visible) SVG nodes. It adds handling for styling, clipping, masking, and transforms.
The object tree is constructed from the XML tree by first manually constructing the SPRoot object (derived from SPObject) in SPDocument::createDoc() (src/document.h) and then calling the SPObject::invoke_build() member function. This function does some bookkeeping and then envokes the build() method (i.e. SPRoot::build() in the case of the root element). It also add the signaling that keeps objects in sync with the XML tree.
The most important functions from an architecture point of view defined by SPObject are:
* Does bookkeeping. * Calls build() member function. * Adds signals to keep in sync with XML tree.
* Calls parent class's build() method. * Reads in attributes by calling readAttr() for each attribute.
* Looks up key for attribute (string). * Calls setKeyValue() which does nothing other than call set()
* Reads in attribute: ** Processing as needed (e.g. converting % length to absolute length). ** Calls requestDisplayUpdate() if required. * Calls parent class set() to handle unknown attributes.
requestDisplayUpdate(unsigned int flags) (SPObject)
* Merge update flags into uflags. * If SP_OBJECT_MODIFIED_FLAG or SP_OBJECT_CHILD_MODIFIED_FLAG not previously set: ** If object has parent, call parent's requestDisplayUpdate with SP_OBJECT_CHILD_MODIFIED_FLAG ** Else call document->requestModified() function which signals to GTK to redraw by calling sp_document_idle_handler() which calls SPDocument::_updateDocument().
updateDisplay(SPCtx *ctx, unsigned flags) (SPObject)
* Called by SPDocument::_updateDocument() which is called by SPDocument::ensureUpToDate(), etc. * Called on child objects by SPGroup::update(), etc.
* Merges uflags into flags. * Merges uflags into mflags. * Updates style if necessary. * Call update( ctx, flags).
* Performs object related updates like resolving % lengths. * Calls child objects with updated transform matrix and with SP_OBJECT_PARENT_MODIFIED_FLAG added to flags if needed. * Calls parent class update() if needed.
requestModified(unsigned int flags)
* Merge modified flags into mflags. * If SP_OBJECT_MODIFIED_FLAG or SP_OBJECT_CHILD_MODIFIED_FLAG not previously set: ** If object has parent, call parent's requestModified with SP_OBJECT_CHILD_MODIFIED_FLAG ** Else call document->requestModified() function which signals to GTK to redraw.