All the events (mouse events, keyboard events, etc.) are passed to the face first, then to the gob. The face event handler could return stop to prevent the event from passing to the gob.
Graphic Object (GOB)
A GOB is very lightweight (96 bytes now) compare to face. Complex UI components can be built by composing many gobs.
List of available fields of gob:
Field
Datatype
Description
offset
pair!
the x-y coordinate relative to parent
size
pair
width and height of gob (note below)
pane
block!
a block of child gobs
parent
gob!
the parent gob
data
any-type!
normally used to reference data related to the gob
face
face!
the face object the gob linked with
draw
block!
a block of draw commands
color
tuple!
background color of the gob in R.G.B or R.G.B.A format
text
string!
text displayed in the gob
image
image!
image displayed in the face background
enabled?
logic!
enable or disable events on the gob
visible?
logic!
display or hide the gob
flags
block!
?? Do we need it?
actors
block!
User-provided events handlers
styles
object!
gob-style! object, styling the gob
...
...
...
Note: The gob uses a box model. Every box is composed of three parts (or areas), defined by their respective edges: the content edge, padding edge and border edge.
If you set an gob's width to 100 pixels, that 100 pixels will include any border or padding you added, and the content box will shrink to absorb that extra width.
The draw commands in gob/draw will be draw in the content box.
Gob style
Gob-style objects are clones of gob-style! template object.
gob-style!: object [
state: none ;-- Internal state info
on-change*: function [word old new][
;-- update field
]
on-deep-change*: function [owner word target action new index part][
;-- update field
]
]
When link a gob-style! object to a gob, the following fields will be processed by the gob. Other fields will be ignored.
TBD
Example of GOB-based widget
Extend Face! Object
The face! object is extended to have a
gob
facet, which does the actual job.Event flow
All the events (mouse events, keyboard events, etc.) are passed to the face first, then to the gob. The face event handler could return
stop
to prevent the event from passing to the gob.Graphic Object (GOB)
A GOB is very lightweight (96 bytes now) compare to face. Complex UI components can be built by composing many gobs.
Note: The gob uses a box model. Every box is composed of three parts (or areas), defined by their respective edges: the content edge, padding edge and border edge.
If you set an gob's width to 100 pixels, that 100 pixels will include any border or padding you added, and the content box will shrink to absorb that extra width. The draw commands in
gob/draw
will be draw in the content box.Gob style
Gob-style objects are clones of gob-style! template object.
When link a gob-style! object to a gob, the following fields will be processed by the gob. Other fields will be ignored. TBD