Fix warp_mouse for transient windows, smoother mouse positioning when releasing mouse for spinbox
This commit is contained in:
parent
8769088f48
commit
5ac5c8bc06
5 changed files with 18 additions and 3 deletions
|
@ -105,8 +105,9 @@ void SpinBox::_range_click_timeout() {
|
|||
void SpinBox::_release_mouse() {
|
||||
if (drag.enabled) {
|
||||
drag.enabled = false;
|
||||
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
|
||||
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_HIDDEN);
|
||||
warp_mouse(drag.capture_pos);
|
||||
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1103,7 +1103,7 @@ Vector2 Viewport::get_mouse_position() const {
|
|||
|
||||
void Viewport::warp_mouse(const Vector2 &p_position) {
|
||||
Transform2D xform = get_screen_transform();
|
||||
Vector2 gpos = xform.xform(p_position).round();
|
||||
Vector2 gpos = xform.xform(p_position);
|
||||
Input::get_singleton()->warp_mouse(gpos);
|
||||
}
|
||||
|
||||
|
|
|
@ -563,7 +563,7 @@ public:
|
|||
bool is_input_disabled() const;
|
||||
|
||||
Vector2 get_mouse_position() const;
|
||||
void warp_mouse(const Vector2 &p_position);
|
||||
virtual void warp_mouse(const Vector2 &p_position);
|
||||
|
||||
void set_physics_object_picking(bool p_enable);
|
||||
bool get_physics_object_picking();
|
||||
|
|
|
@ -974,6 +974,18 @@ DisplayServer::WindowID Window::get_window_id() const {
|
|||
return window_id;
|
||||
}
|
||||
|
||||
void Window::warp_mouse(const Vector2 &p_position) {
|
||||
Transform2D xform = get_screen_transform();
|
||||
Vector2 gpos = xform.xform(p_position);
|
||||
|
||||
if (transient_parent && !transient_parent->is_embedding_subwindows()) {
|
||||
Transform2D window_trans = Transform2D().translated(get_position() + (transient_parent->get_visible_rect().size - transient_parent->get_real_size()));
|
||||
gpos = window_trans.xform(gpos);
|
||||
}
|
||||
|
||||
Input::get_singleton()->warp_mouse(gpos);
|
||||
}
|
||||
|
||||
void Window::set_wrap_controls(bool p_enable) {
|
||||
wrap_controls = p_enable;
|
||||
if (wrap_controls) {
|
||||
|
|
|
@ -239,6 +239,8 @@ public:
|
|||
void set_use_font_oversampling(bool p_oversampling);
|
||||
bool is_using_font_oversampling() const;
|
||||
|
||||
void warp_mouse(const Vector2 &p_position) override;
|
||||
|
||||
void set_wrap_controls(bool p_enable);
|
||||
bool is_wrapping_controls() const;
|
||||
void child_controls_changed();
|
||||
|
|
Loading…
Reference in a new issue