Merge branch 'master' into 1.11
This commit is contained in:
@@ -285,6 +285,17 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
}
|
||||
}
|
||||
|
||||
private static void ForceDefocus(ContainerControl c)
|
||||
{
|
||||
foreach (var cc in c.Children)
|
||||
{
|
||||
if (cc.ContainsFocus)
|
||||
cc.Defocus();
|
||||
if (cc is ContainerControl ccc)
|
||||
ForceDefocus(ccc);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hide popup menu and all child menus.
|
||||
/// </summary>
|
||||
@@ -299,6 +310,9 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
// Close child
|
||||
HideChild();
|
||||
|
||||
// Force defocus
|
||||
ForceDefocus(this);
|
||||
|
||||
// Unlink from window
|
||||
Parent = null;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace FlaxEditor.GUI.Input
|
||||
get => _min;
|
||||
set
|
||||
{
|
||||
if (!Mathd.NearEqual(_min, value))
|
||||
if (_min != value)
|
||||
{
|
||||
if (value > _max)
|
||||
throw new ArgumentException();
|
||||
@@ -58,7 +58,7 @@ namespace FlaxEditor.GUI.Input
|
||||
get => _max;
|
||||
set
|
||||
{
|
||||
if (!Mathd.NearEqual(_max, value))
|
||||
if (_max != value)
|
||||
{
|
||||
if (value < _min)
|
||||
throw new ArgumentException();
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace FlaxEditor.GUI.Input
|
||||
get => _min;
|
||||
set
|
||||
{
|
||||
if (!Mathf.NearEqual(_min, value))
|
||||
if (_min != value)
|
||||
{
|
||||
if (value > _max)
|
||||
throw new ArgumentException();
|
||||
@@ -54,7 +54,7 @@ namespace FlaxEditor.GUI.Input
|
||||
get => _max;
|
||||
set
|
||||
{
|
||||
if (!Mathf.NearEqual(_max, value))
|
||||
if (_max != value)
|
||||
{
|
||||
if (value < _min)
|
||||
throw new ArgumentException();
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace FlaxEditor.GUI.Input
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, Minimum, Maximum);
|
||||
if (!Mathf.NearEqual(value, _value))
|
||||
if (value != _value)
|
||||
{
|
||||
_value = value;
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace FlaxEditor.GUI.Input
|
||||
get => _min;
|
||||
set
|
||||
{
|
||||
if (!Mathf.NearEqual(_min, value))
|
||||
if (_min != value)
|
||||
{
|
||||
if (value > _max)
|
||||
throw new ArgumentException();
|
||||
@@ -330,7 +330,7 @@ namespace FlaxEditor.GUI.Input
|
||||
get => _max;
|
||||
set
|
||||
{
|
||||
if (!Mathf.NearEqual(_max, value))
|
||||
if (_max != value)
|
||||
{
|
||||
if (value < _min)
|
||||
throw new ArgumentException();
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace FlaxEditor.GUI.Tabs
|
||||
if (EnabledInHierarchy && Tab.Enabled)
|
||||
{
|
||||
Tabs.SelectedTab = Tab;
|
||||
Tab.PerformLayout(true);
|
||||
Tabs.Focus();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace FlaxEditor.GUI.Tree
|
||||
private readonly bool _supportMultiSelect;
|
||||
private Margin _margin;
|
||||
private bool _autoSize = true;
|
||||
private bool _deferLayoutUpdate = false;
|
||||
|
||||
/// <summary>
|
||||
/// The TreeNode that is being dragged over. This could have a value when not dragging.
|
||||
@@ -66,6 +67,11 @@ namespace FlaxEditor.GUI.Tree
|
||||
/// Gets the first selected node or null.
|
||||
/// </summary>
|
||||
public TreeNode SelectedNode => Selection.Count > 0 ? Selection[0] : null;
|
||||
|
||||
/// <summary>
|
||||
/// Allow nodes to Draw the root tree line.
|
||||
/// </summary>
|
||||
public bool DrawRootTreeLine = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the margin for the child tree nodes.
|
||||
@@ -353,9 +359,25 @@ namespace FlaxEditor.GUI.Tree
|
||||
BulkSelectUpdateExpanded(false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PerformLayout(bool force = false)
|
||||
{
|
||||
if (_isLayoutLocked && !force)
|
||||
return;
|
||||
|
||||
// In case the tree was fully expanded or collapsed along its children, avoid calculating the layout multiple times for each child
|
||||
_deferLayoutUpdate = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
if (_deferLayoutUpdate)
|
||||
{
|
||||
base.PerformLayout();
|
||||
_deferLayoutUpdate = false;
|
||||
}
|
||||
|
||||
var node = SelectedNode;
|
||||
|
||||
// Check if has focus and if any node is focused and it isn't a root
|
||||
|
||||
@@ -760,20 +760,21 @@ namespace FlaxEditor.GUI.Tree
|
||||
// Show tree guidelines
|
||||
if (Editor.Instance.Options.Options.Interface.ShowTreeLines)
|
||||
{
|
||||
TreeNode parentNode = Parent as TreeNode;
|
||||
ContainerControl parent = Parent;
|
||||
TreeNode parentNode = parent as TreeNode;
|
||||
bool thisNodeIsLast = false;
|
||||
while (parentNode != null && parentNode != ParentTree.Children[0])
|
||||
while (parentNode != null && (parentNode != tree.Children[0] || tree.DrawRootTreeLine))
|
||||
{
|
||||
float bottomOffset = 0;
|
||||
float topOffset = 0;
|
||||
|
||||
if (Parent == parentNode && this == Parent.Children[0])
|
||||
if (parent == parentNode && this == parent.Children[0])
|
||||
topOffset = 2;
|
||||
|
||||
if (thisNodeIsLast && parentNode.Children.Count == 1)
|
||||
bottomOffset = topOffset != 0 ? 4 : 2;
|
||||
|
||||
if (Parent == parentNode && this == Parent.Children[Parent.Children.Count - 1] && !_opened)
|
||||
if (parent == parentNode && this == parent.Children[^1] && !_opened)
|
||||
{
|
||||
thisNodeIsLast = true;
|
||||
bottomOffset = topOffset != 0 ? 4 : 2;
|
||||
@@ -784,6 +785,8 @@ namespace FlaxEditor.GUI.Tree
|
||||
if (_iconCollaped.IsValid)
|
||||
leftOffset += 18;
|
||||
var lineRect1 = new Rectangle(parentNode.TextRect.Left - leftOffset, parentNode.HeaderRect.Top + topOffset, 1, parentNode.HeaderRect.Height - bottomOffset);
|
||||
if (HasAnyVisibleChild && CustomArrowRect.HasValue && CustomArrowRect.Value.Intersects(lineRect1))
|
||||
lineRect1 = Rectangle.Empty; // Skip drawing line if it's overlapping the arrow rectangle
|
||||
Render2D.FillRectangle(lineRect1, isSelected ? style.ForegroundGrey : style.LightBackground);
|
||||
parentNode = parentNode.Parent as TreeNode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user