]> gitweb.factorcode.org Git - factor.git/commitdiff
add a resize-world generic to handle window resizes
authorJoe Groff <arcata@gmail.com>
Mon, 4 May 2009 03:01:35 +0000 (22:01 -0500)
committerJoe Groff <arcata@gmail.com>
Mon, 4 May 2009 03:01:35 +0000 (22:01 -0500)
basis/ui/gadgets/worlds/worlds.factor
basis/ui/ui.factor

index 837cf822dc2f6c3fed9c544145b98259bf586928..31b5a137a34a801949377ac5cc169e025e9064d5 100755 (executable)
@@ -24,6 +24,7 @@ TUPLE: world-attributes
     status
     gadgets
     { pixel-format-attributes initial: $ default-world-pixel-format-attributes } ;
+
 C: <world-attributes> world-attributes
 
 : find-world ( gadget -- world/f ) [ world? ] find-parent ;
@@ -97,10 +98,22 @@ flush-layout-cache-hook [ [ ] ] initialize
 GENERIC: begin-world ( world -- )
 GENERIC: end-world ( world -- )
 
+GENERIC: resize-world ( world -- )
+
 M: world begin-world
     drop ;
 M: world end-world
     drop ;
+M: world resize-world
+    drop ;
+
+M: world (>>dim)
+    [ call-next-method ]
+    [
+        dup handle>>
+        [ select-gl-context resize-world ]
+        [ drop ] if*
+    ] bi ;
 
 GENERIC: draw-world* ( world -- )
 
index 0d15d7d57a7d7c4358c39af5edf7a55ee1a231e2..d07403836a2ba5cc02238ad5fffc9894be59fe67 100644 (file)
@@ -51,13 +51,16 @@ SYMBOL: windows
     focus-path f swap focus-gestures ;
 
 : try-to-open-window ( world -- )
-    [ (open-window) ]
-    [ handle>> select-gl-context ]
-    [
-        [ begin-world ]
-        [ [ handle>> (close-window) ] [ ui-error ] bi* ]
-        recover
-    ] tri ;
+    {
+        [ (open-window) ]
+        [ handle>> select-gl-context ]
+        [
+            [ begin-world ]
+            [ [ handle>> (close-window) ] [ ui-error ] bi* ]
+            recover
+        ]
+        [ resize-world ]
+    } cleave ;
 
 M: world graft*
     [ try-to-open-window ]