From e9f8379564a799704b29363a95e79ea294917542 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Fri, 29 Aug 2008 15:47:36 -0500 Subject: [PATCH 01/37] ui.clipboards: use new accessors --- basis/ui/clipboards/clipboards.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/ui/clipboards/clipboards.factor b/basis/ui/clipboards/clipboards.factor index 4ee54cd833..5cd2974dbd 100644 --- a/basis/ui/clipboards/clipboards.factor +++ b/basis/ui/clipboards/clipboards.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2006, 2007 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel ui.gadgets ui.gestures namespaces ; +USING: kernel accessors ui.gadgets ui.gestures namespaces ; IN: ui.clipboards ! Two text transfer buffers @@ -14,7 +14,7 @@ M: object paste-clipboard GENERIC: copy-clipboard ( string gadget clipboard -- ) -M: object copy-clipboard nip set-clipboard-contents ; +M: object copy-clipboard nip (>>contents) ; SYMBOL: clipboard SYMBOL: selection From 04f8eaf220706d04c392d4898626b0addf223b1f Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Fri, 29 Aug 2008 18:44:19 -0500 Subject: [PATCH 02/37] ui.*: Use new accessors --- basis/ui/clipboards/clipboards.factor | 4 ++- basis/ui/freetype/freetype-docs.factor | 35 +++++++++++++++---- basis/ui/freetype/freetype.factor | 10 +++--- basis/ui/gadgets/books/books.factor | 2 +- basis/ui/gadgets/buttons/buttons.factor | 8 ++--- basis/ui/gadgets/editors/editors.factor | 2 +- basis/ui/gadgets/gadgets.factor | 2 +- basis/ui/gadgets/grids/grids.factor | 9 ++--- .../ui/gadgets/incremental/incremental.factor | 10 +++--- basis/ui/gadgets/labelled/labelled.factor | 4 +-- basis/ui/gadgets/lists/lists.factor | 4 +-- basis/ui/gadgets/packs/packs.factor | 10 +++--- basis/ui/gadgets/panes/panes.factor | 8 ++--- basis/ui/gadgets/paragraphs/paragraphs.factor | 4 +-- basis/ui/gadgets/sliders/sliders.factor | 14 ++++---- basis/ui/gadgets/viewports/viewports.factor | 9 +++-- basis/ui/gadgets/worlds/worlds.factor | 6 ++-- basis/ui/gestures/gestures.factor | 8 ++--- basis/ui/render/render.factor | 12 +++---- basis/ui/traverse/traverse.factor | 10 +++--- basis/ui/ui.factor | 12 +++---- 21 files changed, 104 insertions(+), 79 deletions(-) diff --git a/basis/ui/clipboards/clipboards.factor b/basis/ui/clipboards/clipboards.factor index 5cd2974dbd..235c74da0b 100644 --- a/basis/ui/clipboards/clipboards.factor +++ b/basis/ui/clipboards/clipboards.factor @@ -1,6 +1,8 @@ ! Copyright (C) 2006, 2007 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. + USING: kernel accessors ui.gadgets ui.gestures namespaces ; + IN: ui.clipboards ! Two text transfer buffers @@ -14,7 +16,7 @@ M: object paste-clipboard GENERIC: copy-clipboard ( string gadget clipboard -- ) -M: object copy-clipboard nip (>>contents) ; +M: object copy-clipboard nip set-clipboard-contents ; SYMBOL: clipboard SYMBOL: selection diff --git a/basis/ui/freetype/freetype-docs.factor b/basis/ui/freetype/freetype-docs.factor index 855df9f564..ef01c6756c 100755 --- a/basis/ui/freetype/freetype-docs.factor +++ b/basis/ui/freetype/freetype-docs.factor @@ -16,12 +16,35 @@ HELP: init-freetype { $notes "Do not call this word if you are using the UI." } ; HELP: font -{ $class-description "A font which has been loaded by FreeType. Font instances have the following slots:" - { $list - { { $link font-ascent } ", " { $link font-descent } ", " { $link font-height } " - metrics." } - { { $link font-handle } " - alien pointer to an " { $snippet "FT_Face" } "." } - { { $link font-widths } " - sequence of character widths. Use " { $link char-width } " and " { $link string-width } " to compute string widths instead of reading this sequence directly." } - } + +{ $class-description + +"A font which has been loaded by FreeType. Font instances have the following slots:" + +{ + $list + { + { $snippet "ascent" } ", " + { $snippet "descent" } ", " + { $snippet "height" } " - metrics." + } + + { + { $snippet "handle" } + " - alien pointer to an " + { $snippet "FT_Face" } "." + } + + { + { $snippet "widths" } + " - sequence of character widths. Use " + { $snippet "width" } + " and " + { $snippet "width" } + " to compute string widths instead of reading this sequence directly." + } +} + } ; HELP: close-freetype diff --git a/basis/ui/freetype/freetype.factor b/basis/ui/freetype/freetype.factor index 487da931eb..7042811881 100755 --- a/basis/ui/freetype/freetype.factor +++ b/basis/ui/freetype/freetype.factor @@ -33,7 +33,7 @@ ascent descent height handle widths ; M: font hashcode* drop font hashcode* ; -: close-font ( font -- ) font-handle FT_Done_Face ; +: close-font ( font -- ) handle>> FT_Done_Face ; : close-freetype ( -- ) global [ @@ -111,11 +111,11 @@ M: freetype-renderer open-font ( font -- open-font ) freetype drop open-fonts get [ ] cache ; : load-glyph ( font char -- glyph ) - >r font-handle dup r> 0 FT_Load_Char + >r handle>> dup r> 0 FT_Load_Char freetype-error face-glyph ; : char-width ( open-font char -- w ) - over font-widths [ + over widths>> [ dupd load-glyph glyph-hori-advance ft-ceil ] cache nip ; @@ -123,7 +123,7 @@ M: freetype-renderer string-width ( open-font string -- w ) 0 -rot [ char-width + ] with each ; M: freetype-renderer string-height ( open-font string -- h ) - drop font-height ; + drop height>> ; : glyph-size ( glyph -- dim ) dup glyph-hori-advance ft-ceil @@ -166,7 +166,7 @@ M: freetype-renderer string-height ( open-font string -- h ) : glyph-texture-loc ( glyph font -- loc ) over glyph-hori-bearing-x ft-floor -rot - font-ascent swap glyph-hori-bearing-y - ft-floor 2array ; + ascent>> swap glyph-hori-bearing-y - ft-floor 2array ; : glyph-texture-size ( glyph -- dim ) [ glyph-bitmap-width next-power-of-2 ] diff --git a/basis/ui/gadgets/books/books.factor b/basis/ui/gadgets/books/books.factor index 3ff9c63726..161677b56a 100755 --- a/basis/ui/gadgets/books/books.factor +++ b/basis/ui/gadgets/books/books.factor @@ -5,7 +5,7 @@ IN: ui.gadgets.books TUPLE: book < gadget ; -: hide-all ( book -- ) gadget-children [ hide-gadget ] each ; +: hide-all ( book -- ) children>> [ hide-gadget ] each ; : current-page ( book -- gadget ) [ control-value ] keep nth-gadget ; diff --git a/basis/ui/gadgets/buttons/buttons.factor b/basis/ui/gadgets/buttons/buttons.factor index 3f52ee9511..09bf036c9a 100755 --- a/basis/ui/gadgets/buttons/buttons.factor +++ b/basis/ui/gadgets/buttons/buttons.factor @@ -119,9 +119,9 @@ M: checkmark-paint draw-interior black black - over set-gadget-interior + over (>>interior) black - swap set-gadget-boundary ; + swap (>>boundary) ; : ( -- gadget ) @@ -165,9 +165,9 @@ M: radio-paint draw-boundary black black - over set-gadget-interior + over (>>interior) black - swap set-gadget-boundary ; + swap (>>boundary) ; : ( -- gadget ) diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor index 301121cdcc..6e09fd73b2 100755 --- a/basis/ui/gadgets/editors/editors.factor +++ b/basis/ui/gadgets/editors/editors.factor @@ -121,7 +121,7 @@ M: editor ungraft* line-height 0 swap 2array ; : scroll>caret ( editor -- ) - dup gadget-graft-state second [ + dup graft-state>> second [ dup caret-loc over caret-dim { 1 0 } v+ over scroll>rect ] when drop ; diff --git a/basis/ui/gadgets/gadgets.factor b/basis/ui/gadgets/gadgets.factor index 9a5f53ac4a..bcf908571c 100755 --- a/basis/ui/gadgets/gadgets.factor +++ b/basis/ui/gadgets/gadgets.factor @@ -150,7 +150,7 @@ DEFER: relayout : invalidate* ( gadget -- ) \ invalidate* over (>>layout-state) dup forget-pref-dim - dup gadget-root? + dup root?>> [ layout-later ] [ parent>> [ relayout ] when* ] if ; : relayout ( gadget -- ) diff --git a/basis/ui/gadgets/grids/grids.factor b/basis/ui/gadgets/grids/grids.factor index eb2cdad801..4b60b9e5c8 100644 --- a/basis/ui/gadgets/grids/grids.factor +++ b/basis/ui/gadgets/grids/grids.factor @@ -77,13 +77,14 @@ M: grid pref-dim* M: grid layout* dup compute-grid grid-layout ; M: grid children-on ( rect gadget -- seq ) - dup gadget-children empty? [ - 2drop f - ] [ + dup children>> empty? + [ 2drop f ] + [ { 0 1 } swap grid>> [ 0 fast-children-on ] keep concat - ] if ; + ] + if ; M: grid gadget-text* grid>> diff --git a/basis/ui/gadgets/incremental/incremental.factor b/basis/ui/gadgets/incremental/incremental.factor index 8c227d76ce..826be68b97 100755 --- a/basis/ui/gadgets/incremental/incremental.factor +++ b/basis/ui/gadgets/incremental/incremental.factor @@ -23,7 +23,7 @@ TUPLE: incremental < pack cursor ; { 0 0 } >>cursor ; M: incremental pref-dim* - dup gadget-layout-state [ + dup layout-state>> [ dup call-next-method over set-incremental-cursor ] when incremental-cursor ; @@ -31,13 +31,13 @@ M: incremental pref-dim* [ swap rect-dim swap incremental-cursor 2dup v+ >r vmax r> - ] keep gadget-orientation set-axis ; + ] keep orientation>> set-axis ; : update-cursor ( gadget incremental -- ) [ next-cursor ] keep set-incremental-cursor ; : incremental-loc ( gadget incremental -- ) - dup incremental-cursor swap gadget-orientation v* + dup incremental-cursor swap orientation>> v* swap set-rect-loc ; : prefer-incremental ( gadget -- ) @@ -51,11 +51,11 @@ M: incremental pref-dim* 2dup incremental-loc tuck update-cursor dup prefer-incremental - gadget-parent [ invalidate* ] when* ; + parent>> [ invalidate* ] when* ; : clear-incremental ( incremental -- ) not-in-layout dup (clear-gadget) dup forget-pref-dim { 0 0 } over set-incremental-cursor - gadget-parent [ relayout ] when* ; + parent>> [ relayout ] when* ; diff --git a/basis/ui/gadgets/labelled/labelled.factor b/basis/ui/gadgets/labelled/labelled.factor index 077e125b9f..49ccd5aabe 100755 --- a/basis/ui/gadgets/labelled/labelled.factor +++ b/basis/ui/gadgets/labelled/labelled.factor @@ -29,11 +29,11 @@ M: labelled-gadget focusable-child* labelled-gadget-content ; gray close-box swap ; : title-theme ( gadget -- ) - { 1 0 } over set-gadget-orientation + { 1 0 } over (>>orientation) T{ gradient f { T{ rgba f 0.65 0.65 1.0 1.0 } T{ rgba f 0.65 0.45 1.0 1.0 } - } } swap set-gadget-interior ; + } } swap (>>interior) ; : ( text -- label )