Skip to content

Commit

Permalink
Error checking, screen.size, and automated testing. (#116)
Browse files Browse the repository at this point in the history
* More error checking with windows OpenGL
* Add function to compute screen size.
* Add functions to aid automated testing.
  • Loading branch information
treeform authored Nov 19, 2023
1 parent 6f500b3 commit 4333b81
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/windy/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,10 @@ proc `[]=`*(headers: var seq[HttpHeader], key, value: string) =
header.value = value
return
headers.add(HttpHeader(key: key, value: value))

proc size*(screen: Screen): IVec2 =
## Returns the size of the screen.
ivec2(
(screen.right - screen.left).int32,
(screen.bottom - screen.top).int32
)
15 changes: 15 additions & 0 deletions src/windy/platforms/win32/platform.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2354,3 +2354,18 @@ proc pollEvents*() =

when defined(windyUseStdHttp):
pollHttp()

proc forceMousePos*(window: Window, mousePos: IVec2) =
## Forces mouse position to a place.
## This is used for simulating UI tests.
window.state.mousePos = mousePos

proc forceButtonPress*(window: Window, button: Button) =
## Forces button press.
## This is used for simulating UI tests.
window.handleButtonPress(button)

proc forceButtonReleased*(window: Window, button: Button) =
## Forces button release.
## This is used for simulating UI tests.
window.handleButtonRelease(button)

0 comments on commit 4333b81

Please sign in to comment.