Paste: find-scroller*

Author: dharmatech
Mode: factor
Date: Sun, 9 Nov 2008 21:45:26
Plain Text |
! Current version
! From ui.gadgets.scrollers

: find-scroller* ( gadget -- scroller )
    dup find-scroller dup [
        2dup viewport>> gadget-child
        swap child? [ nip ] [ 2drop f ] if
    ] [
        2drop f
    ] if ;

Annotation: using if* simplifies the stack a bit

Author: dharmatech
Mode: factor
Date: Sun, 9 Nov 2008 21:46:01
Plain Text |
: find-scroller* ( gadget -- scroller )
    dup find-scroller [
        tuck viewport>> gadget-child
        swap child? [ ] [ drop f ] if
    ] [
        drop f
    ] if* ;

Annotation: Using &&. Not as efficient but very clear. (my favorite version)

Author: dharmatech
Mode: factor
Date: Sun, 9 Nov 2008 21:46:49
Plain Text |
: find-scroller* ( gadget -- scroller/f )
  { 
    [ find-scroller ]
    [ dup find-scroller viewport>> gadget-child swap child? ]
    [ find-scroller ]
  } && ;

Annotation: Using &&. As efficient as the original. Involves some shuffling.

Author: dharmatech
Mode: factor
Date: Sun, 9 Nov 2008 21:47:19
Plain Text |
: find-scroller* ( gadget -- scroller/f )
  dup find-scroller
    {
      [ nip ]
      [ viewport>> gadget-child swap child? ]
      [ nip ]
    }
  && ;

New Annotation

Summary:
Author:
Mode:
Body: