Skip to content

Commit

Permalink
Removed compiler warnings, added a hide formulas option, now hiding c…
Browse files Browse the repository at this point in the history
…ollapsable icon on hidden formulas instead of showing an x
  • Loading branch information
Patitotective committed Aug 17, 2024
1 parent 43a6932 commit 4900b45
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 142 deletions.
15 changes: 7 additions & 8 deletions src/frontend.nim
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
## This is the module that manipulates the frontend using karax

import std/[dom, json, asyncjs, jsffi, math, jsconsole, enumerate, sugar, strformat, strutils, tables]
import karax/[karax, kajax, karaxdsl, vdom, vstyles, jdict, languages]
import std/[dom, jsffi]
import karax/[karax, vdom]

# import matter
import frontend/[routes, utils, patterns]
import frontend/simulations/[parabola, utils]

type
Expand Down Expand Up @@ -33,12 +32,12 @@ proc newState(): State =
)
result.parabola.addEventListeners()

proc navigateTo(uri: cstring) =
# Add uri to the history
window.history.pushState(0, cstring"", uri)
#proc navigateTo(uri: cstring) =
# # Add uri to the history
# window.history.pushState(0, cstring"", uri)

# Fire the popState event.
dom.window.dispatchEvent(dom.newEvent("popstate"))
# # Fire the popState event.
# dom.window.dispatchEvent(dom.newEvent("popstate"))

var state = newState()

Expand Down
29 changes: 16 additions & 13 deletions src/frontend/simulations/mouseconstraint.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,32 @@ import std/[jsffi]

import matter

when defined(nimHasUsed):
{.used.}

Matter.MouseConstraint.onmousedown = proc(mouseCons, bodies: JsObject) =
let
mouse = mouseCons.mouse
cons = mouseCons.constraint
body = mouseCons.body

if to(not cons.bodyB, bool):
for body in bodies.to(seq[JsObject]):
if Matter.Bounds.contains(body.bounds, mouse.position).to(bool) and
Matter.Detector.canCollide(body.collisionFilter, mouseCons.collisionFilter).to(bool):
var i = if body.parts.length.to(int) > 1: 1 else: 0
while i < body.parts.length.to(int):
let part = body.parts[i]
for b in bodies.to(seq[JsObject]):
if Matter.Bounds.contains(b.bounds, mouse.position).to(bool) and
Matter.Detector.canCollide(b.collisionFilter, mouseCons.collisionFilter).to(bool):
var i = if b.parts.length.to(int) > 1: 1 else: 0
while i < b.parts.length.to(int):
let part = b.parts[i]
if Matter.Vertices.contains(part.vertices, mouse.position).to(bool):
cons.pointA = mouse.position
mouseCons.body = body
mouseCons.body = b
cons.bodyB = mouseCons.body
cons.pointB = jsVec(mouse.position.x - body.position.x,
mouse.position.y - body.position.y)
cons.angleB = body.angle
cons.pointB = jsVec(mouse.position.x - b.position.x,
mouse.position.y - b.position.y)
cons.angleB = b.angle

Matter.Sleeping.set(body, false)
Matter.Events.trigger(mouseCons, "startdrag", JsObject{mouse: mouse, body: body})
Matter.Sleeping.set(b, false)
Matter.Events.trigger(mouseCons, "startdrag", JsObject{mouse: mouse, body: b})

break
inc i
Expand All @@ -46,7 +49,7 @@ Matter.MouseConstraint.update = proc(mouseCons: JsObject) =
let
mouse = mouseCons.mouse
cons = mouseCons.constraint
body = mouseCons.body
#body = mouseCons.body

if to(cons.bodyB, bool):
Matter.Sleeping.set(cons.bodyB, false)
Expand Down
Loading

0 comments on commit 4900b45

Please sign in to comment.