made it easier to scroll and resize the material source window. and added the ability to change if the text can be scrolled in the text box

This commit is contained in:
Chandler Cox
2022-11-04 10:53:29 -05:00
parent 38d65d38d1
commit c817b63927
2 changed files with 28 additions and 8 deletions

View File

@@ -738,9 +738,10 @@ namespace FlaxEditor.Utilities
var settings = CreateWindowSettings.Default; var settings = CreateWindowSettings.Default;
settings.ActivateWhenFirstShown = true; settings.ActivateWhenFirstShown = true;
settings.AllowMaximize = false; settings.AllowMaximize = true;
settings.AllowMinimize = false; settings.AllowMinimize = false;
settings.HasSizingFrame = false; settings.HasSizingFrame = true;
settings.HasBorder = true;
settings.StartPosition = WindowStartPosition.CenterParent; settings.StartPosition = WindowStartPosition.CenterParent;
settings.Size = new Float2(500, 600) * (parentWindow?.DpiScale ?? Platform.DpiScale); settings.Size = new Float2(500, 600) * (parentWindow?.DpiScale ?? Platform.DpiScale);
settings.Parent = parentWindow; settings.Parent = parentWindow;
@@ -753,12 +754,26 @@ namespace FlaxEditor.Utilities
Parent = dialog.GUI, Parent = dialog.GUI,
}; };
copyButton.Clicked += () => Clipboard.Text = source; copyButton.Clicked += () => Clipboard.Text = source;
var sourceTextBox = new TextBox(true, 2, copyButton.Bottom + 4, settings.Size.X - 4); var backPanel = new Panel
sourceTextBox.Height = settings.Size.Y - sourceTextBox.Top - 2; {
AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, copyButton.Bottom + 4, 0),
ScrollBars = ScrollBars.Both,
IsScrollable = true,
Parent = dialog.GUI,
};
var sourceTextBox = new TextBox(true, 0, 0, 0);
sourceTextBox.Parent = backPanel;
sourceTextBox.AnchorPreset = AnchorPresets.HorizontalStretchTop;
sourceTextBox.Text = source; sourceTextBox.Text = source;
sourceTextBox.Parent = dialog.GUI; sourceTextBox.Height = sourceTextBox.TextSize.Y;
sourceTextBox.Width = sourceTextBox.TextSize.X;
sourceTextBox.TextChanged += () => sourceTextBox.Height = sourceTextBox.TextSize.Y;
sourceTextBox.CanScrollMultilineText = false;
sourceTextBox.IsScrollable = true;
dialog.Show(); dialog.Show();
dialog.Focus(); dialog.Focus();
} }

View File

@@ -229,6 +229,11 @@ namespace FlaxEngine.GUI
[EditorOrder(529)] [EditorOrder(529)]
public bool ClipText { get; set; } = true; public bool ClipText { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether you can scroll the text in the text box
/// </summary>
public bool CanScrollMultilineText { get; set; } = true;
/// <summary> /// <summary>
/// Gets or sets textbox background color when the control is selected (has focus). /// Gets or sets textbox background color when the control is selected (has focus).
/// </summary> /// </summary>
@@ -1157,7 +1162,7 @@ namespace FlaxEngine.GUI
return true; return true;
// Multiline scroll // Multiline scroll
if (IsMultiline && _text.Length != 0) if (IsMultiline && _text.Length != 0 && CanScrollMultilineText)
{ {
TargetViewOffset = Float2.Clamp(_targetViewOffset - new Float2(0, delta * 10.0f), Float2.Zero, new Float2(_targetViewOffset.X, _textSize.Y)); TargetViewOffset = Float2.Clamp(_targetViewOffset - new Float2(0, delta * 10.0f), Float2.Zero, new Float2(_targetViewOffset.X, _textSize.Y));
return true; return true;