Input: Added viewport local mouse position | Transform: Added default parameter values for create_transform procedure
This commit is contained in:
10
ui/ui.jai
10
ui/ui.jai
@@ -38,6 +38,7 @@ Interaction_State :: struct {
|
||||
|
||||
editing: bool;
|
||||
|
||||
local_mouse_coordinates: Vector2; // Coordinates inside the rect in the range [0,1]
|
||||
normalized_local_mouse_coordinates: Vector2; // Coordinates inside the rect in the range [0,1]
|
||||
}
|
||||
|
||||
@@ -928,9 +929,12 @@ ui_update_input :: () {
|
||||
|
||||
for *box: ui_state.boxes {
|
||||
if box.flags & .CLICKABLE {
|
||||
normalized_local_mouse_coordinates: Vector2; // Coordinates inside the rect in the range [0,1]
|
||||
box.interaction.normalized_local_mouse_coordinates.x = clamp(mouse_x - box.rect.x, 0.0, box.rect.w) / box.rect.w;
|
||||
box.interaction.normalized_local_mouse_coordinates.y = clamp(mouse_y - box.rect.y, 0.0, box.rect.h) / box.rect.h;
|
||||
local_mouse: Vector2;
|
||||
local_mouse.x = clamp(mouse_x - box.rect.x, 0.0, box.rect.w);
|
||||
local_mouse.y = clamp(mouse_y - box.rect.y, 0.0, box.rect.h);
|
||||
box.interaction.local_mouse_coordinates = local_mouse;
|
||||
box.interaction.normalized_local_mouse_coordinates.x = local_mouse.x / box.rect.w;
|
||||
box.interaction.normalized_local_mouse_coordinates.y = local_mouse.y / box.rect.h;
|
||||
if box.interaction.clicked {
|
||||
box.interaction.clicked = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user