bork
[clean-tests.git] / 7gui / test.icl
index 8bb3901..b76ee57 100644 (file)
@@ -1,12 +1,14 @@
 module test
 
+import StdMisc
 import Data.Func
 import Data.Tuple
 import System.Time
 
 import iTasks
-import iTasks.Extensions.DateTime
 import iTasks.UI.Editor.Common
+import iTasks.Extensions.DateTime
+import iTasks.Extensions.SVG.SVGEditor => qualified grid
 
 import qualified Data.Map as DM
 import Data.Map.GenJSON
@@ -15,7 +17,8 @@ import Data.Map.GenJSON
 //Start w = doTasks gui2 w
 //Start w = doTasks gui3 w
 //Start w = doTasks (get currentTimestamp >>- \t->gui4 30 t) w
-Start w = doTasks gui5 w
+//Start w = doTasks gui5 w
+Start w = doTasks gui6 w
        
 gui1 :: Int -> Task Int
 gui1 c = viewInformation "Counter" [] c
@@ -61,6 +64,7 @@ name name surname = {name=name, surname=surname}
 derive class iTask Name
 instance toString Name where toString n = n.Name.name +++ ", " +++ n.surname
 
+gui5 :: Task (Int, Name)
 gui5 = withShared ('DM'.fromList [(0, name "Emil" "Hans"), (1, name "Mustermann" "Max"), (2, name "Tisch" "Roman")]) \data->
                enterInformation "Filter prefix" []
        >&> \v->whileUnchanged (mapRead (fromMaybe " ") v) \filter->
@@ -73,3 +77,23 @@ gui5 = withShared ('DM'.fromList [(0, name "Emil" "Hans"), (1, name "Mustermann"
                    , OnAction (Action "update") $ withValue \(i, n)->Just $ upd ('DM'.put i n) data
                    , OnAction (Action "delete") $ withValue \(i, n)->Just $ upd ('DM'.del i) data
                    ]
+
+gui6 :: Task [(Real, Real, Real)]
+gui6 = updateInformation ()
+       [UpdateUsing id (const id) (fromSVGEditor svged)]
+       [(5.0, 5.0, 5.0)]
+
+svged :: SVGEditor [(Real, Real, Real)] [(Real, Real, Real)]
+svged = {initView=id, renderImage=renderImage, updModel=const id}
+where
+       renderImage _ images ts
+               # (_, images) = trace_stdout ("img: ", images)
+               = collage [(px x, px y)\\(_, x, y)<-images] [circle (px r)\\(r, _, _)<-images]
+               $ Host $ rect (px 100.0) (px 100.0)
+                       <@< {fill=toSVGColor "white"}
+                       <@< {onclick=clicker,local=False}
+
+       clicker m = jsTrace "click" [(5.0, 10.0, 10.0):m]
+
+import Debug.Trace, StdDebug
+import iTasks.UI.JavaScript