diff --git a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs index bf82e19da..d84414fcf 100644 --- a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs @@ -25,6 +25,7 @@ namespace FlaxEditor.CustomEditors.Dedicated private DragHandlers _dragHandlers; private DragScriptItems _dragScripts; private DragAssets _dragAssets; + private Button _addScriptsButton; /// /// The parent scripts editor. @@ -40,16 +41,19 @@ namespace FlaxEditor.CustomEditors.Dedicated AutoFocus = false; // Add script button - float addScriptButtonWidth = 60.0f; - var addScriptButton = new Button + var buttonText = "Add script"; + var textSize = Style.Current.FontMedium.MeasureText(buttonText); + float addScriptButtonWidth = (textSize.X < 60.0f) ? 60.0f : textSize.X + 4; + var buttonHeight = (textSize.Y < 18) ? 18 : textSize.Y + 4; + _addScriptsButton = new Button { TooltipText = "Add new scripts to the actor", AnchorPreset = AnchorPresets.MiddleCenter, - Text = "Add script", + Text = buttonText, Parent = this, - Bounds = new Rectangle((Width - addScriptButtonWidth) / 2, 1, addScriptButtonWidth, 18), + Bounds = new Rectangle((Width - addScriptButtonWidth) / 2, 1, addScriptButtonWidth, buttonHeight), }; - addScriptButton.ButtonClicked += OnAddScriptButtonClicked; + _addScriptsButton.ButtonClicked += OnAddScriptButtonClicked; } private void OnAddScriptButtonClicked(Button button) @@ -82,7 +86,7 @@ namespace FlaxEditor.CustomEditors.Dedicated var size = Size; // Info - Render2D.DrawText(style.FontSmall, "Drag scripts here", new Rectangle(2, 22, size.X - 4, size.Y - 4 - 20), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center); + Render2D.DrawText(style.FontSmall, "Drag scripts here", new Rectangle(2, _addScriptsButton.Height + 4, size.X - 4, size.Y - 4 - 20), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center); // Check if drag is over if (IsDragOver && _dragHandlers != null && _dragHandlers.HasValidDrag) diff --git a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs index fde4967e8..5215e23a4 100644 --- a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs @@ -422,12 +422,14 @@ namespace FlaxEditor.CustomEditors.Dedicated // Set control type button var space = layout.Space(20); - float setTypeButtonWidth = 60.0f; + var buttonText = "Set Type"; + var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(buttonText); + float setTypeButtonWidth = (textSize.X < 60.0f) ? 60.0f : textSize.X + 4; var setTypeButton = new Button { TooltipText = "Sets the control to the given type", AnchorPreset = AnchorPresets.MiddleCenter, - Text = "Set Type", + Text = buttonText, Parent = space.Spacer, Bounds = new Rectangle((space.Spacer.Width - setTypeButtonWidth) / 2, 1, setTypeButtonWidth, 18), }; diff --git a/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs b/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs index cb4e7b9c1..4aa02ac78 100644 --- a/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs +++ b/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs @@ -88,20 +88,20 @@ namespace FlaxEditor.CustomEditors.Editors LinkValues = Editor.Instance.Windows.PropertiesWin.ScaleLinked; // Add button with the link icon + _linkButton = new Button { BackgroundBrush = new SpriteBrush(Editor.Instance.Icons.Link32), Parent = LinkedLabel, Width = 18, Height = 18, - AnchorPreset = AnchorPresets.TopLeft, + AnchorPreset = AnchorPresets.MiddleLeft, }; _linkButton.Clicked += ToggleLink; ToggleEnabled(); SetLinkStyle(); - var x = LinkedLabel.Text.Value.Length * 7 + 5; - _linkButton.LocalX += x; - _linkButton.LocalY += 1; + var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(LinkedLabel.Text.Value); + _linkButton.LocalX += textSize.X + 10; LinkedLabel.SetupContextMenu += (label, menu, editor) => { menu.AddSeparator(); diff --git a/Source/Editor/CustomEditors/Editors/TagEditor.cs b/Source/Editor/CustomEditors/Editors/TagEditor.cs index 61e0bba7d..911397785 100644 --- a/Source/Editor/CustomEditors/Editors/TagEditor.cs +++ b/Source/Editor/CustomEditors/Editors/TagEditor.cs @@ -623,13 +623,18 @@ namespace FlaxEditor.CustomEditors.Editors { _label = layout.ClickableLabel(GetText(out _)).CustomControl; _label.RightClick += ShowPicker; + var buttonText = "..."; var button = new Button { Size = new Float2(16.0f), - Text = "...", + Text = buttonText, TooltipText = "Edit...", Parent = _label, }; + var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(buttonText); + if (textSize.Y > button.Width) + button.Width = textSize.Y + 2; + button.SetAnchorPreset(AnchorPresets.MiddleRight, false, true); button.Clicked += ShowPicker; } diff --git a/Source/Editor/GUI/Row.cs b/Source/Editor/GUI/Row.cs index 8dad8b20d..b07d693e5 100644 --- a/Source/Editor/GUI/Row.cs +++ b/Source/Editor/GUI/Row.cs @@ -37,6 +37,9 @@ namespace FlaxEditor.GUI : base(0, 0, 100, height) { Depth = -1; + + if (Height < Style.Current.FontMedium.Height) + Height = Style.Current.FontMedium.Height + 4; } /// diff --git a/Source/Editor/Tools/Foliage/FoliageTab.cs b/Source/Editor/Tools/Foliage/FoliageTab.cs index 814376c75..10358a8c0 100644 --- a/Source/Editor/Tools/Foliage/FoliageTab.cs +++ b/Source/Editor/Tools/Foliage/FoliageTab.cs @@ -137,14 +137,23 @@ namespace FlaxEditor.Tools.Foliage Offsets = Margin.Zero, Parent = _noFoliagePanel }; + + var buttonText = "Create new foliage"; _createNewFoliage = new Button { - Text = "Create new foliage", + Text = buttonText, AnchorPreset = AnchorPresets.MiddleCenter, Offsets = new Margin(-60, 120, -12, 24), Parent = _noFoliagePanel, Enabled = false }; + var textSize = Style.Current.FontMedium.MeasureText(buttonText); + if (_createNewFoliage.Width < textSize.X) + { + _createNewFoliage.LocalX -= (textSize.X - _createNewFoliage.Width) / 2; + _createNewFoliage.Width = textSize.X + 6; + } + _createNewFoliage.Clicked += OnCreateNewFoliageClicked; } diff --git a/Source/Editor/Tools/Terrain/CarveTab.cs b/Source/Editor/Tools/Terrain/CarveTab.cs index 6bee0bd92..000f90817 100644 --- a/Source/Editor/Tools/Terrain/CarveTab.cs +++ b/Source/Editor/Tools/Terrain/CarveTab.cs @@ -95,14 +95,23 @@ namespace FlaxEditor.Tools.Terrain Offsets = Margin.Zero, Parent = _noTerrainPanel }; + + var buttonText = "Create new terrain"; _createTerrainButton = new Button { - Text = "Create new terrain", + Text = buttonText, AnchorPreset = AnchorPresets.MiddleCenter, Offsets = new Margin(-60, 120, -12, 24), Parent = _noTerrainPanel, Enabled = false }; + var textSize = Style.Current.FontMedium.MeasureText(buttonText); + if (_createTerrainButton.Width < textSize.X) + { + _createTerrainButton.LocalX -= (textSize.X - _createTerrainButton.Width) / 2; + _createTerrainButton.Width = textSize.X + 6; + } + _createTerrainButton.Clicked += OnCreateNewTerrainClicked; } diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs index 34dbe561c..8c71a8b02 100644 --- a/Source/Editor/Viewport/EditorViewport.cs +++ b/Source/Editor/Viewport/EditorViewport.cs @@ -441,6 +441,9 @@ namespace FlaxEditor.Viewport if (useWidgets) { + var largestText = "Invert Panning"; + var textSize = Style.Current.FontMedium.MeasureText(largestText); + var xLocationForExtras = textSize.X + 5; // Camera speed widget var camSpeed = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight); var camSpeedCM = new ContextMenu(); @@ -541,7 +544,7 @@ namespace FlaxEditor.Viewport { var ortho = ViewWidgetButtonMenu.AddButton("Orthographic"); ortho.CloseMenuOnClick = false; - var orthoValue = new CheckBox(90, 2, _isOrtho) + var orthoValue = new CheckBox(xLocationForExtras, 2, _isOrtho) { Parent = ortho }; @@ -581,7 +584,7 @@ namespace FlaxEditor.Viewport { var fov = ViewWidgetButtonMenu.AddButton("Field Of View"); fov.CloseMenuOnClick = false; - var fovValue = new FloatValueBox(1, 90, 2, 70.0f, 35.0f, 160.0f, 0.1f) + var fovValue = new FloatValueBox(1, xLocationForExtras, 2, 70.0f, 35.0f, 160.0f, 0.1f) { Parent = fov }; @@ -598,7 +601,7 @@ namespace FlaxEditor.Viewport { var orthoSize = ViewWidgetButtonMenu.AddButton("Ortho Scale"); orthoSize.CloseMenuOnClick = false; - var orthoSizeValue = new FloatValueBox(_orthoSize, 90, 2, 70.0f, 0.001f, 100000.0f, 0.01f) + var orthoSizeValue = new FloatValueBox(_orthoSize, xLocationForExtras, 2, 70.0f, 0.001f, 100000.0f, 0.01f) { Parent = orthoSize }; @@ -615,7 +618,7 @@ namespace FlaxEditor.Viewport { var nearPlane = ViewWidgetButtonMenu.AddButton("Near Plane"); nearPlane.CloseMenuOnClick = false; - var nearPlaneValue = new FloatValueBox(2.0f, 90, 2, 70.0f, 0.001f, 1000.0f) + var nearPlaneValue = new FloatValueBox(2.0f, xLocationForExtras, 2, 70.0f, 0.001f, 1000.0f) { Parent = nearPlane }; @@ -627,7 +630,7 @@ namespace FlaxEditor.Viewport { var farPlane = ViewWidgetButtonMenu.AddButton("Far Plane"); farPlane.CloseMenuOnClick = false; - var farPlaneValue = new FloatValueBox(1000, 90, 2, 70.0f, 10.0f) + var farPlaneValue = new FloatValueBox(1000, xLocationForExtras, 2, 70.0f, 10.0f) { Parent = farPlane }; @@ -639,7 +642,7 @@ namespace FlaxEditor.Viewport { var brightness = ViewWidgetButtonMenu.AddButton("Brightness"); brightness.CloseMenuOnClick = false; - var brightnessValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.001f, 10.0f, 0.001f) + var brightnessValue = new FloatValueBox(1.0f, xLocationForExtras, 2, 70.0f, 0.001f, 10.0f, 0.001f) { Parent = brightness }; @@ -651,7 +654,7 @@ namespace FlaxEditor.Viewport { var resolution = ViewWidgetButtonMenu.AddButton("Resolution"); resolution.CloseMenuOnClick = false; - var resolutionValue = new FloatValueBox(1.0f, 90, 2, 70.0f, 0.1f, 4.0f, 0.001f) + var resolutionValue = new FloatValueBox(1.0f, xLocationForExtras, 2, 70.0f, 0.1f, 4.0f, 0.001f) { Parent = resolution }; @@ -663,7 +666,7 @@ namespace FlaxEditor.Viewport { var invert = ViewWidgetButtonMenu.AddButton("Invert Panning"); invert.CloseMenuOnClick = false; - var invertValue = new CheckBox(90, 2, _invertPanning) + var invertValue = new CheckBox(xLocationForExtras, 2, _invertPanning) { Parent = invert }; diff --git a/Source/Editor/Windows/AboutDialog.cs b/Source/Editor/Windows/AboutDialog.cs index 4b9595445..b059dadcb 100644 --- a/Source/Editor/Windows/AboutDialog.cs +++ b/Source/Editor/Windows/AboutDialog.cs @@ -52,9 +52,11 @@ namespace FlaxEditor.Windows VerticalAlignment = TextAlignment.Near, Parent = this }; - var copyVersionButton = new Button(Width - 104, 6, 100, 20) + var buttonText = "Copy version info"; + var fontSize = Style.Current.FontMedium.MeasureText(buttonText); + var copyVersionButton = new Button(Width - fontSize.X - 8, 6, fontSize.X + 4, 20) { - Text = "Copy version info", + Text = buttonText, TooltipText = "Copies the current engine version information to system clipboard.", Parent = this };