mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-13 15:48:11 +07:00
cursor pos from left bottom window corner
This commit is contained in:
@@ -82,7 +82,7 @@ namespace e2d::imgui
|
||||
void imgui_event_listener::on_move_cursor(const v2f& pos) noexcept {
|
||||
const v2f real_size = window_.real_size().cast_to<f32>();
|
||||
if ( math::minimum(real_size) > 0.f ) {
|
||||
io_.MousePos = pos * (v2f(io_.DisplaySize) / real_size);
|
||||
io_.MousePos = v2f(pos.x, real_size.y - pos.y) / real_size * v2f(io_.DisplaySize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -362,7 +362,9 @@ namespace e2d
|
||||
double cursor_x = 0.0, cursor_y = 0.0;
|
||||
E2D_ASSERT(window);
|
||||
glfwGetCursorPos(window.get(), &cursor_x, &cursor_y);
|
||||
listener.on_move_cursor(make_vec2(cursor_x, cursor_y).cast_to<f32>());
|
||||
listener.on_move_cursor(make_vec2(
|
||||
cursor_x,
|
||||
math::numeric_cast<double>(real_size.y) - cursor_y).cast_to<f32>());
|
||||
return listener;
|
||||
}
|
||||
private:
|
||||
@@ -427,7 +429,7 @@ namespace e2d
|
||||
if ( self ) {
|
||||
self->for_all_listeners(
|
||||
&event_listener::on_move_cursor,
|
||||
make_vec2(pos_x, pos_y).cast_to<f32>());
|
||||
make_vec2(pos_x, math::numeric_cast<double>(self->real_size.y) - pos_y).cast_to<f32>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user