summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2020-03-07 18:02:54 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2020-03-26 16:24:05 +0100
commit15a9f94346c211b7afe96af500cb3405aabcf6b8 (patch)
tree150287a257a89a0ff579bcc81baa75a0bbca8c79 /scene
parent197cb4e7718034aba35832a547477dfc858a7280 (diff)
Add macOS DisplayServer implementation.
Change global menu to use Callable, add support for check items and submenus.
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/line_edit.cpp21
-rw-r--r--scene/gui/text_edit.cpp20
-rw-r--r--scene/main/node.h1
-rw-r--r--scene/main/scene_tree.cpp7
-rw-r--r--scene/main/scene_tree.h1
-rw-r--r--scene/main/window.cpp16
6 files changed, 38 insertions, 28 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index fd82c33c4e..734e27b1b6 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -913,9 +913,10 @@ void LineEdit::_notification(int p_what) {
}
if (has_focus()) {
-
- DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
- DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + Point2(using_placeholder ? 0 : x_ofs, y_ofs + caret_height), get_viewport()->get_window_id());
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + Point2(using_placeholder ? 0 : x_ofs, y_ofs + caret_height), get_viewport()->get_window_id());
+ }
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -926,9 +927,11 @@ void LineEdit::_notification(int p_what) {
draw_caret = true;
}
- DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
- Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height;
- DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height;
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
+ }
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length);
@@ -940,8 +943,10 @@ void LineEdit::_notification(int p_what) {
caret_blink_timer->stop();
}
- DisplayServer::get_singleton()->window_set_ime_position(Point2(), get_viewport()->get_window_id());
- DisplayServer::get_singleton()->window_set_ime_active(false, get_viewport()->get_window_id());
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_position(Point2(), get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_active(false, get_viewport()->get_window_id());
+ }
ime_text = "";
ime_selection = Point2();
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 49e89f6c6d..fb477ee3b4 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1754,8 +1754,10 @@ void TextEdit::_notification(int p_what) {
}
if (has_focus()) {
- DisplayServer::get_singleton()->window_set_ime_active(true);
- DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height()));
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height()), get_viewport()->get_window_id());
+ }
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -1766,9 +1768,11 @@ void TextEdit::_notification(int p_what) {
draw_caret = true;
}
- DisplayServer::get_singleton()->window_set_ime_active(true);
- Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height();
- DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos);
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height();
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
+ }
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
DisplayServer::get_singleton()->virtual_keyboard_show(get_text(), get_global_rect());
@@ -1779,8 +1783,10 @@ void TextEdit::_notification(int p_what) {
caret_blink_timer->stop();
}
- DisplayServer::get_singleton()->window_set_ime_position(Point2());
- DisplayServer::get_singleton()->window_set_ime_active(false);
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_position(Point2(), get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_active(false, get_viewport()->get_window_id());
+ }
ime_text = "";
ime_selection = Point2();
diff --git a/scene/main/node.h b/scene/main/node.h
index 981477a159..cf25a92be6 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -252,6 +252,7 @@ public:
NOTIFICATION_WM_CLOSE_REQUEST = 1006,
NOTIFICATION_WM_GO_BACK_REQUEST = 1007,
NOTIFICATION_WM_SIZE_CHANGED = 1008,
+ NOTIFICATION_WM_DPI_CHANGE = 1009,
NOTIFICATION_OS_MEMORY_WARNING = MainLoop::NOTIFICATION_OS_MEMORY_WARNING,
NOTIFICATION_TRANSLATION_CHANGED = MainLoop::NOTIFICATION_TRANSLATION_CHANGED,
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 33cb067db1..fad10524b9 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -1104,12 +1104,6 @@ void SceneTree::add_current_scene(Node *p_current) {
root->add_child(p_current);
}
-void SceneTree::global_menu_action(const Variant &p_id, const Variant &p_meta) {
-
- emit_signal("global_menu_action", p_id, p_meta);
- MainLoop::global_menu_action(p_id, p_meta);
-}
-
Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_pause) {
Ref<SceneTreeTimer> stt;
@@ -1315,7 +1309,6 @@ void SceneTree::_bind_methods() {
ADD_SIGNAL(MethodInfo("physics_frame"));
ADD_SIGNAL(MethodInfo("files_dropped", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "screen")));
- ADD_SIGNAL(MethodInfo("global_menu_action", PropertyInfo(Variant::NIL, "id"), PropertyInfo(Variant::NIL, "meta")));
ADD_SIGNAL(MethodInfo("network_peer_connected", PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("network_peer_disconnected", PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("connected_to_server"));
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 4fb19a57d5..e6b2575f98 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -331,7 +331,6 @@ public:
static SceneTree *get_singleton() { return singleton; }
- void global_menu_action(const Variant &p_id, const Variant &p_meta);
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
//network API
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 5054e18a7a..a2a49aea75 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -104,19 +104,22 @@ void Window::set_max_size(const Size2i &p_max_size) {
}
_update_window_size();
}
-Size2i Window::get_max_size() const {
- return min_size;
+Size2i Window::get_max_size() const {
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ max_size = DisplayServer::get_singleton()->window_get_max_size(window_id);
+ }
+ return max_size;
}
void Window::set_min_size(const Size2i &p_min_size) {
-
min_size = p_min_size;
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
- DisplayServer::get_singleton()->window_set_min_size(max_size, window_id);
+ DisplayServer::get_singleton()->window_set_min_size(min_size, window_id);
}
_update_window_size();
}
+
Size2i Window::get_min_size() const {
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
min_size = DisplayServer::get_singleton()->window_get_min_size(window_id);
@@ -338,6 +341,10 @@ void Window::_event_callback(DisplayServer::WindowEvent p_event) {
_propagate_window_notification(this, NOTIFICATION_WM_GO_BACK_REQUEST);
emit_signal("go_back_requested");
} break;
+ case DisplayServer::WINDOW_EVENT_DPI_CHANGE: {
+ _propagate_window_notification(this, NOTIFICATION_WM_DPI_CHANGE);
+ emit_signal("dpi_changed");
+ } break;
}
}
@@ -1360,7 +1367,6 @@ void Window::_bind_methods() {
ADD_SIGNAL(MethodInfo("close_requested"));
ADD_SIGNAL(MethodInfo("go_back_requested"));
ADD_SIGNAL(MethodInfo("visibility_changed"));
- ADD_SIGNAL(MethodInfo("files_dropped"));
ADD_SIGNAL(MethodInfo("about_to_popup"));
BIND_CONSTANT(NOTIFICATION_VISIBILITY_CHANGED);