Merge pull request #59574 from Sauermann/proposal-rename-warp-mouse
Rename warp mouse functions to warp_mouse
This commit is contained in:
commit
00e9170812
@ -72,7 +72,7 @@ Input *Input::singleton = nullptr;
|
||||
|
||||
void (*Input::set_mouse_mode_func)(Input::MouseMode) = nullptr;
|
||||
Input::MouseMode (*Input::get_mouse_mode_func)() = nullptr;
|
||||
void (*Input::warp_mouse_func)(const Vector2 &p_to_pos) = nullptr;
|
||||
void (*Input::warp_mouse_func)(const Vector2 &p_position) = nullptr;
|
||||
Input::CursorShape (*Input::get_current_cursor_shape_func)() = nullptr;
|
||||
void (*Input::set_custom_mouse_cursor_func)(const RES &, Input::CursorShape, const Vector2 &) = nullptr;
|
||||
|
||||
@ -126,7 +126,7 @@ void Input::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_mouse_button_mask"), &Input::get_mouse_button_mask);
|
||||
ClassDB::bind_method(D_METHOD("set_mouse_mode", "mode"), &Input::set_mouse_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_mouse_mode"), &Input::get_mouse_mode);
|
||||
ClassDB::bind_method(D_METHOD("warp_mouse_position", "to"), &Input::warp_mouse_position);
|
||||
ClassDB::bind_method(D_METHOD("warp_mouse", "position"), &Input::warp_mouse);
|
||||
ClassDB::bind_method(D_METHOD("action_press", "action", "strength"), &Input::action_press, DEFVAL(1.f));
|
||||
ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release);
|
||||
ClassDB::bind_method(D_METHOD("set_default_cursor_shape", "shape"), &Input::set_default_cursor_shape, DEFVAL(CURSOR_ARROW));
|
||||
@ -733,8 +733,8 @@ MouseButton Input::get_mouse_button_mask() const {
|
||||
return mouse_button_mask; // do not trust OS implementation, should remove it - OS::get_singleton()->get_mouse_button_state();
|
||||
}
|
||||
|
||||
void Input::warp_mouse_position(const Vector2 &p_to) {
|
||||
warp_mouse_func(p_to);
|
||||
void Input::warp_mouse(const Vector2 &p_position) {
|
||||
warp_mouse_func(p_position);
|
||||
}
|
||||
|
||||
Point2i Input::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect) {
|
||||
@ -756,7 +756,7 @@ Point2i Input::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, con
|
||||
const Point2i pos_local = p_motion->get_global_position() - p_rect.position;
|
||||
const Point2i pos_warped(Math::fposmod(pos_local.x, p_rect.size.x), Math::fposmod(pos_local.y, p_rect.size.y));
|
||||
if (pos_warped != pos_local) {
|
||||
warp_mouse_position(pos_warped + p_rect.position);
|
||||
warp_mouse(pos_warped + p_rect.position);
|
||||
}
|
||||
|
||||
return rel_warped;
|
||||
|
@ -216,7 +216,7 @@ private:
|
||||
|
||||
static void (*set_mouse_mode_func)(MouseMode);
|
||||
static MouseMode (*get_mouse_mode_func)();
|
||||
static void (*warp_mouse_func)(const Vector2 &p_to_pos);
|
||||
static void (*warp_mouse_func)(const Vector2 &p_position);
|
||||
|
||||
static CursorShape (*get_current_cursor_shape_func)();
|
||||
static void (*set_custom_mouse_cursor_func)(const RES &, CursorShape, const Vector2 &);
|
||||
@ -273,7 +273,7 @@ public:
|
||||
Vector2 get_last_mouse_velocity();
|
||||
MouseButton get_mouse_button_mask() const;
|
||||
|
||||
void warp_mouse_position(const Vector2 &p_to);
|
||||
void warp_mouse(const Vector2 &p_position);
|
||||
Point2i warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect);
|
||||
|
||||
void parse_input_event(const Ref<InputEvent> &p_event);
|
||||
|
@ -943,9 +943,9 @@
|
||||
</method>
|
||||
<method name="warp_mouse">
|
||||
<return type="void" />
|
||||
<argument index="0" name="to_position" type="Vector2" />
|
||||
<argument index="0" name="position" type="Vector2" />
|
||||
<description>
|
||||
Moves the mouse cursor to [code]to_position[/code], relative to [member position] of this [Control].
|
||||
Moves the mouse cursor to [code]position[/code], relative to [member position] of this [Control].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
|
@ -670,13 +670,6 @@
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="mouse_warp_to_position">
|
||||
<return type="void" />
|
||||
<argument index="0" name="position" type="Vector2i" />
|
||||
<description>
|
||||
Sets the mouse cursor position to the given [code]position[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="process_events">
|
||||
<return type="void" />
|
||||
<description>
|
||||
@ -852,6 +845,13 @@
|
||||
[b]Note:[/b] This method is implemented on Android, iOS and UWP.
|
||||
</description>
|
||||
</method>
|
||||
<method name="warp_mouse">
|
||||
<return type="void" />
|
||||
<argument index="0" name="position" type="Vector2i" />
|
||||
<description>
|
||||
Sets the mouse cursor position to the given [code]position[/code] relative to an origin at the upper left corner of the currently focused game Window Manager window.
|
||||
</description>
|
||||
</method>
|
||||
<method name="window_attach_instance_id">
|
||||
<return type="void" />
|
||||
<argument index="0" name="instance_id" type="int" />
|
||||
|
@ -379,11 +379,11 @@
|
||||
[b]Note:[/b] It needs [code]VIBRATE[/code] permission for Android at export settings. iOS does not support duration.
|
||||
</description>
|
||||
</method>
|
||||
<method name="warp_mouse_position">
|
||||
<method name="warp_mouse">
|
||||
<return type="void" />
|
||||
<argument index="0" name="to" type="Vector2" />
|
||||
<argument index="0" name="position" type="Vector2" />
|
||||
<description>
|
||||
Sets the mouse position to the specified vector, provided in pixels and relative to an origin at the upper left corner of the game window.
|
||||
Sets the mouse position to the specified vector, provided in pixels and relative to an origin at the upper left corner of the currently focused Window Manager game window.
|
||||
Mouse position is clipped to the limits of the screen resolution, or to the limits of the game window if [enum MouseMode] is set to [code]MOUSE_MODE_CONFINED[/code] or [code]MOUSE_MODE_CONFINED_HIDDEN[/code].
|
||||
</description>
|
||||
</method>
|
||||
|
@ -172,7 +172,7 @@
|
||||
</method>
|
||||
<method name="warp_mouse">
|
||||
<return type="void" />
|
||||
<argument index="0" name="to_position" type="Vector2" />
|
||||
<argument index="0" name="position" type="Vector2" />
|
||||
<description>
|
||||
Moves the mouse pointer to the specified position in this [Viewport] using the coordinate system of this [Viewport].
|
||||
</description>
|
||||
|
@ -81,7 +81,7 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) {
|
||||
if (grabbing_spinner_attempt) {
|
||||
if (grabbing_spinner) {
|
||||
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
|
||||
Input::get_singleton()->warp_mouse_position(grabbing_spinner_mouse_pos);
|
||||
Input::get_singleton()->warp_mouse(grabbing_spinner_mouse_pos);
|
||||
update();
|
||||
} else {
|
||||
_focus_entered();
|
||||
@ -414,7 +414,7 @@ void EditorSpinSlider::_draw_spin_slider() {
|
||||
grabber->set_position(get_global_position() + (grabber_rect.get_center() - grabber->get_size() * 0.5) * scale);
|
||||
|
||||
if (mousewheel_over_grabber) {
|
||||
Input::get_singleton()->warp_mouse_position(grabber->get_position() + grabber_rect.size);
|
||||
Input::get_singleton()->warp_mouse(grabber->get_position() + grabber_rect.size);
|
||||
}
|
||||
|
||||
grabber_range = width;
|
||||
|
@ -205,7 +205,7 @@ void ViewportRotationControl::gui_input(const Ref<InputEvent> &p_event) {
|
||||
orbiting = false;
|
||||
if (Input::get_singleton()->get_mouse_mode() == Input::MOUSE_MODE_CAPTURED) {
|
||||
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
|
||||
Input::get_singleton()->warp_mouse_position(orbiting_mouse_start);
|
||||
Input::get_singleton()->warp_mouse(orbiting_mouse_start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -363,15 +363,15 @@ DisplayServerX11::MouseMode DisplayServerX11::mouse_get_mode() const {
|
||||
return mouse_mode;
|
||||
}
|
||||
|
||||
void DisplayServerX11::mouse_warp_to_position(const Point2i &p_to) {
|
||||
void DisplayServerX11::warp_mouse(const Point2i &p_position) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
if (mouse_mode == MOUSE_MODE_CAPTURED) {
|
||||
last_mouse_pos = p_to;
|
||||
last_mouse_pos = p_position;
|
||||
} else {
|
||||
WindowID window_id = windows.has(last_focused_window) ? last_focused_window : MAIN_WINDOW_ID;
|
||||
XWarpPointer(x11_display, None, windows[window_id].x11_window,
|
||||
0, 0, 0, 0, (int)p_to.x, (int)p_to.y);
|
||||
0, 0, 0, 0, (int)p_position.x, (int)p_position.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ public:
|
||||
virtual void mouse_set_mode(MouseMode p_mode) override;
|
||||
virtual MouseMode mouse_get_mode() const override;
|
||||
|
||||
virtual void mouse_warp_to_position(const Point2i &p_to) override;
|
||||
virtual void warp_mouse(const Point2i &p_position) override;
|
||||
virtual Point2i mouse_get_position() const override;
|
||||
virtual MouseButton mouse_get_button_state() const override;
|
||||
|
||||
|
@ -271,7 +271,7 @@ public:
|
||||
virtual MouseMode mouse_get_mode() const override;
|
||||
|
||||
bool update_mouse_wrap(WindowData &p_wd, NSPoint &r_delta, NSPoint &r_mpos, NSTimeInterval p_timestamp);
|
||||
virtual void mouse_warp_to_position(const Point2i &p_to) override;
|
||||
virtual void warp_mouse(const Point2i &p_position) override;
|
||||
virtual Point2i mouse_get_position() const override;
|
||||
void mouse_set_button_state(MouseButton p_state);
|
||||
virtual MouseButton mouse_get_button_state() const override;
|
||||
|
@ -1646,7 +1646,7 @@ bool DisplayServerOSX::update_mouse_wrap(WindowData &p_wd, NSPoint &r_delta, NSP
|
||||
return false;
|
||||
}
|
||||
|
||||
void DisplayServerOSX::mouse_warp_to_position(const Point2i &p_to) {
|
||||
void DisplayServerOSX::warp_mouse(const Point2i &p_position) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
if (mouse_mode != MOUSE_MODE_CAPTURED) {
|
||||
@ -1656,7 +1656,7 @@ void DisplayServerOSX::mouse_warp_to_position(const Point2i &p_to) {
|
||||
// Local point in window coords.
|
||||
const NSRect contentRect = [wd.window_view frame];
|
||||
const float scale = screen_get_max_scale();
|
||||
NSRect pointInWindowRect = NSMakeRect(p_to.x / scale, contentRect.size.height - (p_to.y / scale - 1), 0, 0);
|
||||
NSRect pointInWindowRect = NSMakeRect(p_position.x / scale, contentRect.size.height - (p_position.y / scale - 1), 0, 0);
|
||||
NSPoint pointOnScreen = [[wd.window_view window] convertRectToScreen:pointInWindowRect].origin;
|
||||
|
||||
// Point in scren coords.
|
||||
|
@ -150,7 +150,7 @@ DisplayServer::MouseMode DisplayServerWindows::mouse_get_mode() const {
|
||||
return mouse_mode;
|
||||
}
|
||||
|
||||
void DisplayServerWindows::mouse_warp_to_position(const Point2i &p_to) {
|
||||
void DisplayServerWindows::warp_mouse(const Point2i &p_position) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
if (!windows.has(last_focused_window)) {
|
||||
@ -158,12 +158,12 @@ void DisplayServerWindows::mouse_warp_to_position(const Point2i &p_to) {
|
||||
}
|
||||
|
||||
if (mouse_mode == MOUSE_MODE_CAPTURED) {
|
||||
old_x = p_to.x;
|
||||
old_y = p_to.y;
|
||||
old_x = p_position.x;
|
||||
old_y = p_position.y;
|
||||
} else {
|
||||
POINT p;
|
||||
p.x = p_to.x;
|
||||
p.y = p_to.y;
|
||||
p.x = p_position.x;
|
||||
p.y = p_position.y;
|
||||
ClientToScreen(windows[last_focused_window].hWnd, &p);
|
||||
|
||||
SetCursorPos(p.x, p.y);
|
||||
|
@ -457,7 +457,7 @@ public:
|
||||
virtual void mouse_set_mode(MouseMode p_mode) override;
|
||||
virtual MouseMode mouse_get_mode() const override;
|
||||
|
||||
virtual void mouse_warp_to_position(const Point2i &p_to) override;
|
||||
virtual void warp_mouse(const Point2i &p_position) override;
|
||||
virtual Point2i mouse_get_position() const override;
|
||||
virtual MouseButton mouse_get_button_state() const override;
|
||||
|
||||
|
@ -2937,9 +2937,9 @@ Control::MouseFilter Control::get_mouse_filter() const {
|
||||
return data.mouse_filter;
|
||||
}
|
||||
|
||||
void Control::warp_mouse(const Point2 &p_to_pos) {
|
||||
void Control::warp_mouse(const Point2 &p_position) {
|
||||
ERR_FAIL_COND(!is_inside_tree());
|
||||
get_viewport()->warp_mouse(get_global_transform().xform(p_to_pos));
|
||||
get_viewport()->warp_mouse(get_global_transform().xform(p_position));
|
||||
}
|
||||
|
||||
bool Control::is_text_field() const {
|
||||
@ -3331,7 +3331,7 @@ void Control::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_drag_preview", "control"), &Control::set_drag_preview);
|
||||
ClassDB::bind_method(D_METHOD("is_drag_successful"), &Control::is_drag_successful);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("warp_mouse", "to_position"), &Control::warp_mouse);
|
||||
ClassDB::bind_method(D_METHOD("warp_mouse", "position"), &Control::warp_mouse);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("update_minimum_size"), &Control::update_minimum_size);
|
||||
|
||||
|
@ -548,7 +548,7 @@ public:
|
||||
|
||||
void grab_click_focus();
|
||||
|
||||
void warp_mouse(const Point2 &p_to_pos);
|
||||
void warp_mouse(const Point2 &p_position);
|
||||
|
||||
virtual bool is_text_field() const;
|
||||
|
||||
|
@ -1124,9 +1124,9 @@ Vector2 Viewport::get_mouse_position() const {
|
||||
return gui.last_mouse_pos;
|
||||
}
|
||||
|
||||
void Viewport::warp_mouse(const Vector2 &p_pos) {
|
||||
Vector2 gpos = (get_final_transform().affine_inverse() * _get_input_pre_xform()).affine_inverse().xform(p_pos);
|
||||
Input::get_singleton()->warp_mouse_position(gpos);
|
||||
void Viewport::warp_mouse(const Vector2 &p_position) {
|
||||
Vector2 gpos = (get_final_transform().affine_inverse() * _get_input_pre_xform()).affine_inverse().xform(p_position);
|
||||
Input::get_singleton()->warp_mouse(gpos);
|
||||
}
|
||||
|
||||
void Viewport::_gui_sort_roots() {
|
||||
@ -3642,7 +3642,7 @@ void Viewport::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("is_audio_listener_2d"), &Viewport::is_audio_listener_2d);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_mouse_position"), &Viewport::get_mouse_position);
|
||||
ClassDB::bind_method(D_METHOD("warp_mouse", "to_position"), &Viewport::warp_mouse);
|
||||
ClassDB::bind_method(D_METHOD("warp_mouse", "position"), &Viewport::warp_mouse);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("gui_get_drag_data"), &Viewport::gui_get_drag_data);
|
||||
ClassDB::bind_method(D_METHOD("gui_is_dragging"), &Viewport::gui_is_dragging);
|
||||
|
@ -547,7 +547,7 @@ public:
|
||||
bool is_input_disabled() const;
|
||||
|
||||
Vector2 get_mouse_position() const;
|
||||
void warp_mouse(const Vector2 &p_pos);
|
||||
void warp_mouse(const Vector2 &p_position);
|
||||
|
||||
void set_physics_object_picking(bool p_enable);
|
||||
bool get_physics_object_picking();
|
||||
|
@ -228,7 +228,7 @@ DisplayServer::MouseMode DisplayServer::mouse_get_mode() const {
|
||||
return MOUSE_MODE_VISIBLE;
|
||||
}
|
||||
|
||||
void DisplayServer::mouse_warp_to_position(const Point2i &p_to) {
|
||||
void DisplayServer::warp_mouse(const Point2i &p_position) {
|
||||
WARN_PRINT("Mouse warping is not supported by this display server.");
|
||||
}
|
||||
|
||||
@ -481,7 +481,7 @@ void DisplayServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("mouse_set_mode", "mouse_mode"), &DisplayServer::mouse_set_mode);
|
||||
ClassDB::bind_method(D_METHOD("mouse_get_mode"), &DisplayServer::mouse_get_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("mouse_warp_to_position", "position"), &DisplayServer::mouse_warp_to_position);
|
||||
ClassDB::bind_method(D_METHOD("warp_mouse", "position"), &DisplayServer::warp_mouse);
|
||||
ClassDB::bind_method(D_METHOD("mouse_get_position"), &DisplayServer::mouse_get_position);
|
||||
ClassDB::bind_method(D_METHOD("mouse_get_button_state"), &DisplayServer::mouse_get_button_state);
|
||||
|
||||
@ -729,7 +729,7 @@ Input::MouseMode DisplayServer::_input_get_mouse_mode() {
|
||||
}
|
||||
|
||||
void DisplayServer::_input_warp(const Vector2 &p_to_pos) {
|
||||
singleton->mouse_warp_to_position(p_to_pos);
|
||||
singleton->warp_mouse(p_to_pos);
|
||||
}
|
||||
|
||||
Input::CursorShape DisplayServer::_input_get_current_cursor_shape() {
|
||||
|
@ -183,7 +183,7 @@ public:
|
||||
virtual void mouse_set_mode(MouseMode p_mode);
|
||||
virtual MouseMode mouse_get_mode() const;
|
||||
|
||||
virtual void mouse_warp_to_position(const Point2i &p_to);
|
||||
virtual void warp_mouse(const Point2i &p_position);
|
||||
virtual Point2i mouse_get_position() const;
|
||||
virtual MouseButton mouse_get_button_state() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user