From a22b04d2b6bf1f12e5d8d691223fd528fdca8888 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 12 Mar 2005 02:41:46 +0000 Subject: [PATCH] UI work --- TODO.FACTOR.txt | 2 -- library/bootstrap/boot-stage2.factor | 4 ++-- library/ui/checkboxes.factor | 4 ++-- library/ui/editors.factor | 2 +- library/ui/panes.factor | 2 +- library/ui/scrolling.factor | 24 +++++++++++------------- library/ui/tiles.factor | 3 --- 7 files changed, 17 insertions(+), 24 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index d7f7885aa7..9144e10133 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -6,14 +6,12 @@ + ui: -- fix up initial layout of slider - resizing a gadget should probably relayout children - resizing: drag relative to initial click pos - mouse enter onto overlapping with interior, but not child, gadget - menu dragging - auto-updating inspector - fix up the min thumb size hack -- console: scroll to bottom - faster layout - faster repaint - check broken diff --git a/library/bootstrap/boot-stage2.factor b/library/bootstrap/boot-stage2.factor index 80c322e462..1a30428a69 100644 --- a/library/bootstrap/boot-stage2.factor +++ b/library/bootstrap/boot-stage2.factor @@ -9,7 +9,7 @@ default-cli-args parse-command-line ! Dummy defs for mini bootstrap -IN: compiler : compile-all ; : compile drop ; +IN: compiler : compile-all ; : compile drop ; : supported-cpu? f ; IN: assembler : init-assembler ; IN: alien : add-library 3drop ; @@ -54,7 +54,7 @@ cpu "x86" = "mini" get not and [ "/library/compiler/x86/fixnum.factor" ] pull-in -"compile" get [ +"compile" get supported-cpu? and [ init-assembler \ car compile \ = compile diff --git a/library/ui/checkboxes.factor b/library/ui/checkboxes.factor index e602173911..80b622cd6f 100644 --- a/library/ui/checkboxes.factor +++ b/library/ui/checkboxes.factor @@ -3,11 +3,11 @@ IN: gadgets USING: generic kernel lists math namespaces sdl ; -: check-size 7 ; +: check-size 8 ; : ( -- cross ) 0 0 check-size dup - >r check-size 0 check-size neg check-size r> + >r check-size 1 - 0 check-size neg check-size r> 2list ; TUPLE: checkbox bevel selected? ; diff --git a/library/ui/editors.factor b/library/ui/editors.factor index d6efe915fa..658185b448 100644 --- a/library/ui/editors.factor +++ b/library/ui/editors.factor @@ -87,7 +87,7 @@ C: editor ( text -- ) M: editor user-input* ( ch field -- ? ) [ [ insert-char ] with-editor ] keep - [ scroll>bottom ] swap handle-gesture drop t ; + scroll>bottom t ; M: editor layout* ( field -- ) dup [ editor-text shape-size ] keep resize-gadget diff --git a/library/ui/panes.factor b/library/ui/panes.factor index 517f0c62ac..ae5492baad 100644 --- a/library/ui/panes.factor +++ b/library/ui/panes.factor @@ -72,7 +72,7 @@ M: pane stream-readln ( stream -- line ) [ swap set-pane-continuation (yield) ] callcc1 nip ; M: pane stream-write-attr ( string style stream -- ) - nip swap "\n" split pane-write ; + [ nip swap "\n" split pane-write ] keep scroll>bottom ; M: pane stream-close ( stream -- ) drop ; diff --git a/library/ui/scrolling.factor b/library/ui/scrolling.factor index 80c155a6f9..f41525565a 100644 --- a/library/ui/scrolling.factor +++ b/library/ui/scrolling.factor @@ -15,14 +15,12 @@ TUPLE: viewport x y ; dup shape-h swap viewport-h - max 0 min ; : scroll-viewport ( y viewport -- ) - #! y is a number between 0 and 1. + #! y is a number between -1 and 0.. [ viewport-h * >fixnum ] keep [ adjust-scroll ] keep [ set-viewport-y ] keep relayout ; -: scroll>bottom ( viewport -- ) 1 swap scroll-viewport ; - C: viewport ( content -- viewport ) [ swap set-delegate ] keep [ add-gadget ] keep @@ -32,11 +30,8 @@ C: viewport ( content -- viewport ) M: viewport pref-size gadget-child pref-size ; M: viewport layout* ( viewport -- ) - dup gadget-children [ - [ - >r dup viewport-x swap viewport-y r> move-gadget - ] keep prefer - ] each-with ; + dup gadget-child dup prefer + >r dup viewport-x swap viewport-y r> move-gadget ; ! A slider scrolls a viewport. @@ -111,13 +106,16 @@ TUPLE: scroller viewport slider ; : add-viewport 2dup set-scroller-viewport add-center ; : add-slider 2dup set-scroller-slider add-right ; -: viewport>bottom 1 swap scroll-viewport ; -: scroll>bottom ( scroller -- ) - dup scroller-slider relayout - scroller-viewport viewport>bottom ; +: viewport>bottom -1 swap scroll-viewport ; +: (scroll>bottom) ( scroller -- ) + dup scroller-viewport viewport>bottom + scroller-slider relayout ; : scroller-actions ( scroller -- ) - [ scroll>bottom ] [ scroll>bottom ] set-action ; + [ (scroll>bottom) ] [ scroll>bottom ] set-action ; + +: scroll>bottom ( gadget -- ) + [ scroll>bottom ] swap handle-gesture drop ; C: scroller ( gadget -- scroller ) #! Wrap a scrolling pane around the gadget. diff --git a/library/ui/tiles.factor b/library/ui/tiles.factor index 46fb5482e6..7a19f9a8d6 100644 --- a/library/ui/tiles.factor +++ b/library/ui/tiles.factor @@ -37,11 +37,8 @@ USING: generic kernel math namespaces ; dup t reverse-video set-paint-prop dup caption-actions ; -DEFER: inspect - : tile-actions ( tile -- ) dup [ unparent ] [ close-tile ] set-action - dup [ inspect ] [ inspect-tile ] set-action dup [ raise ] [ raise ] set-action [ drag-tile ] [ drag-tile ] set-action ;