Path: blob/master/editor/settings/editor_settings_dialog.h
9903 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);4849bool updating = false;5051TabContainer *tabs = nullptr;52Control *tab_general = nullptr;53Control *tab_shortcuts = nullptr;5455LineEdit *search_box = nullptr;56CheckButton *advanced_switch = nullptr;57SectionedInspector *inspector = nullptr;58EditorEventSearchBar *shortcut_search_bar = nullptr;5960// Shortcuts61enum ShortcutButton {62SHORTCUT_ADD,63SHORTCUT_EDIT,64SHORTCUT_ERASE,65SHORTCUT_REVERT66};6768Tree *shortcuts = nullptr;6970InputEventConfigurationDialog *shortcut_editor = nullptr;7172bool is_editing_action = false;73String current_edited_identifier;74Array current_events;75int current_event_index = -1;7677Timer *timer = nullptr;7879virtual void cancel_pressed() override;80virtual void ok_pressed() override;8182void _settings_changed();83void _settings_property_edited(const String &p_name);84void _settings_save();8586virtual void shortcut_input(const Ref<InputEvent> &p_event) override;87void _notification(int p_what);88void _update_icons();8990void _event_config_confirmed();9192TreeItem *_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);93Array _event_list_to_array_helper(const List<Ref<InputEvent>> &p_events);94void _update_builtin_action(const String &p_name, const Array &p_events);95void _update_shortcut_events(const String &p_path, const Array &p_events);9697Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);98bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;99void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);100101void _tabs_tab_changed(int p_tab);102void _focus_current_search_box();103104void _advanced_toggled(bool p_button_pressed);105106void _update_dynamic_property_hints();107PropertyInfo _create_mouse_shortcut_property_info(const String &p_property_name, const String &p_shortcut_1_name, const String &p_shortcut_2_name);108String _get_shortcut_button_string(const String &p_shortcut_name);109110bool _should_display_shortcut(const String &p_name, const Array &p_events, bool p_match_localized_name) const;111112void _update_shortcuts();113void _shortcut_button_pressed(Object *p_item, int p_column, int p_idx, MouseButton p_button = MouseButton::LEFT);114void _shortcut_cell_double_clicked();115static void _set_shortcut_input(const String &p_name, Ref<InputEventKey> &p_event);116117static void _undo_redo_callback(void *p_self, const String &p_name);118119Label *restart_label = nullptr;120TextureRect *restart_icon = nullptr;121PanelContainer *restart_container = nullptr;122Button *restart_close_button = nullptr;123124void _editor_restart_request();125void _editor_restart();126void _editor_restart_close();127128protected:129static void _bind_methods();130131public:132void popup_edit_settings();133static void update_navigation_preset();134135EditorSettingsDialog();136};137138class EditorSettingsPropertyWrapper : public EditorProperty {139GDCLASS(EditorSettingsPropertyWrapper, EditorProperty);140141String property;142EditorProperty *editor_property = nullptr;143144BoxContainer *container = nullptr;145146HBoxContainer *override_info = nullptr;147Label *override_label = nullptr;148Button *goto_button = nullptr;149Button *remove_button = nullptr;150151bool requires_restart = false;152153void _update_override();154void _create_override();155void _remove_override();156157protected:158void _notification(int p_what);159160public:161static inline Callable restart_request_callback;162163virtual void update_property() override;164void setup(const String &p_property, EditorProperty *p_editor_property, bool p_requires_restart);165};166167class EditorSettingsInspectorPlugin : public EditorInspectorPlugin {168GDCLASS(EditorSettingsInspectorPlugin, EditorInspectorPlugin);169170Object *current_object = nullptr;171172public:173SectionedInspector *inspector = nullptr;174175virtual bool can_handle(Object *p_object) override;176virtual 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;177};178179180