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();
}