diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-04-12 23:46:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 23:46:56 +0200 |
commit | 895f2a21f4beea6f4c89d33666bdf3b0925d6db7 (patch) | |
tree | 0a146241304a1a2620802745b1f08b6e2c7a7a02 /editor/plugins/input_event_editor_plugin.cpp | |
parent | 360fff4ccfd7fb0fa364a21ed1401c81502b5712 (diff) | |
parent | 0b0a74e135846b15485eea6e92975e2182edccdc (diff) |
Merge pull request #60081 from fire-forge/input-event-editor-fix
Redesign InputEvent editor and fix `Window.popup_centered()` rect calculation.
Diffstat (limited to 'editor/plugins/input_event_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/input_event_editor_plugin.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/editor/plugins/input_event_editor_plugin.cpp b/editor/plugins/input_event_editor_plugin.cpp index b4a7081ebc..fb0e260388 100644 --- a/editor/plugins/input_event_editor_plugin.cpp +++ b/editor/plugins/input_event_editor_plugin.cpp @@ -33,6 +33,15 @@ void InputEventConfigContainer::_bind_methods() { } +void InputEventConfigContainer::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + open_config_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + } break; + } +} + void InputEventConfigContainer::_configure_pressed() { config_dialog->popup_and_configure(input_event); } @@ -47,12 +56,6 @@ void InputEventConfigContainer::_config_dialog_confirmed() { _event_changed(); } -Size2 InputEventConfigContainer::get_minimum_size() const { - // Don't bother with a minimum x size for the control - we don't want the inspector - // to jump in size if a long text is placed in the label (e.g. Joypad Axis description) - return Size2(0, HBoxContainer::get_minimum_size().y); -} - void InputEventConfigContainer::set_event(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; Ref<InputEventMouseButton> m = p_event; @@ -75,29 +78,26 @@ void InputEventConfigContainer::set_event(const Ref<InputEvent> &p_event) { } InputEventConfigContainer::InputEventConfigContainer() { - MarginContainer *mc = memnew(MarginContainer); - mc->add_theme_constant_override("margin_left", 10); - mc->add_theme_constant_override("margin_right", 10); - mc->add_theme_constant_override("margin_top", 10); - mc->add_theme_constant_override("margin_bottom", 10); - add_child(mc); - - HBoxContainer *hb = memnew(HBoxContainer); - mc->add_child(hb); + input_event_text = memnew(Label); + input_event_text->set_h_size_flags(SIZE_EXPAND_FILL); + input_event_text->set_autowrap_mode(Label::AutowrapMode::AUTOWRAP_WORD_SMART); + input_event_text->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); + add_child(input_event_text); open_config_button = memnew(Button); open_config_button->set_text(TTR("Configure")); open_config_button->connect("pressed", callable_mp(this, &InputEventConfigContainer::_configure_pressed)); - hb->add_child(open_config_button); + add_child(open_config_button); - input_event_text = memnew(Label); - hb->add_child(input_event_text); + add_child(memnew(Control)); config_dialog = memnew(InputEventConfigurationDialog); config_dialog->connect("confirmed", callable_mp(this, &InputEventConfigContainer::_config_dialog_confirmed)); add_child(config_dialog); } +/////////////////////// + bool EditorInspectorPluginInputEvent::can_handle(Object *p_object) { Ref<InputEventKey> k = Ref<InputEventKey>(p_object); Ref<InputEventMouseButton> m = Ref<InputEventMouseButton>(p_object); @@ -115,6 +115,8 @@ void EditorInspectorPluginInputEvent::parse_begin(Object *p_object) { add_custom_control(picker_controls); } +/////////////////////// + InputEventEditorPlugin::InputEventEditorPlugin() { Ref<EditorInspectorPluginInputEvent> plugin; plugin.instantiate(); |