From 5800dd2448c51d8a3b00532b54fa7f2be03fe364 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 22 Aug 2024 16:06:13 -0500 Subject: [PATCH] Shrink listen button in input editors. --- .../Editors/BindableButtonEditor.cs | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Source/Editor/CustomEditors/Editors/BindableButtonEditor.cs b/Source/Editor/CustomEditors/Editors/BindableButtonEditor.cs index f8323bb49..91c508a33 100644 --- a/Source/Editor/CustomEditors/Editors/BindableButtonEditor.cs +++ b/Source/Editor/CustomEditors/Editors/BindableButtonEditor.cs @@ -1,3 +1,4 @@ +using FlaxEditor.CustomEditors.Elements; using FlaxEditor.GUI; using FlaxEngine; using FlaxEngine.GUI; @@ -39,20 +40,27 @@ namespace FlaxEditor.CustomEditors.Editors public override void Initialize(LayoutElementsContainer layout) { Window = layout.Control.RootWindow.Window; + var panelElement = layout.CustomContainer(); + var panel = panelElement.ContainerControl as Panel; - var panel = layout.CustomContainer(); - panel.CustomControl.SlotsHorizontally = 2; - panel.CustomControl.SlotsVertically = 1; - - var button = panel.Button("Listen", "Press to listen for input events"); + var button = panelElement.Button("Listen", "Press to listen for input events"); _button = button.Button; + _button.Width = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText("Listening...").X + 8; + _button.Height = ComboBox.DefaultHeight; _button.Clicked += OnButtonClicked; ResetButton(); - var padding = panel.CustomControl.SlotPadding; - panel.CustomControl.Height = ComboBox.DefaultHeight + padding.Height; + panel.Height = ComboBox.DefaultHeight; - base.Initialize(panel); + base.Initialize(panelElement); + + if (panelElement.Children.Find(x => x is EnumElement) is EnumElement comboBoxElement) + { + var comboBox = comboBoxElement.ComboBox; + comboBox.AnchorPreset = AnchorPresets.StretchAll; + comboBox.Offsets = new Margin(0, _button.Width + 2, 0, 0); + comboBox.LocalX += _button.Width + 2; + } } ///