From 54b24fd8b1060c80362898744e797b5d285935d7 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sun, 13 Jul 2008 01:24:43 -0500 Subject: [PATCH 1/6] ui.gadgets: new effects for add-gadget, add-gadgets, and (add-gadget) --- extra/ui/gadgets/gadgets.factor | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/extra/ui/gadgets/gadgets.factor b/extra/ui/gadgets/gadgets.factor index 3fc185a10e..ebe3773ce9 100755 --- a/extra/ui/gadgets/gadgets.factor +++ b/extra/ui/gadgets/gadgets.factor @@ -285,22 +285,27 @@ SYMBOL: in-layout? not-in-layout dup (clear-gadget) relayout ; -: ((add-gadget)) ( gadget box -- ) - [ children>> ?push ] keep (>>children) ; +: ((add-gadget)) ( parent child -- parent ) + over children>> ?push >>children ; -: (add-gadget) ( gadget box -- ) - over unparent - dup pick (>>parent) - [ ((add-gadget)) ] 2keep - graft-state>> second [ graft ] [ drop ] if ; +: (add-gadget) ( parent child -- parent ) + dup unparent + over >>parent + tuck ((add-gadget)) + tuck graft-state>> second + [ graft ] + [ drop ] + if ; -: add-gadget ( gadget parent -- ) +: add-gadget ( parent child -- parent ) not-in-layout - [ (add-gadget) ] keep relayout ; - -: add-gadgets ( seq parent -- ) + (add-gadget) + dup relayout ; + +: add-gadgets ( parent children -- parent ) not-in-layout - swap [ over (add-gadget) ] each relayout ; + [ (add-gadget) ] each + dup relayout ; : parents ( gadget -- seq ) [ parent>> ] follow ; @@ -352,7 +357,7 @@ M: f request-focus-on 2drop ; : focus-path ( world -- seq ) [ focus>> ] follow ; -: gadget, ( gadget -- ) gadget get add-gadget ; +: gadget, ( gadget -- ) gadget get swap add-gadget drop ; : g ( -- gadget ) gadget get ; From 73e30123f52ae037b11f1977933c04e6e98f61fd Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sun, 13 Jul 2008 01:25:44 -0500 Subject: [PATCH 2/6] ui.gadgets.*: updates for new effects --- extra/ui/gadgets/books/books.factor | 2 +- extra/ui/gadgets/borders/borders.factor | 2 +- extra/ui/gadgets/grids/grids.factor | 4 ++-- extra/ui/gadgets/incremental/incremental.factor | 2 +- extra/ui/gadgets/lists/lists.factor | 2 +- extra/ui/gadgets/menus/menus.factor | 4 ++-- extra/ui/gadgets/panes/panes.factor | 12 ++++++------ extra/ui/gadgets/sliders/sliders.factor | 2 +- extra/ui/gadgets/tabs/tabs.factor | 4 ++-- extra/ui/gadgets/tracks/tracks.factor | 2 +- extra/ui/gadgets/viewports/viewports.factor | 2 +- extra/ui/gadgets/wrappers/wrappers.factor | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/extra/ui/gadgets/books/books.factor b/extra/ui/gadgets/books/books.factor index 93a8d271af..ce15bd9e6c 100755 --- a/extra/ui/gadgets/books/books.factor +++ b/extra/ui/gadgets/books/books.factor @@ -19,7 +19,7 @@ M: book model-changed : new-book ( pages model class -- book ) new-gadget swap >>model - [ add-gadgets ] keep ; inline + [ swap add-gadgets drop ] keep ; inline : ( pages model -- book ) book new-book ; diff --git a/extra/ui/gadgets/borders/borders.factor b/extra/ui/gadgets/borders/borders.factor index 7d6a24fed1..d1cf7cfb29 100644 --- a/extra/ui/gadgets/borders/borders.factor +++ b/extra/ui/gadgets/borders/borders.factor @@ -10,7 +10,7 @@ TUPLE: border < gadget { align initial: { 1/2 1/2 } } ; : new-border ( child class -- border ) - new-gadget [ add-gadget ] keep ; inline + new-gadget [ swap add-gadget drop ] keep ; inline : ( child gap -- border ) swap border new-border diff --git a/extra/ui/gadgets/grids/grids.factor b/extra/ui/gadgets/grids/grids.factor index b539934771..474e6b95c0 100644 --- a/extra/ui/gadgets/grids/grids.factor +++ b/extra/ui/gadgets/grids/grids.factor @@ -12,7 +12,7 @@ grid : new-grid ( children class -- grid ) new-gadget - [ (>>grid) ] [ >r concat r> add-gadgets ] [ nip ] 2tri ; + [ (>>grid) ] [ >r concat r> swap add-gadgets drop ] [ nip ] 2tri ; inline : ( children -- grid ) @@ -21,7 +21,7 @@ grid : grid-child ( grid i j -- gadget ) rot grid>> nth nth ; : grid-add ( gadget grid i j -- ) - >r >r 2dup add-gadget r> r> + >r >r 2dup swap add-gadget drop r> r> 3dup grid-child unparent rot grid>> nth set-nth ; : grid-remove ( grid i j -- ) diff --git a/extra/ui/gadgets/incremental/incremental.factor b/extra/ui/gadgets/incremental/incremental.factor index c74f6676ad..8c227d76ce 100755 --- a/extra/ui/gadgets/incremental/incremental.factor +++ b/extra/ui/gadgets/incremental/incremental.factor @@ -45,7 +45,7 @@ M: incremental pref-dim* : add-incremental ( gadget incremental -- ) not-in-layout - 2dup (add-gadget) + 2dup swap (add-gadget) drop over prefer-incremental over layout-later 2dup incremental-loc diff --git a/extra/ui/gadgets/lists/lists.factor b/extra/ui/gadgets/lists/lists.factor index 776814853f..c2539e146a 100755 --- a/extra/ui/gadgets/lists/lists.factor +++ b/extra/ui/gadgets/lists/lists.factor @@ -48,7 +48,7 @@ TUPLE: list < pack index presenter color hook ; M: list model-changed nip dup clear-gadget - dup over add-gadgets + dup over swap add-gadgets drop bound-index ; : selected-rect ( list -- rect ) diff --git a/extra/ui/gadgets/menus/menus.factor b/extra/ui/gadgets/menus/menus.factor index 3e1145a8b6..4f815bc33d 100644 --- a/extra/ui/gadgets/menus/menus.factor +++ b/extra/ui/gadgets/menus/menus.factor @@ -15,7 +15,7 @@ TUPLE: menu-glass < gadget ; : ( menu world -- glass ) menu-glass new-gadget >r over menu-loc over set-rect-loc r> - [ add-gadget ] keep ; + [ swap add-gadget drop ] keep ; M: menu-glass layout* gadget-child prefer ; @@ -26,7 +26,7 @@ M: menu-glass layout* gadget-child prefer ; : show-glass ( gadget world -- ) over hand-clicked set-global [ hide-glass ] keep - [ add-gadget ] 2keep + [ swap add-gadget drop ] 2keep set-world-glass ; : show-menu ( gadget owner -- ) diff --git a/extra/ui/gadgets/panes/panes.factor b/extra/ui/gadgets/panes/panes.factor index 973c8c5725..9b547ce544 100755 --- a/extra/ui/gadgets/panes/panes.factor +++ b/extra/ui/gadgets/panes/panes.factor @@ -22,10 +22,10 @@ selection-color caret mark selecting? ; drop ; : add-output ( current pane -- ) - [ set-pane-output ] [ add-gadget ] 2bi ; + [ set-pane-output ] [ swap add-gadget drop ] 2bi ; : add-current ( current pane -- ) - [ set-pane-current ] [ add-gadget ] 2bi ; + [ set-pane-current ] [ swap add-gadget drop ] 2bi ; : prepare-line ( pane -- ) [ clear-selection ] @@ -120,7 +120,7 @@ C: pane-stream GENERIC: write-gadget ( gadget stream -- ) M: pane-stream write-gadget - pane-stream-pane pane-current add-gadget ; + pane-stream-pane pane-current swap add-gadget drop ; M: style-stream write-gadget stream>> write-gadget ; @@ -299,12 +299,12 @@ M: paragraph dispose drop ; : gadget-write ( string gadget -- ) over empty? - [ 2drop ] [ >r