Control
type Control @abstract =
var obs width : u32 = 0
var obs height : u32 = 0
def measure (w : u32) (h : u32)
obs
fields are observable, can give a notification when the value changes.
type Aligner =
inherit Control
def Control.measure (w : u32) (h : u32) =
...
Aligner
implements the abstract measure
method of the Control
. Method can no longer be overridden in subtypes.
type ListItem =
inherit Control
var obs text = ""
var obs foreground = Vector3@zero
var obs background = Vector3@zero
var obs is_selected = false
let rectangle = Rectangle
color@obs = background@obs
is_visible@obs = is_selected@obs
let text_block = TextBlock
text@obs = text@obs
color@obs = foreground@obs
align_h = AlignH/Center
let aligner = Aligner
items = rectangle
text_block
@zero
modifier returns a zeroed block of memory.
Constructors of Rectangle
, TextBlock
and Aligner
do not accept arguments, changes are applied to fields after objects are created.
rectangle.color
is updated every time background
changes because of the @obs
modifier.
let aligner = Aligner rectangle text_block
The Aligner.items
field has the @dst
attribute.
let rectangle = Rectangle.new
let text_block = TextBlock.new
let aligner = Aligner
rectangle
color@obs = background@obs
is_visible@obs = is_selected@obs
text_block
text@obs = text@obs
color@obs = foreground@obs
align_h = AlignH/Center
We moved field setters into the expression for aligner
.
let aligner = Aligner
Rectangle
color@obs = background@obs
is_visible@obs = is_selected@obs
TextBlock
text@obs = text@obs
color@obs = foreground@obs
align_h = AlignH/Center
If references to Rectangle
and TextBlock
are not needed, then the objects can be created in place.