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:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user