From c918f606710e15f9ac66f4f9302c7a3eef310143 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 2 Mar 2005 03:11:08 +0000 Subject: [PATCH] presentations and menus --- TODO.FACTOR.txt | 6 ++--- examples/gadget-test.factor | 3 ++- library/bootstrap/boot-stage2.factor | 3 ++- library/ui/editors.factor | 4 ++-- library/ui/gestures.factor | 3 +++ library/ui/halo.factor | 4 +++- library/ui/inspector.factor | 13 +++-------- library/ui/labels.factor | 16 ++++++++++--- library/ui/layouts.factor | 13 +++++------ library/ui/menus.factor | 35 ++++++++++++++++++++++++++++ library/ui/paint.factor | 23 +++++++++++++++--- library/ui/panes.factor | 4 ++-- library/ui/presentations.factor | 29 +++++++++++++++++++++++ library/ui/scrolling.factor | 4 ++-- library/ui/world.factor | 31 ++++++++++++++++++------ 15 files changed, 149 insertions(+), 42 deletions(-) create mode 100644 library/ui/menus.factor create mode 100644 library/ui/presentations.factor diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 1feb38e5da..8bebccd7e6 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -6,6 +6,8 @@ + ui: +- menu dragging +- hide menu after item selected - scrollable inspector - inspector needs prettier nesting - needs to look better @@ -16,9 +18,7 @@ - console: scroll to bottom - split preferred size and layouting - remove shelf/pile duplication -- menus -- layered gadget -- resizing and moving gadgets interactively with halo on top of gadget +- resizing and moving gadgets - faster layout - faster repaint diff --git a/examples/gadget-test.factor b/examples/gadget-test.factor index b594d15439..97cac9faad 100644 --- a/examples/gadget-test.factor +++ b/examples/gadget-test.factor @@ -74,6 +74,7 @@ USE: words : gadget-demo ( -- ) make-shapes - start-world ; + USE: shells + ui ; gadget-demo diff --git a/library/bootstrap/boot-stage2.factor b/library/bootstrap/boot-stage2.factor index f125f85b9d..be411a18d2 100644 --- a/library/bootstrap/boot-stage2.factor +++ b/library/bootstrap/boot-stage2.factor @@ -173,15 +173,16 @@ cpu "x86" = "mini" get not and [ "/library/ui/gestures.factor" "/library/ui/hand.factor" "/library/ui/layouts.factor" + "/library/ui/halo.factor" "/library/ui/world.factor" "/library/ui/labels.factor" "/library/ui/buttons.factor" "/library/ui/line-editor.factor" "/library/ui/editors.factor" - "/library/ui/halo.factor" "/library/ui/dialogs.factor" "/library/ui/events.factor" "/library/ui/scrolling.factor" + "/library/ui/presentations.factor" "/library/ui/panes.factor" "/library/ui/inspector.factor" ] [ diff --git a/library/ui/editors.factor b/library/ui/editors.factor index 29b6cdd299..17766a5785 100644 --- a/library/ui/editors.factor +++ b/library/ui/editors.factor @@ -55,7 +55,7 @@ TUPLE: editor line caret delegate ; request-focus ; : editor-actions ( editor -- ) - {{ + [ [[ [ gain-focus ] [ focus-editor ] ]] [[ [ lose-focus ] [ unfocus-editor ] ]] [[ [ button-down 1 ] [ click-editor ] ]] @@ -63,7 +63,7 @@ TUPLE: editor line caret delegate ; [[ [ "LEFT" ] [ [ left ] with-editor ] ]] [[ [ "RIGHT" ] [ [ right ] with-editor ] ]] [[ [ "CTRL" "k" ] [ [ line-clear ] with-editor ] ]] - }} clone swap set-gadget-gestures ; + ] swap add-actions ; : ( -- caret ) 0 0 0 0 diff --git a/library/ui/gestures.factor b/library/ui/gestures.factor index 4b10ea091f..e23adc6d8f 100644 --- a/library/ui/gestures.factor +++ b/library/ui/gestures.factor @@ -9,6 +9,9 @@ USING: alien generic hashtables kernel lists math sdl-event ; : set-action ( gadget quot gesture -- ) rot gadget-gestures set-hash ; +: add-actions ( alist gadget -- ) + swap [ unswons set-action ] each-with ; + : handle-gesture* ( gesture gadget -- ? ) tuck gadget-gestures hash* dup [ cdr call f diff --git a/library/ui/halo.factor b/library/ui/halo.factor index 0b5b8353e9..d230626b55 100644 --- a/library/ui/halo.factor +++ b/library/ui/halo.factor @@ -1,7 +1,9 @@ ! Copyright (C) 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: gadgets -USING: kernel math namespaces ; +USING: kernel math namespaces sdl ; + +! The halo is used to move and resize gadgets. : grab ( gadget hand -- ) [ swap screen-pos swap screen-pos - >rect ] 2keep diff --git a/library/ui/inspector.factor b/library/ui/inspector.factor index 17f85ba8fe..183336d34b 100644 --- a/library/ui/inspector.factor +++ b/library/ui/inspector.factor @@ -1,16 +1,9 @@ +! Copyright (C) 2005 Slava Pestov. +! See http://factor.sf.net/license.txt for BSD license. +IN: gadgets USING: gadgets generic hashtables kernel kernel-internals lists namespaces unparser vectors words ; -DEFER: inspect - -: ( obj -- gadget ) - dup unparse