type
TPxCoord* = int32
TPxRect* = object
x*, y*, w*, h*: TPxCoord
TUIContextRoot* = object
## This describes a top window/rendering context. Only one is supported
## but in future several rendering windows can be supported.
rootNode: TUINode ## The size is auto-adjusted to occupy the whole \
## window. It's in scaled coords (uiScale).
uiScale: float
uiInvScale: float
pxScale: float
windowRect: TPxRect ## Unscaled rect in device/pixel coords of the \
## window.
fixed: bool ## Window is not resizeable
proc initContextRoot*(c: var TUIContextRoot, uiScale = 1.0, pxScale = 1.0,
windowRect = TPxRect(0, 0, 480, 320), fixed = true) =
c.uiScale = uiScale
What's wrong with the "windowRect = TPxRect..." ? How to define "TPxCoord" as an alias to type int32 (like C typedef) ?
The compiler is not very helpful but you are using the wrong syntax. If you look carefully at the second tutorial regarding objects you will notice the constructor does use colons to assign the fields. Here's a compilable version of your code:
type
TPxCoord* = int32
TPxRect* = object
x*, y*, w*, h*: TPxCoord
TUIContextRoot* = object
## This describes a top window/rendering context. Only one is supported
## but in future several rendering windows can be supported.
rootNode: int ## The size is auto-adjusted to occupy the whole \
## window. It's in scaled coords (uiScale).
uiScale: float
uiInvScale: float
pxScale: float
windowRect: TPxRect ## Unscaled rect in device/pixel coords of the \
## window.
fixed: bool ## Window is not resizeable
proc initContextRoot*(c: var TUIContextRoot, uiScale = 1.0, pxScale = 1.0,
windowRect = TPxRect(x: 0, y: 0, w: 480, h: 320),
fixed = true) =
c.windowRect = windowRect
c.uiScale = uiScale