Skip to content

Commit b31be62

Browse files
committed
Optimize files that #include input.h header
1 parent d5edd4a commit b31be62

File tree

62 files changed

+175
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+175
-108
lines changed

core/debugger/remote_debugger.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,12 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
424424
}
425425
send_message("debug_enter", msg);
426426

427-
Input::MouseMode mouse_mode = Input::MOUSE_MODE_VISIBLE;
427+
Input::MouseMode mouse_mode = Input::MouseMode::MOUSE_MODE_VISIBLE;
428428

429429
if (Thread::get_caller_id() == Thread::get_main_id()) {
430430
mouse_mode = Input::get_singleton()->get_mouse_mode();
431-
if (mouse_mode != Input::MOUSE_MODE_VISIBLE) {
432-
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
431+
if (mouse_mode != Input::MouseMode::MOUSE_MODE_VISIBLE) {
432+
Input::get_singleton()->set_mouse_mode(Input::MouseMode::MOUSE_MODE_VISIBLE);
433433
}
434434
} else {
435435
MutexLock mutex_lock(mutex);
@@ -630,7 +630,7 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
630630
send_message("debug_exit", Array());
631631

632632
if (Thread::get_caller_id() == Thread::get_main_id()) {
633-
if (mouse_mode != Input::MOUSE_MODE_VISIBLE) {
633+
if (mouse_mode != Input::MouseMode::MOUSE_MODE_VISIBLE) {
634634
Input::get_singleton()->set_mouse_mode(mouse_mode);
635635
}
636636
} else {

core/input/input.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ void Input::_bind_methods() {
178178
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emulate_mouse_from_touch"), "set_emulate_mouse_from_touch", "is_emulating_mouse_from_touch");
179179
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emulate_touch_from_mouse"), "set_emulate_touch_from_mouse", "is_emulating_touch_from_mouse");
180180

181+
using namespace InputClassEnums;
182+
181183
BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
182184
BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
183185
BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);

core/input/input.h

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,40 @@
3838
#include "core/templates/rb_set.h"
3939
#include "core/variant/typed_array.h"
4040

41+
namespace InputClassEnums {
42+
// Keep synced with "DisplayServer::MouseMode" enum.
43+
enum MouseMode : int {
44+
MOUSE_MODE_VISIBLE,
45+
MOUSE_MODE_HIDDEN,
46+
MOUSE_MODE_CAPTURED,
47+
MOUSE_MODE_CONFINED,
48+
MOUSE_MODE_CONFINED_HIDDEN,
49+
MOUSE_MODE_MAX,
50+
};
51+
52+
#undef CursorShape
53+
enum CursorShape : int {
54+
CURSOR_ARROW,
55+
CURSOR_IBEAM,
56+
CURSOR_POINTING_HAND,
57+
CURSOR_CROSS,
58+
CURSOR_WAIT,
59+
CURSOR_BUSY,
60+
CURSOR_DRAG,
61+
CURSOR_CAN_DROP,
62+
CURSOR_FORBIDDEN,
63+
CURSOR_VSIZE,
64+
CURSOR_HSIZE,
65+
CURSOR_BDIAGSIZE,
66+
CURSOR_FDIAGSIZE,
67+
CURSOR_MOVE,
68+
CURSOR_VSPLIT,
69+
CURSOR_HSPLIT,
70+
CURSOR_HELP,
71+
CURSOR_MAX
72+
};
73+
} //namespace InputClassEnums
74+
4175
class Input : public Object {
4276
GDCLASS(Input, Object);
4377
_THREAD_SAFE_CLASS_
@@ -47,37 +81,8 @@ class Input : public Object {
4781
static constexpr uint64_t MAX_EVENT = 32;
4882

4983
public:
50-
// Keep synced with "DisplayServer::MouseMode" enum.
51-
enum MouseMode {
52-
MOUSE_MODE_VISIBLE,
53-
MOUSE_MODE_HIDDEN,
54-
MOUSE_MODE_CAPTURED,
55-
MOUSE_MODE_CONFINED,
56-
MOUSE_MODE_CONFINED_HIDDEN,
57-
MOUSE_MODE_MAX,
58-
};
59-
60-
#undef CursorShape
61-
enum CursorShape {
62-
CURSOR_ARROW,
63-
CURSOR_IBEAM,
64-
CURSOR_POINTING_HAND,
65-
CURSOR_CROSS,
66-
CURSOR_WAIT,
67-
CURSOR_BUSY,
68-
CURSOR_DRAG,
69-
CURSOR_CAN_DROP,
70-
CURSOR_FORBIDDEN,
71-
CURSOR_VSIZE,
72-
CURSOR_HSIZE,
73-
CURSOR_BDIAGSIZE,
74-
CURSOR_FDIAGSIZE,
75-
CURSOR_MOVE,
76-
CURSOR_VSPLIT,
77-
CURSOR_HSPLIT,
78-
CURSOR_HELP,
79-
CURSOR_MAX
80-
};
84+
using MouseMode = InputClassEnums::MouseMode;
85+
using CursorShape = InputClassEnums::CursorShape;
8186

8287
class JoypadFeatures {
8388
public:
@@ -195,7 +200,7 @@ class Input : public Object {
195200

196201
int fallback_mapping = -1; // Index of the guid in map_db.
197202

198-
CursorShape default_shape = CURSOR_ARROW;
203+
CursorShape default_shape = CursorShape::CURSOR_ARROW;
199204

200205
enum JoyType {
201206
TYPE_BUTTON,
@@ -382,7 +387,7 @@ class Input : public Object {
382387
CursorShape get_default_cursor_shape() const;
383388
void set_default_cursor_shape(CursorShape p_shape);
384389
CursorShape get_current_cursor_shape() const;
385-
void set_custom_mouse_cursor(const Ref<Resource> &p_cursor, CursorShape p_shape = Input::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
390+
void set_custom_mouse_cursor(const Ref<Resource> &p_cursor, CursorShape p_shape = Input::CursorShape::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
386391

387392
void parse_mapping(const String &p_mapping);
388393
void joy_button(int p_device, JoyButton p_button, bool p_pressed);

editor/docks/filesystem_dock.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "filesystem_dock.h"
3232

3333
#include "core/config/project_settings.h"
34+
#include "core/input/input.h"
3435
#include "core/io/dir_access.h"
3536
#include "core/io/file_access.h"
3637
#include "core/io/resource_loader.h"

editor/gui/editor_spin_slider.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) {
115115
grabbing_spinner_dist_cache += diff_x * grabbing_spinner_speed;
116116

117117
if (!grabbing_spinner && Math::abs(grabbing_spinner_dist_cache) > 4 * grabbing_spinner_speed * EDSCALE) {
118-
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
118+
Input::get_singleton()->set_mouse_mode(Input::MouseMode::MOUSE_MODE_CAPTURED);
119119
grabbing_spinner = true;
120120
}
121121

@@ -166,7 +166,7 @@ void EditorSpinSlider::_grab_start() {
166166
void EditorSpinSlider::_grab_end() {
167167
if (grabbing_spinner_attempt) {
168168
if (grabbing_spinner) {
169-
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
169+
Input::get_singleton()->set_mouse_mode(Input::MouseMode::MOUSE_MODE_VISIBLE);
170170
Input::get_singleton()->warp_mouse(grabbing_spinner_mouse_pos);
171171
mouse_over_grabber = true;
172172
queue_redraw();
@@ -493,7 +493,7 @@ void EditorSpinSlider::_notification(int p_what) {
493493
case NOTIFICATION_EXIT_TREE: {
494494
if (grabbing_spinner) {
495495
grabber->hide();
496-
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
496+
Input::get_singleton()->set_mouse_mode(Input::MouseMode::MOUSE_MODE_VISIBLE);
497497
Input::get_singleton()->warp_mouse(grabbing_spinner_mouse_pos);
498498
grabbing_spinner = false;
499499
grabbing_spinner_attempt = false;

editor/gui/editor_zoom_widget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "editor_zoom_widget.h"
3232

33+
#include "core/input/input.h"
3334
#include "core/os/keyboard.h"
3435
#include "core/string/translation_server.h"
3536
#include "editor/settings/editor_settings.h"

editor/inspector/editor_inspector.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "editor_inspector.h"
3232
#include "editor_inspector.compat.inc"
3333

34+
#include "core/input/input.h"
3435
#include "core/os/keyboard.h"
3536
#include "editor/debugger/editor_debugger_inspector.h"
3637
#include "editor/doc/doc_tools.h"

editor/inspector/editor_properties_array_dict.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ void EditorPropertyArray::_reorder_button_down(int p_slot_index) {
933933
reorder_to_index = reorder_slot.index;
934934
// Ideally it'd to be able to show the mouse but I had issues with
935935
// Control's `mouse_exit()`/`mouse_entered()` signals not getting called.
936-
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
936+
Input::get_singleton()->set_mouse_mode(Input::MouseMode::MOUSE_MODE_CAPTURED);
937937
}
938938

939939
void EditorPropertyArray::_reorder_button_up() {
@@ -954,7 +954,7 @@ void EditorPropertyArray::_reorder_button_up() {
954954
emit_changed(get_edited_property(), array);
955955
}
956956

957-
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
957+
Input::get_singleton()->set_mouse_mode(Input::MouseMode::MOUSE_MODE_VISIBLE);
958958

959959
ERR_FAIL_NULL(reorder_slot.reorder_button);
960960
reorder_slot.reorder_button->warp_mouse(reorder_slot.reorder_button->get_size() / 2.0f);

editor/inspector/editor_resource_picker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "editor_resource_picker.h"
3232

33+
#include "core/input/input.h"
3334
#include "editor/audio/audio_stream_preview.h"
3435
#include "editor/doc/editor_help.h"
3536
#include "editor/docks/filesystem_dock.h"

editor/project_manager/project_list.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "project_list.h"
3232

3333
#include "core/config/project_settings.h"
34+
#include "core/input/input.h"
3435
#include "core/io/dir_access.h"
3536
#include "core/os/time.h"
3637
#include "core/version.h"

0 commit comments

Comments
 (0)