Path: blob/master/editor/settings/editor_settings_dialog.h
21414 views
/**************************************************************************/1/* editor_settings_dialog.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "editor/inspector/editor_inspector.h"33#include "scene/gui/dialogs.h"3435class CheckButton;36class EditorEventSearchBar;37class EventListenerLineEdit;38class InputEventConfigurationDialog;39class PanelContainer;40class SectionedInspector;41class TabContainer;42class TextureRect;43class Tree;44class TreeItem;4546class EditorSettingsDialog : public AcceptDialog {47GDCLASS(EditorSettingsDialog, AcceptDialog);4849TabContainer *tabs = nullptr;50Control *tab_general = nullptr;51Control *tab_shortcuts = nullptr;5253LineEdit *search_box = nullptr;54CheckButton *advanced_switch = nullptr;55SectionedInspector *inspector = nullptr;56EditorEventSearchBar *shortcut_search_bar = nullptr;5758// Shortcuts59enum ShortcutButton {60SHORTCUT_ADD,61SHORTCUT_EDIT,62SHORTCUT_ERASE,63SHORTCUT_REVERT64};6566Tree *shortcuts = nullptr;6768InputEventConfigurationDialog *shortcut_editor = nullptr;6970bool is_editing_action = false;71String current_edited_identifier;72Array current_events;73int current_event_index = -1;7475Timer *timer = nullptr;7677virtual void cancel_pressed() override;78virtual void ok_pressed() override;7980void _settings_changed();81void _settings_property_edited();82void _settings_save();8384virtual void shortcut_input(const Ref<InputEvent> &p_event) override;85void _notification(int p_what);86void _update_icons();8788void _event_config_confirmed();89bool _is_in_project_manager() const;9091TreeItem *_create_shortcut_treeitem(TreeItem *p_parent, const String &p_shortcut_identifier, const String &p_display, Array &p_events, bool p_allow_revert, bool p_is_common, bool p_is_collapsed);92Array _event_list_to_array_helper(const List<Ref<InputEvent>> &p_events);93void _update_builtin_action(const String &p_name, const Array &p_events);94void _update_shortcut_events(const String &p_path, const Array &p_events);9596Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);97bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;98void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);99100void _tabs_tab_changed(int p_tab);101void _focus_current_search_box();102103void _advanced_toggled(bool p_button_pressed);104105void _update_dynamic_property_hints();106PropertyInfo _create_mouse_shortcut_property_info(const String &p_property_name, const String &p_shortcut_1_name, const String &p_shortcut_2_name);107String _get_shortcut_button_string(const String &p_shortcut_name);108109bool _should_display_shortcut(const String &p_name, const Array &p_events, bool p_match_localized_name) const;110111void _update_shortcuts();112void _shortcut_button_pressed(Object *p_item, int p_column, int p_idx, MouseButton p_button = MouseButton::LEFT);113void _shortcut_cell_double_clicked();114static void _set_shortcut_input(const String &p_name, Ref<InputEventKey> &p_event);115116static void _undo_redo_callback(void *p_self, const String &p_name);117118Label *restart_label = nullptr;119TextureRect *restart_icon = nullptr;120PanelContainer *restart_container = nullptr;121Button *restart_close_button = nullptr;122123void _editor_restart_request();124void _editor_restart();125void _editor_restart_close();126127protected:128static void _bind_methods();129130public:131void popup_edit_settings();132static void update_navigation_preset();133134EditorSettingsDialog();135};136137class EditorSettingsPropertyWrapper : public EditorProperty {138GDCLASS(EditorSettingsPropertyWrapper, EditorProperty);139140String property;141PropertyHint hint;142String hint_text;143uint32_t usage;144145EditorProperty *editor_property = nullptr;146147HBoxContainer *override_container = nullptr;148TextureRect *override_icon = nullptr;149EditorProperty *override_editor_property = nullptr;150Button *goto_button = nullptr;151Button *remove_button = nullptr;152153void _setup_override_info();154void _update_override();155void _create_override();156void _remove_override();157158protected:159void _notification(int p_what);160161public:162static inline Callable restart_request_callback;163164virtual void update_property() override;165void setup(const String &p_property, EditorProperty *p_editor_property, PropertyHint p_hint, const String &p_hint_text, uint32_t p_usage);166};167168class EditorSettingsInspectorPlugin : public EditorInspectorPlugin {169GDCLASS(EditorSettingsInspectorPlugin, EditorInspectorPlugin);170171Object *current_object = nullptr;172173public:174SectionedInspector *inspector = nullptr;175176virtual bool can_handle(Object *p_object) override;177virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;178};179180181