mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Add more procedures for window related positions
This commit is contained in:
Vendored
+23
-5
@@ -6,7 +6,14 @@ foreign import dom_lib "odin_dom"
|
|||||||
@(default_calling_convention="contextless")
|
@(default_calling_convention="contextless")
|
||||||
foreign dom_lib {
|
foreign dom_lib {
|
||||||
get_element_value_f64 :: proc(id: string) -> f64 ---
|
get_element_value_f64 :: proc(id: string) -> f64 ---
|
||||||
set_element_value :: proc(id: string, value: f64) ---
|
set_element_value_f64 :: proc(id: string, value: f64) ---
|
||||||
|
|
||||||
|
set_element_value_string :: proc(id: string, value: string) ---
|
||||||
|
get_element_value_string_length :: proc(id: string) -> int ---
|
||||||
|
|
||||||
|
device_pixel_ratio :: proc() -> f64 ---
|
||||||
|
|
||||||
|
window_set_scroll :: proc(x, y: f64) ---
|
||||||
}
|
}
|
||||||
|
|
||||||
get_element_value_string :: proc "contextless" (id: string, buf: []byte) -> string {
|
get_element_value_string :: proc "contextless" (id: string, buf: []byte) -> string {
|
||||||
@@ -47,12 +54,23 @@ get_bounding_client_rect :: proc "contextless" (id: string) -> (rect: Rect) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
get_window_rect :: proc "contextless" () -> (rect: Rect) {
|
window_get_rect :: proc "contextless" () -> (rect: Rect) {
|
||||||
@(default_calling_convention="contextless")
|
@(default_calling_convention="contextless")
|
||||||
foreign dom_lib {
|
foreign dom_lib {
|
||||||
@(link_name="get_window_rect")
|
@(link_name="window_get_rect")
|
||||||
_get_window_rect :: proc(rect: ^Rect) ---
|
_window_get_rect :: proc(rect: ^Rect) ---
|
||||||
}
|
}
|
||||||
_get_window_rect(&rect)
|
_window_get_rect(&rect)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
window_get_scroll :: proc "contextless" () -> (x, y: f64) {
|
||||||
|
@(default_calling_convention="contextless")
|
||||||
|
foreign dom_lib {
|
||||||
|
@(link_name="window_get_scroll")
|
||||||
|
_window_get_scroll :: proc(scroll: ^[2]f64) ---
|
||||||
|
}
|
||||||
|
scroll := [2]f64{x, y}
|
||||||
|
_window_get_scroll(&scroll)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Vendored
+32
-2
@@ -1533,6 +1533,14 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
get_element_value_string_length: (id_ptr, id_len) => {
|
||||||
|
let id = wasmMemoryInterface.loadString(id_ptr, id_len);
|
||||||
|
let element = document.getElementById(id);
|
||||||
|
if (element) {
|
||||||
|
return element.value.length;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
get_element_min_max: (ptr_array2_f64, id_ptr, id_len) => {
|
get_element_min_max: (ptr_array2_f64, id_ptr, id_len) => {
|
||||||
let id = wasmMemoryInterface.loadString(id_ptr, id_len);
|
let id = wasmMemoryInterface.loadString(id_ptr, id_len);
|
||||||
let element = document.getElementById(id);
|
let element = document.getElementById(id);
|
||||||
@@ -1542,13 +1550,22 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) {
|
|||||||
values[1] = element.max;
|
values[1] = element.max;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
set_element_value: (id_ptr, id_len, value) => {
|
set_element_value_f64: (id_ptr, id_len, value) => {
|
||||||
let id = wasmMemoryInterface.loadString(id_ptr, id_len);
|
let id = wasmMemoryInterface.loadString(id_ptr, id_len);
|
||||||
let element = document.getElementById(id);
|
let element = document.getElementById(id);
|
||||||
if (element) {
|
if (element) {
|
||||||
element.value = value;
|
element.value = value;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
set_element_value_string: (id_ptr, id_len, value_ptr, value_id) => {
|
||||||
|
let id = wasmMemoryInterface.loadString(id_ptr, id_len);
|
||||||
|
let value = wasmMemoryInterface.loadString(value_ptr, value_len);
|
||||||
|
let element = document.getElementById(id);
|
||||||
|
if (element) {
|
||||||
|
element.value = value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
get_bounding_client_rect: (rect_ptr, id_ptr, id_len) => {
|
get_bounding_client_rect: (rect_ptr, id_ptr, id_len) => {
|
||||||
let id = wasmMemoryInterface.loadString(id_ptr, id_len);
|
let id = wasmMemoryInterface.loadString(id_ptr, id_len);
|
||||||
@@ -1562,7 +1579,7 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) {
|
|||||||
values[3] = rect.bottom - rect.top;
|
values[3] = rect.bottom - rect.top;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
get_window_rect: (rect_ptr) => {
|
window_get_rect: (rect_ptr) => {
|
||||||
let values = wasmMemoryInterface.loadF64Array(rect_ptr, 4);
|
let values = wasmMemoryInterface.loadF64Array(rect_ptr, 4);
|
||||||
values[0] = window.screenX;
|
values[0] = window.screenX;
|
||||||
values[1] = window.screenY;
|
values[1] = window.screenY;
|
||||||
@@ -1570,6 +1587,19 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) {
|
|||||||
values[3] = window.screen.height;
|
values[3] = window.screen.height;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
window_get_scroll: (pos_ptr) => {
|
||||||
|
let values = wasmMemoryInterface.loadF64Array(pos_ptr, 2);
|
||||||
|
values[0] = window.scrollX;
|
||||||
|
values[1] = window.scrollY;
|
||||||
|
},
|
||||||
|
window_set_scroll: (x, y) => {
|
||||||
|
window.scroll(x, y);
|
||||||
|
},
|
||||||
|
|
||||||
|
device_pixel_ratio: () => {
|
||||||
|
return window.devicePixelRatio;
|
||||||
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"webgl": webglContext.getWebGL1Interface(),
|
"webgl": webglContext.getWebGL1Interface(),
|
||||||
|
|||||||
Reference in New Issue
Block a user