REBOL Programming/center-face

From Wikibooks, open books for an open world
< REBOL Programming
Jump to: navigation, search

USAGE:[edit]

CENTER-FACE obj /with face 

DESCRIPTION:[edit]

Center a face relative to parent (screen for windows) or a sibling face.

CENTER-FACE is a function value.

ARGUMENTS[edit]

  • obj -- (Type: object)

REFINEMENTS[edit]

  • /with -- Center relative to a sibling face.
    • face -- (Type: object)

SOURCE CODE[edit]

center-face: func [
    {Center a face relative to parent (screen for windows) or a sibling face.} 
    obj [object!] 
    /with "Center relative to a sibling face." face [object!]
][
    if none? face [face: any [obj/parent-face system/view/screen-face]] 
    obj/offset: max 0x0 face/size - obj/size / 2 + either with [face/offset] [0x0] 
    obj
]