]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/ui/gadgets/lists/lists.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[factor.git] / extra / ui / gadgets / lists / lists.factor
index 4b5ceac08613295c9b1269cd06d21cf52b8225d4..8730c0acc48330bd553edc4d7a93b3f2125c7dd1 100644 (file)
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors math.vectors classes.tuple math.rectangles colors
 kernel sequences models opengl math math.order namespaces
-ui.commands ui.gestures ui.render ui.gadgets
-ui.gadgets.labels ui.gadgets.scrollers
-ui.gadgets.presentations ui.gadgets.viewports ui.gadgets.packs ;
+ui.commands ui.gestures ui.render ui.gadgets ui.gadgets.labels
+ui.gadgets.scrollers ui.gadgets.presentations ui.gadgets.viewports
+ui.gadgets.packs ;
 IN: ui.gadgets.lists
 
 TUPLE: list < pack index presenter color hook ;
@@ -23,7 +23,7 @@ TUPLE: list < pack index presenter color hook ;
         list-theme ;
 
 : calc-bounded-index ( n list -- m )
-    control-value length 1- min 0 max ;
+    control-value length 1 - min 0 max ;
 
 : bound-index ( list -- )
     dup index>> over calc-bounded-index >>index drop ;
@@ -32,7 +32,7 @@ TUPLE: list < pack index presenter color hook ;
     hook>> [ [ list? ] find-parent ] prepend ;
 
 : <list-presentation> ( hook elt presenter -- gadget )
-    keep [ >label text-theme ] dip
+    [ call( elt -- obj ) ] [ drop ] 2bi [ >label text-theme ] dip
     <presentation>
     swap >>hook ; inline
 
@@ -57,9 +57,7 @@ M: list draw-gadget*
     origin get [
         dup color>> gl-color
         selected-rect [
-            dup loc>> [
-                dim>> gl-fill-rect
-            ] with-translation
+            rect-bounds gl-fill-rect
         ] when*
     ] with-translation ;
 
@@ -85,14 +83,14 @@ M: list focusable-child* drop t ;
     ] if ;
 
 : select-previous ( list -- )
-    [ index>> 1- ] keep select-index ;
+    [ index>> 1 - ] keep select-index ;
 
 : select-next ( list -- )
-    [ index>> 1+ ] keep select-index ;
+    [ index>> 1 + ] keep select-index ;
 
 : invoke-value-action ( list -- )
     dup list-empty? [
-        dup hook>> call
+        dup hook>> call( list -- )
     ] [
         [ index>> ] keep nth-gadget invoke-secondary
     ] if ;