From: Joe Groff Date: Sat, 16 Jan 2010 20:24:47 +0000 (-0800) Subject: Merge branch 'master' of git://factorcode.org/git/factor X-Git-Tag: 0.97~5067 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=f7e1ed18b0a8821256e00e42625db760186ede03;hp=e4da6874134c2ec37d29b297d21c54027b99152b Merge branch 'master' of git://factorcode.org/git/factor --- diff --git a/basis/ui/gadgets/tracks/tracks.factor b/basis/ui/gadgets/tracks/tracks.factor index 387f41a6a4..89389485b2 100644 --- a/basis/ui/gadgets/tracks/tracks.factor +++ b/basis/ui/gadgets/tracks/tracks.factor @@ -39,7 +39,8 @@ TUPLE: track < pack sizes ; M: track layout* ( track -- ) dup track-layout pack-layout ; : track-pref-dims-1 ( track -- dim ) - children>> pref-dims max-dim ; + [ children>> pref-dims max-dim ] + [ pref-dim>> { 0 0 } or ] bi vmax ; : track-pref-dims-2 ( track -- dim ) [ diff --git a/basis/ui/gadgets/worlds/worlds.factor b/basis/ui/gadgets/worlds/worlds.factor index 8f38cee988..8a22107f3a 100644 --- a/basis/ui/gadgets/worlds/worlds.factor +++ b/basis/ui/gadgets/worlds/worlds.factor @@ -50,7 +50,8 @@ TUPLE: world-attributes status gadgets { pixel-format-attributes initial: $ default-world-pixel-format-attributes } - { window-controls initial: $ default-world-window-controls } ; + { window-controls initial: $ default-world-window-controls } + pref-dim ; : ( -- world-attributes ) world-attributes new ; inline @@ -132,7 +133,8 @@ M: world request-focus-on ( child gadget -- ) [ window-controls>> >>window-controls ] [ initial-background-color >>background-color ] [ grab-input?>> >>grab-input? ] - [ gadgets>> [ 1 track-add ] each ] + [ gadgets>> dup sequence? [ [ 1 track-add ] each ] [ 1 track-add ] if ] + [ pref-dim>> >>pref-dim ] } cleave ; : ( world-attributes -- world ) diff --git a/basis/ui/ui-docs.factor b/basis/ui/ui-docs.factor index 51ff4c2609..b55ea44c6b 100644 --- a/basis/ui/ui-docs.factor +++ b/basis/ui/ui-docs.factor @@ -2,7 +2,7 @@ USING: help.markup help.syntax strings quotations debugger namespaces ui.backend ui.gadgets ui.gadgets.worlds ui.gadgets.tracks ui.gadgets.packs ui.gadgets.grids ui.gadgets.private math.rectangles colors ui.text fonts -kernel ui.private classes sequences ; +kernel ui.private vocabs.loader classes sequences ; IN: ui HELP: windows @@ -150,7 +150,9 @@ ARTICLE: "ui-windows" "Top-level windows" "When the gadget is removed from a parent shown in a top-level window, or when the top-level window is closed, a corresponding generic word is called to clean up:" { $subsections ungraft* } "The root of the gadget hierarchy in a window is a special gadget which is rarely operated on directly, but it is helpful to know it exists:" -{ $subsections world } ; +{ $subsections world } +"There is also syntax for defining a main window as the entry point for a vocabulary:" +{ $subsections POSTPONE: MAIN-WINDOW: } ; ARTICLE: "ui-backend" "Developing UI backends" "None of the words documented in this section should be called directly by user code. They are only of interest when developing new UI backends." @@ -325,6 +327,20 @@ HELP: normal-title-bar HELP: textured-background { $description "Asks for a window to have a background that blends seamlessly with the window frame. Factor will leave the window background transparent and pass mouse button gestures not handled directly by a gadget through to the window system so that the window can be dragged from anywhere on its background." } ; +HELP: MAIN-WINDOW: +{ $syntax "MAIN-WINDOW: window-word { attributes } + attribute-code ;" } +{ $description "Defines a " { $link POSTPONE: MAIN: } " word for the current vocabulary named " { $snippet "window-word" } " that opens a UI window when the vocabulary is " { $link run } ". The " { $snippet "attributes" } " specify the key-value pairs of the window's " { $link world-attributes } ". The " { $snippet "attribute-code" } " is run with the " { $snippet "world-attributes" } " on the stack; this allows the word to construct gadget objects to place in the " { $snippet "gadget" } " slot or set other runtime-dependent world attributes." } +{ $examples +"From the " { $vocab-link "hello-ui" } " vocabulary. Creates a window with the title \"Hi\" containing a label reading \"Hello world\":" +{ $code +"""USING: accessors ui ui.gadgets.labels ; +IN: hello-ui + +MAIN-WINDOW: hello { { title "Hi" } } + "Hello world"