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;
settings.ActivateWhenFirstShown = true;
settings.AllowMaximize = false;
settings.AllowMaximize = true;
settings.AllowMinimize = false;
settings.HasSizingFrame = false;
settings.HasSizingFrame = true;
settings.HasBorder = true;
settings.StartPosition = WindowStartPosition.CenterParent;
settings.Size = new Float2(500, 600) * (parentWindow?.DpiScale ?? Platform.DpiScale);
settings.Parent = parentWindow;
@@ -753,12 +754,26 @@ namespace FlaxEditor.Utilities
Parent = dialog.GUI,
};
copyButton.Clicked += () => Clipboard.Text = source;
var sourceTextBox = new TextBox(true, 2, copyButton.Bottom + 4, settings.Size.X - 4);
sourceTextBox.Height = settings.Size.Y - sourceTextBox.Top - 2;
var backPanel = new Panel
{
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.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.Focus();
}

View File

@@ -229,6 +229,11 @@ namespace FlaxEngine.GUI
[EditorOrder(529)]
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>
/// Gets or sets textbox background color when the control is selected (has focus).
/// </summary>
@@ -1157,7 +1162,7 @@ namespace FlaxEngine.GUI
return true;
// 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));
return true;