]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.gadgets.incremental: trivial scrolling, maybe solves #1488?
authorBjörn Lindqvist <bjourne@gmail.com>
Fri, 16 Oct 2015 08:55:48 +0000 (10:55 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Fri, 16 Oct 2015 08:55:48 +0000 (10:55 +0200)
basis/ui/gadgets/incremental/incremental.factor

index 952252a5cd1cd9711429ef1050a382ff4bc8e106..55d4ca612af23ba020074d950db6b7cdfde854bd 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators kernel math.vectors namespaces
-ui.gadgets ui.gadgets.packs ui.gadgets.private ;
+USING: accessors combinators kernel math math.vectors namespaces
+sequences ui.gadgets ui.gadgets.packs ui.gadgets.private ;
 IN: ui.gadgets.incremental
 
 TUPLE: incremental < pack cursor ;
@@ -34,8 +34,16 @@ M: incremental pref-dim*
 
 M: incremental dim-changed drop ;
 
+: scroll-children ( incremental -- )
+    dup children>> length 200,000 > [
+        ! We let the length oscillate between 100k-200k, so we don't
+        ! have to tail* the sequence on every gadget add.
+        [ 100,000 short tail* ] change-children drop
+    ] [ drop ] if ;
+
 : add-incremental ( gadget incremental -- )
     not-in-layout
+    dup scroll-children
     2dup (add-gadget)
     t in-layout? [
         {