Move DisplayServer enums and typedefs to DisplayServerEnums
This will allow decoupling `display_server.h` from a number of headers in the codebase which only require those enums and not all the DisplayServer API.
This commit is contained in:
parent
778cf54dab
commit
a447ac95ec
160 changed files with 4584 additions and 4520 deletions
|
|
@ -52,21 +52,21 @@ void DisplayServerMock::_set_window_over(bool p_over) {
|
|||
return;
|
||||
}
|
||||
window_over = p_over;
|
||||
_send_window_event(p_over ? WINDOW_EVENT_MOUSE_ENTER : WINDOW_EVENT_MOUSE_EXIT);
|
||||
_send_window_event(p_over ? DisplayServerEnums::WINDOW_EVENT_MOUSE_ENTER : DisplayServerEnums::WINDOW_EVENT_MOUSE_EXIT);
|
||||
}
|
||||
void DisplayServerMock::_send_window_event(WindowEvent p_event) {
|
||||
void DisplayServerMock::_send_window_event(DisplayServerEnums::WindowEvent p_event) {
|
||||
if (event_callback.is_valid()) {
|
||||
Variant event = int(p_event);
|
||||
event_callback.call(event);
|
||||
}
|
||||
}
|
||||
|
||||
bool DisplayServerMock::has_feature(Feature p_feature) const {
|
||||
bool DisplayServerMock::has_feature(DisplayServerEnums::Feature p_feature) const {
|
||||
switch (p_feature) {
|
||||
case FEATURE_MOUSE:
|
||||
case FEATURE_CURSOR_SHAPE:
|
||||
case FEATURE_CLIPBOARD:
|
||||
case FEATURE_CLIPBOARD_PRIMARY:
|
||||
case DisplayServerEnums::FEATURE_MOUSE:
|
||||
case DisplayServerEnums::FEATURE_CURSOR_SHAPE:
|
||||
case DisplayServerEnums::FEATURE_CLIPBOARD:
|
||||
case DisplayServerEnums::FEATURE_CLIPBOARD_PRIMARY:
|
||||
return true;
|
||||
default: {
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ bool DisplayServerMock::has_feature(Feature p_feature) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
DisplayServer *DisplayServerMock::create_func(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, int64_t p_parent_window, Error &r_error) {
|
||||
DisplayServer *DisplayServerMock::create_func(const String &p_rendering_driver, DisplayServerEnums::WindowMode p_mode, DisplayServerEnums::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, DisplayServerEnums::Context p_context, int64_t p_parent_window, Error &r_error) {
|
||||
r_error = OK;
|
||||
RasterizerDummy::make_current();
|
||||
return memnew(DisplayServerMock());
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ private:
|
|||
friend class DisplayServer;
|
||||
|
||||
Point2i mouse_position = Point2i(-1, -1); // Outside of Window.
|
||||
CursorShape cursor_shape = CursorShape::CURSOR_ARROW;
|
||||
DisplayServerEnums::CursorShape cursor_shape = DisplayServerEnums::CursorShape::CURSOR_ARROW;
|
||||
bool window_over = false;
|
||||
Callable event_callback;
|
||||
|
||||
|
|
@ -49,14 +49,14 @@ private:
|
|||
String primary_clipboard_text;
|
||||
|
||||
static Vector<String> get_rendering_drivers_func();
|
||||
static DisplayServer *create_func(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, int64_t p_parent_window, Error &r_error);
|
||||
static DisplayServer *create_func(const String &p_rendering_driver, DisplayServerEnums::WindowMode p_mode, DisplayServerEnums::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, DisplayServerEnums::Context p_context, int64_t p_parent_window, Error &r_error);
|
||||
|
||||
void _set_mouse_position(const Point2i &p_position);
|
||||
void _set_window_over(bool p_over);
|
||||
void _send_window_event(WindowEvent p_event);
|
||||
void _send_window_event(DisplayServerEnums::WindowEvent p_event);
|
||||
|
||||
public:
|
||||
bool has_feature(Feature p_feature) const override;
|
||||
bool has_feature(DisplayServerEnums::Feature p_feature) const override;
|
||||
|
||||
String get_name() const override { return "mock"; }
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ public:
|
|||
void simulate_event(Ref<InputEvent> p_event);
|
||||
|
||||
// Returns the current cursor shape.
|
||||
CursorShape get_cursor_shape() {
|
||||
DisplayServerEnums::CursorShape get_cursor_shape() {
|
||||
return cursor_shape;
|
||||
}
|
||||
|
||||
|
|
@ -78,15 +78,15 @@ public:
|
|||
virtual void clipboard_set_primary(const String &p_text) override { primary_clipboard_text = p_text; }
|
||||
virtual String clipboard_get_primary() const override { return primary_clipboard_text; }
|
||||
|
||||
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override {
|
||||
virtual Size2i window_get_size(DisplayServerEnums::WindowID p_window = DisplayServerEnums::MAIN_WINDOW_ID) const override {
|
||||
return Size2i(1920, 1080);
|
||||
}
|
||||
|
||||
virtual void cursor_set_shape(CursorShape p_shape) override {
|
||||
virtual void cursor_set_shape(DisplayServerEnums::CursorShape p_shape) override {
|
||||
cursor_shape = p_shape;
|
||||
}
|
||||
|
||||
virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override {
|
||||
virtual void window_set_window_event_callback(const Callable &p_callable, DisplayServerEnums::WindowID p_window = DisplayServerEnums::MAIN_WINDOW_ID) override {
|
||||
event_callback = p_callable;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ TEST_CASE("[SceneTree][SplitContainer] Collapsed") {
|
|||
|
||||
// Cursor is default.
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(Point2(1, 1), MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_ARROW);
|
||||
|
||||
// Dragger is disabled, cannot drag.
|
||||
SEND_GUI_MOUSE_BUTTON_EVENT(Point2(1, 1), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE);
|
||||
|
|
@ -377,20 +377,20 @@ TEST_CASE("[SceneTree][SplitContainer] Cursor shape") {
|
|||
|
||||
// Default cursor shape.
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(not_on_dragger, MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_ARROW);
|
||||
|
||||
// Horizontal cursor shape.
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_dragger, MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_HSPLIT);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_HSPLIT);
|
||||
|
||||
// Vertical cursor shape.
|
||||
split_container->set_vertical(true);
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_dragger, MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_VSPLIT);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_VSPLIT);
|
||||
|
||||
// Move off, default cursor shape.
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(not_on_dragger, MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_ARROW);
|
||||
|
||||
memdelete(child_a);
|
||||
memdelete(child_b);
|
||||
|
|
|
|||
|
|
@ -8303,13 +8303,13 @@ TEST_CASE("[SceneTree][TextEdit] gutters") {
|
|||
|
||||
// Defaults to none.
|
||||
CHECK(text_edit->get_hovered_gutter() == Vector2i(-1, -1));
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_ARROW);
|
||||
|
||||
// Hover over gutter.
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(Point2(5, line_height + line_height / 2), MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(text_edit->get_hovered_gutter() == Vector2i(0, 1));
|
||||
SIGNAL_CHECK_FALSE("gutter_clicked");
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_POINTING_HAND);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_POINTING_HAND);
|
||||
|
||||
// Click on gutter.
|
||||
SEND_GUI_MOUSE_BUTTON_EVENT(Point2(5, line_height / 2), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE);
|
||||
|
|
@ -8325,19 +8325,19 @@ TEST_CASE("[SceneTree][TextEdit] gutters") {
|
|||
SEND_GUI_MOUSE_MOTION_EVENT(Point2(15, line_height + line_height / 2), MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(text_edit->get_hovered_gutter() == Vector2i(1, 1));
|
||||
SIGNAL_CHECK_FALSE("gutter_clicked");
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_ARROW);
|
||||
|
||||
// Unclickable gutter can be clicked.
|
||||
SEND_GUI_MOUSE_BUTTON_EVENT(Point2(15, line_height * 2 + line_height / 2), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE);
|
||||
CHECK(text_edit->get_hovered_gutter() == Vector2i(1, 2));
|
||||
SIGNAL_CHECK("gutter_clicked", Array({ { 2, 1 } }));
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_ARROW);
|
||||
|
||||
// Hover past last line.
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(Point2(5, line_height * 5), MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(text_edit->get_hovered_gutter() == Vector2i(-1, -1));
|
||||
SIGNAL_CHECK_FALSE("gutter_clicked");
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_ARROW);
|
||||
|
||||
// Click on gutter past last line.
|
||||
SEND_GUI_MOUSE_BUTTON_EVENT(Point2(5, line_height * 5), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE);
|
||||
|
|
|
|||
|
|
@ -1170,7 +1170,7 @@ TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") {
|
|||
|
||||
// Move above a Control, that is a Drop target and allows dropping at this point.
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_d, MouseButtonMask::LEFT, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_CAN_DROP);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_CAN_DROP);
|
||||
|
||||
CHECK(root->gui_is_dragging());
|
||||
CHECK_FALSE(root->gui_is_drag_successful());
|
||||
|
|
@ -1194,11 +1194,11 @@ TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") {
|
|||
|
||||
// Move above a Control, that is not a Drop target.
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_a, MouseButtonMask::LEFT, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_FORBIDDEN);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_FORBIDDEN);
|
||||
|
||||
// Move above a Control, that is a Drop target, but has disallowed this point.
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_d + Point2i(20, 0), MouseButtonMask::LEFT, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_FORBIDDEN);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_FORBIDDEN);
|
||||
CHECK(root->gui_is_dragging());
|
||||
|
||||
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d + Point2i(20, 0), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE);
|
||||
|
|
@ -1220,7 +1220,7 @@ TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") {
|
|||
|
||||
// Move away from Controls.
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_background, MouseButtonMask::LEFT, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_ARROW);
|
||||
|
||||
CHECK(root->gui_is_dragging());
|
||||
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_background, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE);
|
||||
|
|
@ -1237,7 +1237,7 @@ TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") {
|
|||
CHECK(root->gui_is_dragging());
|
||||
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_d, MouseButtonMask::LEFT, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_CAN_DROP);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_CAN_DROP);
|
||||
|
||||
// Move outside of window.
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_outside, MouseButtonMask::LEFT, Key::NONE);
|
||||
|
|
@ -1444,7 +1444,7 @@ TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") {
|
|||
CHECK(root->gui_is_dragging());
|
||||
CHECK(sv_b->during_drag);
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_svb, MouseButtonMask::LEFT, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_CAN_DROP);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_CAN_DROP);
|
||||
|
||||
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_svb, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(sv_b->valid_drop);
|
||||
|
|
@ -1458,7 +1458,7 @@ TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") {
|
|||
CHECK(sv->gui_is_dragging());
|
||||
CHECK(node_d->during_drag);
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_d, MouseButtonMask::LEFT, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_CAN_DROP);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_CAN_DROP);
|
||||
|
||||
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(node_d->valid_drop);
|
||||
|
|
@ -1472,7 +1472,7 @@ TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") {
|
|||
CHECK(root->gui_is_dragging());
|
||||
CHECK(ew_b->during_drag);
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_ewb, MouseButtonMask::LEFT, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_CAN_DROP);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_CAN_DROP);
|
||||
|
||||
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_ewb, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(ew_b->valid_drop);
|
||||
|
|
@ -1486,7 +1486,7 @@ TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") {
|
|||
CHECK(ew->gui_is_dragging());
|
||||
CHECK(node_d->during_drag);
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_d, MouseButtonMask::LEFT, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_CAN_DROP);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_CAN_DROP);
|
||||
|
||||
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(node_d->valid_drop);
|
||||
|
|
@ -1547,7 +1547,7 @@ TEST_CASE("[SceneTree][Viewport] Control mouse cursor shape") {
|
|||
Point2i on_c = Point2i(5, 5);
|
||||
|
||||
SEND_GUI_MOUSE_MOTION_EVENT(on_c, MouseButtonMask::NONE, Key::NONE);
|
||||
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_FORBIDDEN); // GH-74805
|
||||
CHECK(DS->get_cursor_shape() == DisplayServerEnums::CURSOR_FORBIDDEN); // GH-74805
|
||||
|
||||
memdelete(node_c);
|
||||
memdelete(node_b);
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ struct GodotTestCaseListener : public doctest::IReporter {
|
|||
|
||||
for (int i = 0; i < DisplayServer::get_create_function_count(); i++) {
|
||||
if (String("mock") == DisplayServer::get_create_function_name(i)) {
|
||||
DisplayServer::create(i, "", DisplayServer::WindowMode::WINDOW_MODE_MINIMIZED, DisplayServer::VSyncMode::VSYNC_ENABLED, 0, nullptr, Vector2i(0, 0), DisplayServer::SCREEN_PRIMARY, DisplayServer::CONTEXT_EDITOR, 0, err);
|
||||
DisplayServer::create(i, "", DisplayServerEnums::WindowMode::WINDOW_MODE_MINIMIZED, DisplayServerEnums::VSyncMode::VSYNC_ENABLED, 0, nullptr, Vector2i(0, 0), DisplayServerEnums::SCREEN_PRIMARY, DisplayServerEnums::CONTEXT_EDITOR, 0, err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -232,7 +232,7 @@ struct GodotTestCaseListener : public doctest::IReporter {
|
|||
|
||||
memnew(SceneTree);
|
||||
SceneTree::get_singleton()->initialize();
|
||||
if (!DisplayServer::get_singleton()->has_feature(DisplayServer::Feature::FEATURE_SUBWINDOWS)) {
|
||||
if (!DisplayServer::get_singleton()->has_feature(DisplayServerEnums::FEATURE_SUBWINDOWS)) {
|
||||
SceneTree::get_singleton()->get_root()->set_embedding_subwindows(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue