113 lines
6.4 KiB
Plaintext
113 lines
6.4 KiB
Plaintext
IN: gadgets
|
|
USING: help generic kernel ;
|
|
|
|
HELP: relayout
|
|
{ $values { "gadget" gadget } }
|
|
{ $description "Relayout and redraw a gadget before the next iteration of the event loop. Unlike " { $link relayout-1 } ", this relayouts all parents up to a gadget having " { $link gadget-root? } " set, so this word should be used when the gadget's dimensions have potentially changed." }
|
|
{ $see-also relayout-1 } ;
|
|
|
|
HELP: relayout-1
|
|
{ $values { "gadget" gadget } }
|
|
{ $description "Relayout and redraw a gadget before the next iteration of the event loop. Unlike " { $link relayout } ", this does not propagate requests up to the parent, and so this word should only be used when the gadget's internal layout or appearance has changed, but the dimensions have not." }
|
|
{ $see-also relayout } ;
|
|
|
|
HELP: set-layout-dim
|
|
{ $values { "dim" "a pair of integers" } { "gadget" gadget } }
|
|
{ $description "Resizes a gadget inside a " { $link layout* } " method." }
|
|
{ $warning "Do not call this word outside of a " { $link layout* } " method, or otherwise the gadget will not be relayout automatically. Instead, use " { $link set-gadget-dim } "." } ;
|
|
|
|
HELP: set-gadget-dim
|
|
{ $values { "dim" "a pair of integers" } { "gadget" gadget } }
|
|
{ $description "Resizes and relayouts a gadget before the next iteration of the event loop." }
|
|
{ $warning "Do not call this word inside a " { $link layout* } " method, or otherwise unnecessary work will be done by the UI to ensure the gadget is relayout. Instead, use " { $link set-layout-dim } "." } ;
|
|
|
|
HELP: pref-dim*
|
|
{ $values { "gadget" gadget } { "dim" "a pair of integers" } }
|
|
{ $contract "Outputs the preferred dimensions of the gadget, possibly computing them from the preferred dimensions of the gadget's children." }
|
|
{ $notes "User code should not call this word directly, instead call " { $link pref-dim } "." }
|
|
{ $see-also relayout relayout-1 layout* } ;
|
|
|
|
HELP: pref-dim
|
|
{ $values { "gadget" gadget } { "dim" "a pair of integers" } }
|
|
{ $description "Outputs the preferred dimensions of the gadget. The value is cached between calls, and invalidated when the gadget needs to be relayout." }
|
|
{ $see-also pref-dim* relayout relayout-1 layout* } ;
|
|
|
|
HELP: pref-dims
|
|
{ $values { "seq" "a sequence of gadgets" } { "seq" "a sequence of a pair of integers" } }
|
|
{ $description "Collects the preferred dimensions of every gadget in the sequence into a new sequence." }
|
|
{ $see-also max-dim dim-sum } ;
|
|
|
|
HELP: layout*
|
|
{ $values { "gadget" gadget } }
|
|
{ $contract "Lays out the children of the gadget according to the gadget's policy. The dimensions of the gadget are already set by the parent by the time this word is called." }
|
|
{ $notes "User code should not call this word directly, instead call " { $link relayout } " and " { $link relayout-1 } "." }
|
|
{ $see-also pref-dim pref-dim* layout* } ;
|
|
|
|
HELP: prefer
|
|
{ $values { "gadget" gadget } }
|
|
{ $contract "Resizes the gadget to assume its preferred dimensions." }
|
|
{ $see-also pref-dim* layout* } ;
|
|
|
|
HELP: dim-sum
|
|
{ $values { "seq" "a sequence of pairs of integers" } { "dim" "a pair of integers" } }
|
|
{ $description "Sums a sequence of dimensions." }
|
|
{ $see-also pref-dims max-dim } ;
|
|
|
|
HELP: layout
|
|
{ $values { "gadget" gadget } }
|
|
{ $description "Lays out the children of the gadget if the gadget needs to be relayout, and otherwise does nothing." }
|
|
{ $notes "User code should not call this word directly, instead call " { $link relayout } " and " { $link relayout-1 } "." }
|
|
{ $see-also pref-dim pref-dim* layout* } ;
|
|
|
|
HELP: pack
|
|
{ $class-description "A gadget which lays out its children along a single axis stored in the " { $link gadget-orientation } " slot. Can be constructed with one of the following words:"
|
|
{ $list
|
|
{ $link <pack> }
|
|
{ $link <pile> }
|
|
{ $link <shelf> }
|
|
{ $link make-pile }
|
|
{ $link make-filled-pile }
|
|
{ $link make-shelf }
|
|
}
|
|
"Packs have the following slots:"
|
|
{ $list
|
|
{ { $link pack-align } " a rational number between 0 and 1, the alignment of gadgets along the axis perpendicular to the pack's orientation" }
|
|
{ { $link pack-fill } " a rational number between 0 and 1, where 0 gives each gadget its preferred size and 1 fills the dimension perpendicular to the pack's orientation" }
|
|
{ { $link pack-gap } " a pair of integers, the horizontal and vertical gap between children" }
|
|
}
|
|
"Gadgets can delegate to packs and implement their own " { $link pref-dim* } " and " { $link layout* } " methods, reusing pack layout logic by calling " { $link pack-pref-dim } " and " { $link pack-layout } "." }
|
|
{ $see-also delegate>pack } ;
|
|
|
|
HELP: pack-layout
|
|
{ $values { "pack" "a new " { $link pack } } { "sizes" "a sequence of pairs of integers" } }
|
|
{ $description "Lays out the pack's children along the " { $link gadget-orientation } " of the pack, with each gadget receiving its size from the corresponding index of the " { $snippet "sizes" } " sequence." }
|
|
{ $notes
|
|
"This word is useful if you are writing your own layout gadget which delegates to a " { $link pack } ". This allows you to reuse layout logic while computing gadget sizes using a custom procedure."
|
|
} ;
|
|
|
|
HELP: <pack>
|
|
{ $values { "orientation" "either " { $snippet "{ 1 0 }" } " or " { $snippet "{ 0 1 }" } } { "pack" "a new " { $link pack } } }
|
|
{ $description "Creates a new pack which lays out children along the given axis. Children are laid out vertically if the orientation is " { $snippet "{ 0 1 }" } " and horizontally if the orientation is " { $snippet "{ 1 0 }" } "." }
|
|
{ $see-also delegate>pack <pile> <shelf> } ;
|
|
|
|
HELP: delegate>pack
|
|
{ $values { "orientation" "either " { $snippet "{ 1 0 }" } " or " { $snippet "{ 0 1 }" } } { "tuple" tuple } }
|
|
{ $description "Sets the tuple's delegate to a new pack." }
|
|
{ $side-effects "tuple" }
|
|
{ $see-also <pack> <pile> <shelf> } ;
|
|
|
|
HELP: <pile>
|
|
{ $values { "pack" "a new " { $link pack } } }
|
|
{ $description "Creates a new " { $link pack } " which lays out its children vertically." } ;
|
|
|
|
HELP: <shelf>
|
|
{ $values { "pack" "a new " { $link pack } } }
|
|
{ $description "Creates a new " { $link pack } " which lays out its children horizontally." } ;
|
|
|
|
HELP: pack-pref-dim
|
|
{ $values { "gadget" gadget } { "sizes" "a sequence of pairs of integers" } { "dim" "a pair of integers" } }
|
|
{ $description "Computes the preferred size of a pack, with each gadget receiving its size from the corresponding index of the " { $snippet "sizes" } " sequence." }
|
|
{ $notes
|
|
"This word is useful if you are writing your own layout gadget which delegates to a " { $link pack } ". This allows you to reuse layout logic while computing gadget sizes using a custom procedure."
|
|
} ;
|