]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.gadgets.slate: some cleanup
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 2 Sep 2023 03:38:29 +0000 (20:38 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 2 Sep 2023 03:38:29 +0000 (20:38 -0700)
extra/ui/gadgets/slate/slate.factor

index 79cb015be300373c613248eb4c4a7a944c8c9ffd..6dbb1357439a9c9688f0ae7f149997eeba277454 100644 (file)
@@ -1,18 +1,13 @@
 ! Copyright (C) 2009 Eduardo Cavazos
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel namespaces opengl ui.render ui.gadgets accessors ;
 
-IN: ui.gadgets.slate
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+USING: accessors arrays combinators kernel math opengl opengl.gl
+sequences ui.gadgets ui.gadgets.worlds ui.render ;
 
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+IN: ui.gadgets.slate
 
 TUPLE: slate < gadget action pdim graft ungraft ;
 
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
 : init-slate ( slate -- slate )
   [ ]         >>action
   { 200 200 } >>pdim
@@ -20,83 +15,41 @@ TUPLE: slate < gadget action pdim graft ungraft ;
   [ ]         >>ungraft ;
 
 : <slate> ( action -- slate )
-  slate new
-    init-slate
-    swap >>action ;
+    slate new
+        init-slate
+        swap >>action ;
 
 M: slate pref-dim* ( slate -- dim ) pdim>> ;
 
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-USING: combinators arrays sequences math
-       opengl.gl ui.gadgets.worlds ;
-
 : width ( rect -- w ) dim>> first ;
+
 : height ( rect -- h ) dim>> second ;
 
 : screen-y* ( gadget -- loc )
-  {
-    [ find-world height ]
-    [ screen-loc second ]
-    [ height ]
-  }
-  cleave
-  + - ;
+    [ find-world height ] [ screen-loc second ] [ height ] tri + - ;
 
 : screen-loc* ( gadget -- loc )
-  {
-    [ screen-loc first ]
-    [ screen-y* ]
-  }
-  cleave
-  2array ;
+    [ screen-loc first ] [ screen-y* ] bi 2array ;
 
 : setup-viewport ( gadget -- gadget )
-  dup
-  {
-    [ screen-loc* ]
-    [ dim>>       ]
-  }
-  cleave
-  gl-viewport ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    dup { [ screen-loc* ] [ dim>> ] } cleave gl-viewport ;
 
 : default-coordinate-system ( gadget -- gadget )
-  dup
-  {
-    [ drop 0 ]
-    [ width 1 - ]
-    [ height 1 - ]
-    [ drop 0 ]
-  }
-  cleave
-  -1 1
-  glOrtho ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    dup {
+        [ drop 0 ] [ width 1 - ] [ height 1 - ] [ drop 0 ]
+    } cleave -1 1 glOrtho ;
 
-M: slate graft*   ( slate -- ) graft>>   call( -- ) ;
-M: slate ungraft* ( slate -- ) ungraft>> call( -- ) ;
+M: slate graft* graft>> call( -- ) ;
 
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+M: slate ungraft* ungraft>> call( -- ) ;
 
 GENERIC: establish-coordinate-system ( gadget -- gadget )
 
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-M: slate establish-coordinate-system ( slate -- slate )
-   default-coordinate-system ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+M: slate establish-coordinate-system default-coordinate-system ;
 
 GENERIC: draw-slate ( slate -- slate )
 
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-M: slate draw-slate ( slate -- slate ) dup action>> call( slate -- slate ) ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+M: slate draw-slate dup action>> call( slate -- slate ) ;
 
 M: slate draw-gadget* ( slate -- )
 
@@ -120,5 +73,3 @@ M: slate draw-gadget* ( slate -- )
    setup-viewport
    drop
    drop ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!