diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-03-26 17:23:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-26 17:23:11 +0100 |
commit | 5f1107aa30295e686be6f41cb6d17fc2cff1e036 (patch) | |
tree | 7bce4c680e6686c9d29be8b479be5b39205ce7a3 /editor/settings_config_dialog.cpp | |
parent | a2da99f40cf2123c0906c734a2eb01e9b65a45a2 (diff) | |
parent | be07f86f85ab70a48b310b42faa64e72a74ca694 (diff) |
Merge pull request #37317 from akien-mga/display-server-rebased
Separate DisplayServer from OS and add multiple windows support
Diffstat (limited to 'editor/settings_config_dialog.cpp')
-rw-r--r-- | editor/settings_config_dialog.cpp | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index cf93fab9a8..6bd06aff64 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -118,6 +118,12 @@ void EditorSettingsDialog::_undo_redo_callback(void *p_self, const String &p_nam void EditorSettingsDialog::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible()) { + EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "editor_settings", Rect2(get_position(), get_size())); + set_process_unhandled_input(false); + } + } break; case NOTIFICATION_READY: { undo_redo->set_method_notify_callback(EditorDebuggerNode::_method_changeds, NULL); undo_redo->set_property_notify_callback(EditorDebuggerNode::_property_changeds, NULL); @@ -126,10 +132,6 @@ void EditorSettingsDialog::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { _update_icons(); } break; - case NOTIFICATION_POPUP_HIDE: { - EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "editor_settings", get_rect()); - set_process_unhandled_input(false); - } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { _update_icons(); // Update theme colors. @@ -143,7 +145,7 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { const Ref<InputEventKey> k = p_event; - if (k.is_valid() && is_window_modal_on_top() && k->is_pressed()) { + if (k.is_valid() && k->is_pressed()) { bool handled = false; @@ -169,22 +171,22 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { } if (handled) { - accept_event(); + set_input_as_handled(); } } } void EditorSettingsDialog::_update_icons() { - search_box->set_right_icon(get_icon("Search", "EditorIcons")); + search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); - shortcut_search_box->set_right_icon(get_icon("Search", "EditorIcons")); + shortcut_search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); shortcut_search_box->set_clear_button_enabled(true); - restart_close_button->set_icon(get_icon("Close", "EditorIcons")); - restart_container->add_style_override("panel", get_stylebox("bg", "Tree")); - restart_icon->set_texture(get_icon("StatusWarning", "EditorIcons")); - restart_label->add_color_override("font_color", get_color("warning_color", "Editor")); + restart_close_button->set_icon(shortcuts->get_theme_icon("Close", "EditorIcons")); + restart_container->add_theme_style_override("panel", shortcuts->get_theme_stylebox("bg", "Tree")); + restart_icon->set_texture(shortcuts->get_theme_icon("StatusWarning", "EditorIcons")); + restart_label->add_theme_color_override("font_color", shortcuts->get_theme_color("warning_color", "Editor")); } void EditorSettingsDialog::_update_shortcuts() { @@ -230,8 +232,8 @@ void EditorSettingsDialog::_update_shortcuts() { } sections[section_name] = section; - section->set_custom_bg_color(0, get_color("prop_subsection", "Editor")); - section->set_custom_bg_color(1, get_color("prop_subsection", "Editor")); + section->set_custom_bg_color(0, shortcuts->get_theme_color("prop_subsection", "Editor")); + section->set_custom_bg_color(1, shortcuts->get_theme_color("prop_subsection", "Editor")); } // Don't match unassigned shortcuts when searching for assigned keys in search results. @@ -243,16 +245,16 @@ void EditorSettingsDialog::_update_shortcuts() { item->set_text(1, sc->get_as_text()); if (!sc->is_shortcut(original) && !(sc->get_shortcut().is_null() && original.is_null())) { - item->add_button(1, get_icon("Reload", "EditorIcons"), 2); + item->add_button(1, shortcuts->get_theme_icon("Reload", "EditorIcons"), 2); } if (sc->get_as_text() == "None") { // Fade out unassigned shortcut labels for easier visual grepping. - item->set_custom_color(1, get_color("font_color", "Label") * Color(1, 1, 1, 0.5)); + item->set_custom_color(1, shortcuts->get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.5)); } - item->add_button(1, get_icon("Edit", "EditorIcons"), 0); - item->add_button(1, get_icon("Close", "EditorIcons"), 1); + item->add_button(1, shortcuts->get_theme_icon("Edit", "EditorIcons"), 0); + item->add_button(1, shortcuts->get_theme_icon("Close", "EditorIcons"), 1); item->set_tooltip(0, E->get()); item->set_metadata(0, E->get()); } @@ -279,9 +281,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column press_a_key_label->set_text(TTR("Press a Key...")); last_wait_for_key = Ref<InputEventKey>(); press_a_key->popup_centered(Size2(250, 80) * EDSCALE); - press_a_key->grab_focus(); - press_a_key->get_ok()->set_focus_mode(FOCUS_NONE); - press_a_key->get_cancel()->set_focus_mode(FOCUS_NONE); + //press_a_key->grab_focus(); + press_a_key->get_ok()->set_focus_mode(Control::FOCUS_NONE); + press_a_key->get_cancel()->set_focus_mode(Control::FOCUS_NONE); shortcut_configured = item; } else if (p_idx == 1) { //erase @@ -323,7 +325,7 @@ void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) { const String str = keycode_get_string(k->get_keycode_with_modifiers()); press_a_key_label->set_text(str); - press_a_key->accept_event(); + press_a_key->set_input_as_handled(); } } @@ -394,7 +396,7 @@ void EditorSettingsDialog::_bind_methods() { EditorSettingsDialog::EditorSettingsDialog() { set_title(TTR("Editor Settings")); - set_resizable(true); + undo_redo = memnew(UndoRedo); tabs = memnew(TabContainer); @@ -430,7 +432,7 @@ EditorSettingsDialog::EditorSettingsDialog() { HBoxContainer *restart_hb = memnew(HBoxContainer); restart_container->add_child(restart_hb); restart_icon = memnew(TextureRect); - restart_icon->set_v_size_flags(SIZE_SHRINK_CENTER); + restart_icon->set_v_size_flags(Control::SIZE_SHRINK_CENTER); restart_hb->add_child(restart_icon); restart_label = memnew(Label); restart_label->set_text(TTR("The editor must be restarted for changes to take effect.")); @@ -462,7 +464,7 @@ EditorSettingsDialog::EditorSettingsDialog() { shortcuts = memnew(Tree); tab_shortcuts->add_child(shortcuts, true); - shortcuts->set_v_size_flags(SIZE_EXPAND_FILL); + shortcuts->set_v_size_flags(Control::SIZE_EXPAND_FILL); shortcuts->set_columns(2); shortcuts->set_hide_root(true); shortcuts->set_column_titles_visible(true); @@ -471,7 +473,7 @@ EditorSettingsDialog::EditorSettingsDialog() { shortcuts->connect("button_pressed", callable_mp(this, &EditorSettingsDialog::_shortcut_button_pressed)); press_a_key = memnew(ConfirmationDialog); - press_a_key->set_focus_mode(FOCUS_ALL); + //press_a_key->set_focus_mode(Control::FOCUS_ALL); add_child(press_a_key); Label *l = memnew(Label); @@ -479,10 +481,10 @@ EditorSettingsDialog::EditorSettingsDialog() { l->set_anchors_and_margins_preset(Control::PRESET_WIDE); l->set_align(Label::ALIGN_CENTER); l->set_margin(MARGIN_TOP, 20); - l->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 30); + l->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_BEGIN, 30); press_a_key_label = l; press_a_key->add_child(l); - press_a_key->connect("gui_input", callable_mp(this, &EditorSettingsDialog::_wait_for_key)); + press_a_key->connect("window_input", callable_mp(this, &EditorSettingsDialog::_wait_for_key)); press_a_key->connect("confirmed", callable_mp(this, &EditorSettingsDialog::_press_a_key_confirm)); set_hide_on_ok(true); |