dup unparent
over >>parent
tuck ((add-gadget))
- tuck graft-state>> second [ graft ] [ drop ] if ;
+ tuck graft-state>> second [ graft ] [ drop ] if ;
: add-gadget ( parent child -- parent )
not-in-layout
-! Copyright (C) 2005, 2008 Slava Pestov.
+! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: io kernel math namespaces math.vectors ui.gadgets
-ui.gadgets.packs accessors math.geometry.rect ;
+ui.gadgets.packs accessors math.geometry.rect combinators ;
IN: ui.gadgets.incremental
TUPLE: incremental < pack cursor ;
[ cursor>> ] [ orientation>> ] bi v*
>>loc drop ;
-: prefer-incremental ( gadget -- ) USE: slots.private
+: prefer-incremental ( gadget -- )
dup forget-pref-dim dup pref-dim >>dim drop ;
M: incremental dim-changed drop ;
not-in-layout
2dup swap (add-gadget) drop
t in-layout? [
- over prefer-incremental
- over layout-later
- 2dup incremental-loc
- tuck update-cursor
- dup prefer-incremental
- parent>> [ invalidate* ] when*
+ {
+ [ drop prefer-incremental ]
+ [ drop layout-later ]
+ [ incremental-loc ]
+ [ update-cursor ]
+ [ nip prefer-incremental ]
+ [ nip parent>> [ invalidate* ] when* ]
+ } 2cleave
] with-variable ;
: clear-incremental ( incremental -- )
not-in-layout
- dup (clear-gadget)
- dup forget-pref-dim
- { 0 0 } >>cursor
- parent>> [ relayout ] when* ;
+ [ (clear-gadget) ]
+ [ forget-pref-dim ]
+ [ { 0 0 } >>cursor parent>> [ relayout ] when* ]
+ tri ;
[ dim>> ] [ pref-dim ] bi* [v-] hand-loc get-global vmin ;
: show-menu ( owner menu -- )
- [ find-world dup ] dip tuck menu-loc show-glass ;
+ [ find-world ] dip 2dup menu-loc show-glass ;
:: <menu-item> ( target hook command -- button )
command command-name [
stream>> write-gadget ;
: print-gadget ( gadget stream -- )
- tuck write-gadget stream-nl ;
+ [ write-gadget ] [ nip stream-nl ] 2bi ;
: gadget. ( gadget -- )
output-stream get print-gadget ;
: (compute-column-widths) ( font rows -- total widths )
[ drop 0 { } ] [
- tuck [ first length 0 <repetition> ] 2dip
+ [ nip first length 0 <repetition> ] 2keep
[ [ text-width ] with map vmax ] with each
[ [ sum ] [ length 1 [-] table-gap * ] bi + ] keep
] if-empty ;
if ;
M: table model-changed
- tuck initial-selected-index {
+ [ nip ] [ initial-selected-index ] 2bi {
[ >>selected-index drop ]
[ show-row-summary ]
[ drop update-selected-value ]
GENERIC: handle-gesture ( gesture gadget -- ? )
M: object handle-gesture
- tuck class superclasses
- [ "gestures" word-prop ] map
- assoc-stack dup [ call f ] [ 2drop t ] if ;
+ [ nip ]
+ [ class superclasses [ "gestures" word-prop ] map assoc-stack ] 2bi
+ dup [ call f ] [ 2drop t ] if ;
: set-gestures ( class hash -- ) "gestures" set-word-prop ;
>float-array ;
M: gradient recompute-pen ( gadget gradient -- )
- tuck
- [ [ orientation>> ] [ dim>> ] bi ] [ colors>> ] bi*
+ [ nip ] [ [ [ orientation>> ] [ dim>> ] bi ] [ colors>> ] bi* ] 2bi
[ gradient-vertices >>last-vertices ]
- [ gradient-colors >>last-colors ] bi
- drop ;
+ [ gradient-colors >>last-colors ]
+ bi drop ;
: draw-gradient ( colors -- )
GL_COLOR_ARRAY [
} 2|| ;
M: browser-gadget definitions-changed ( assoc browser -- )
- model>> tuck value>> swap showing-definition?
- [ notify-connections ] [ drop ] if ;
+ model>> [ value>> swap showing-definition? ] keep
+ '[ _ notify-connections ] when ;
M: browser-gadget focusable-child* search-field>> ;
] recover ;
: handle-interactive ( lines interactor -- quot/f ? )
- tuck try-parse {
+ [ nip ] [ try-parse ] 2bi {
{ [ dup quotation? ] [ nip t ] }
{ [ dup not ] [ drop "\n" swap user-input* drop f f ] }
[ handle-parse-error f f ]
nip ,
] [
[
- 2dup children>> swap first head-slice %
- tuck traverse-step traverse-to-path
+ [ children>> swap first head-slice % ]
+ [ tuck traverse-step traverse-to-path ]
+ 2bi
] make-node
] if
] if ;
nip ,
] [
[
- 2dup traverse-step traverse-from-path
- tuck children>> swap first 1+ tail-slice %
+ [ traverse-step traverse-from-path ]
+ [ tuck children>> swap first 1+ tail-slice % ] 2bi
] make-node
] if
] if ;
M: x11-ui-backend set-fullscreen* ( ? world -- )
handle>> window>> "XClientMessageEvent" <c-object>
- tuck set-XClientMessageEvent-window
+ [ set-XClientMessageEvent-window ] keep
swap _NET_WM_STATE_ADD _NET_WM_STATE_REMOVE ?
over set-XClientMessageEvent-data0
ClientMessage over set-XClientMessageEvent-type