Files
kryon/tests/window_runtime_test.zi
T
waozi 9383e95e57 Add the GPU scene renderer, hosted widget aggregates and component packages
Restructure maintained components into per-widget source folders, add the
portable scene GPU renderer with GLSL shaders, hosted widget aggregates,
GTK theming and multi-target clipboard support, rebuild the guide with
theming guidance, and move the toolchain to the Ziran revision without
module root limits so the eighty component roots resolve everywhere.
2026-11-12 00:12:06 -03:00

85 lines
1.8 KiB
Ziran

#import "window_runtime"
#import "drawing_props"
sequence: s32;
cleared: Color;
hidden: bool;
minimized: bool;
closing: bool;
closed: bool;
#program_export "GetScreenWidth"
TestWidth :: () -> s32 {
return 640
}
#program_export "GetScreenHeight"
TestHeight :: () -> s32 {
return 480
}
#program_export "BeginDrawing"
TestBegin :: () {
sequence = sequence * 10 + 1
}
#program_export "ClearBackground"
TestClear :: (color: Color) {
sequence = sequence * 10 + 2
cleared = color
}
#program_export "EndDrawing"
TestEnd :: () {
sequence = sequence * 10 + 3
}
#program_export "CloseWindow"
TestClose :: () {
closed = true
}
#program_export "IsWindowHidden"
TestHidden :: () -> bool {
return hidden
}
#program_export "IsWindowMinimized"
TestMinimized :: () -> bool {
return minimized
}
#program_export "WindowShouldClose"
TestClosing :: () -> bool {
return closing
}
#program_export
main :: () -> s32 {
if WindowWidth() != 640 || WindowHeight() != 480 {
return 7
}
if WindowHidden() || WindowMinimized() || WindowClosing() {
return 1
}
hidden = true
if !WindowHidden() || WindowMinimized() || WindowClosing() {
return 2
}
hidden = false
minimized = true
if WindowHidden() || !WindowMinimized() || WindowClosing() {
return 3
}
// A hidden/minimized custom host still decides when to present a frame.
BeginWindowFrame()
ClearWindowFrame(Color.{11, 22, 33, 44})
EndWindowFrame()
if sequence != 123 || cleared.r != cast(u8)11 || cleared.g != cast(u8)22 ||
cleared.b != cast(u8)33 || cleared.a != cast(u8)44 {
return 4
}
closing = true
if !WindowClosing() || closed {
return 5
}
CloseNativeWindow()
if !closed {
return 6
}
return 0
}