more fixes
This commit is contained in:
parent
41df9b769f
commit
443b24de3e
3 changed files with 24 additions and 11 deletions
|
|
@ -256,6 +256,8 @@ proc redraw*() =
|
||||||
else:
|
else:
|
||||||
dodraw()
|
dodraw()
|
||||||
|
|
||||||
|
proc redrawForce*() = dodraw()
|
||||||
|
|
||||||
proc init(ev: Event) =
|
proc init(ev: Event) =
|
||||||
reqFrame(dodraw)
|
reqFrame(dodraw)
|
||||||
|
|
||||||
|
|
@ -263,6 +265,12 @@ proc setRenderer*(renderer: proc (): VNode) =
|
||||||
dorender = renderer
|
dorender = renderer
|
||||||
window.onload = init
|
window.onload = init
|
||||||
|
|
||||||
|
proc setRendererOnly*(renderer: proc (): VNode) =
|
||||||
|
dorender = renderer
|
||||||
|
|
||||||
|
proc setOnloadOnly*() =
|
||||||
|
window.onload = init
|
||||||
|
|
||||||
proc addEventHandler*(n: VNode; k: EventKind; action: EventHandler) =
|
proc addEventHandler*(n: VNode; k: EventKind; action: EventHandler) =
|
||||||
## Implements the foundation of Karax's event management.
|
## Implements the foundation of Karax's event management.
|
||||||
## Karax DSL transforms ``tag(onEvent = handler)`` to
|
## Karax DSL transforms ``tag(onEvent = handler)`` to
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,11 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="App"></div>
|
<div id="App"></div>
|
||||||
<script src="https://localvoid.github.io/uibench-base/0.1.0/uibench.js"></script>
|
|
||||||
<script src="nimcache/nim_uibench.js" type="text/javascript"></script>
|
|
||||||
|
|
||||||
<div id="ROOT"></div>
|
<div id="ROOT"></div>
|
||||||
|
|
||||||
|
<script src="https://localvoid.github.io/uibench-base/0.1.0/uibench.js"></script>
|
||||||
|
<script src="nimcache/nim_uibench.js" type="text/javascript"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -26,11 +26,6 @@ type
|
||||||
anim: AnimState
|
anim: AnimState
|
||||||
tree: TreeState
|
tree: TreeState
|
||||||
|
|
||||||
proc init*(a: cstring, b: cstring) {.importc: "uibench.init", nodecl.}
|
|
||||||
proc run*(a: proc(state: AppState), b: proc(samples: RootRef)) {.importc: "uibench.run", nodecl.}
|
|
||||||
|
|
||||||
init(cstring"Nim-karax", cstring"0.6.1")
|
|
||||||
|
|
||||||
var container = document.getElementById("#App")
|
var container = document.getElementById("#App")
|
||||||
var appState: AppState
|
var appState: AppState
|
||||||
|
|
||||||
|
|
@ -98,7 +93,9 @@ proc treeCreateVNode(data: TreeState): VNode =
|
||||||
|
|
||||||
|
|
||||||
proc update(): VNode =
|
proc update(): VNode =
|
||||||
if appState == nil: return newVNode(VNodeKind.tdiv)
|
if appState == nil:
|
||||||
|
kout cstring"stupid fuck"
|
||||||
|
return newVNode(VNodeKind.tdiv)
|
||||||
let location = appState.location
|
let location = appState.location
|
||||||
var children: VNode = nil
|
var children: VNode = nil
|
||||||
if location == cstring"table":
|
if location == cstring"table":
|
||||||
|
|
@ -113,15 +110,22 @@ proc update(): VNode =
|
||||||
children
|
children
|
||||||
|
|
||||||
proc a(state: AppState) =
|
proc a(state: AppState) =
|
||||||
|
kout cstring"setting state here"
|
||||||
appState = state
|
appState = state
|
||||||
redraw()
|
redrawForce()
|
||||||
|
|
||||||
proc b(samples: RootRef) =
|
proc b(samples: RootRef) =
|
||||||
|
kout cstring"end called"
|
||||||
#document.body.innerHTML = cstring"<pre>" & toJson(samples) & cstring"</pre>"
|
#document.body.innerHTML = cstring"<pre>" & toJson(samples) & cstring"</pre>"
|
||||||
#redraw()
|
#redraw()
|
||||||
discard
|
discard
|
||||||
|
|
||||||
kout cstring"updating"
|
proc init*(a: cstring, b: cstring) {.importc: "uibench.init", nodecl.}
|
||||||
setRenderer update
|
proc run*(a: proc(state: AppState), b: proc(samples: RootRef)) {.importc: "uibench.run", nodecl.}
|
||||||
|
|
||||||
|
init(cstring"Nim-karax", cstring"0.6.1")
|
||||||
|
|
||||||
|
setRendererOnly update
|
||||||
kout cstring"running"
|
kout cstring"running"
|
||||||
|
|
||||||
run(a, b)
|
run(a, b)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue