Merge remote-tracking branch 'origin/master' into sdl_platform

This commit is contained in:
2025-06-16 17:09:22 +03:00
15 changed files with 100 additions and 51 deletions

BIN
Content/Shaders/Editor/Grid.flax (Stored with Git LFS)

Binary file not shown.

View File

@@ -670,6 +670,8 @@ namespace FlaxEditor
{ {
FlaxEngine.Networking.NetworkManager.Stop(); // Shutdown any multiplayer from playmode FlaxEngine.Networking.NetworkManager.Stop(); // Shutdown any multiplayer from playmode
PlayModeEnding?.Invoke(); PlayModeEnding?.Invoke();
for (int i = 0; i < _modules.Count; i++)
_modules[i].OnPlayEnding();
} }
internal void OnPlayEnd() internal void OnPlayEnd()

View File

@@ -299,6 +299,7 @@ namespace FlaxEditor.GUI
{ {
// Select asset // Select asset
Editor.Instance.Windows.ContentWin.Select(Validator.SelectedItem); Editor.Instance.Windows.ContentWin.Select(Validator.SelectedItem);
Editor.Instance.Windows.ContentWin.ClearItemsSearch();
} }
} }
else if (Button1Rect.Contains(location)) else if (Button1Rect.Contains(location))
@@ -312,6 +313,7 @@ namespace FlaxEditor.GUI
{ {
// Select asset // Select asset
Editor.Instance.Windows.ContentWin.Select(Validator.SelectedItem); Editor.Instance.Windows.ContentWin.Select(Validator.SelectedItem);
Editor.Instance.Windows.ContentWin.ClearItemsSearch();
} }
else if (Button3Rect.Contains(location)) else if (Button3Rect.Contains(location))
{ {

View File

@@ -73,6 +73,11 @@ namespace FlaxEditor.GUI.Tree
/// </summary> /// </summary>
public bool DrawRootTreeLine = true; public bool DrawRootTreeLine = true;
/// <summary>
/// Occurs when the deferred layout operation was performed.
/// </summary>
public event Action AfterDeferredLayout;
/// <summary> /// <summary>
/// Gets or sets the margin for the child tree nodes. /// Gets or sets the margin for the child tree nodes.
/// </summary> /// </summary>
@@ -375,6 +380,7 @@ namespace FlaxEditor.GUI.Tree
if (_deferLayoutUpdate) if (_deferLayoutUpdate)
{ {
base.PerformLayout(); base.PerformLayout();
AfterDeferredLayout?.Invoke();
_deferLayoutUpdate = false; _deferLayoutUpdate = false;
} }

View File

@@ -76,6 +76,13 @@ namespace FlaxEditor.Modules
{ {
} }
/// <summary>
/// Called when Editor will leave the play mode.
/// </summary>
public virtual void OnPlayEnding()
{
}
/// <summary> /// <summary>
/// Called when Editor leaves the play mode. /// Called when Editor leaves the play mode.
/// </summary> /// </summary>

View File

@@ -1226,6 +1226,13 @@ namespace FlaxEditor.Modules
Windows[i].OnPlayBegin(); Windows[i].OnPlayBegin();
} }
/// <inheritdoc />
public override void OnPlayEnding()
{
for (int i = 0; i < Windows.Count; i++)
Windows[i].OnPlayEnding();
}
/// <inheritdoc /> /// <inheritdoc />
public override void OnPlayEnd() public override void OnPlayEnd()
{ {

View File

@@ -912,7 +912,7 @@ namespace FlaxEditor.Surface
/// <inheritdoc /> /// <inheritdoc />
public override bool OnTestTooltipOverControl(ref Float2 location) public override bool OnTestTooltipOverControl(ref Float2 location)
{ {
return _headerRect.Contains(ref location) && ShowTooltip; return _headerRect.Contains(ref location) && ShowTooltip && !Surface.IsConnecting && !Surface.IsBoxSelecting;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -1070,7 +1070,7 @@ namespace FlaxEditor.Surface
// Header // Header
var headerColor = style.BackgroundHighlighted; var headerColor = style.BackgroundHighlighted;
if (_headerRect.Contains(ref _mousePosition)) if (_headerRect.Contains(ref _mousePosition) && !Surface.IsConnecting && !Surface.IsBoxSelecting)
headerColor *= 1.07f; headerColor *= 1.07f;
Render2D.FillRectangle(_headerRect, headerColor); Render2D.FillRectangle(_headerRect, headerColor);
Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center); Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
@@ -1078,7 +1078,8 @@ namespace FlaxEditor.Surface
// Close button // Close button
if ((Archetype.Flags & NodeFlags.NoCloseButton) == 0 && Surface.CanEdit) if ((Archetype.Flags & NodeFlags.NoCloseButton) == 0 && Surface.CanEdit)
{ {
Render2D.DrawSprite(style.Cross, _closeButtonRect, _closeButtonRect.Contains(_mousePosition) ? style.Foreground : style.ForegroundGrey); bool highlightClose = _closeButtonRect.Contains(_mousePosition) && !Surface.IsConnecting && !Surface.IsBoxSelecting;
Render2D.DrawSprite(style.Cross, _closeButtonRect, highlightClose ? style.Foreground : style.ForegroundGrey);
} }
// Footer // Footer
@@ -1123,8 +1124,9 @@ namespace FlaxEditor.Surface
if (base.OnMouseUp(location, button)) if (base.OnMouseUp(location, button))
return true; return true;
// Close // Close/ delete
if (button == MouseButton.Left && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location)) bool canDelete = !Surface.IsConnecting && !Surface.WasBoxSelecting && !Surface.WasMovingSelection;
if (button == MouseButton.Left && canDelete && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location))
{ {
Surface.Delete(this); Surface.Delete(this);
return true; return true;

View File

@@ -225,7 +225,7 @@ namespace FlaxEditor.Surface
_rootControl.DrawComments(); _rootControl.DrawComments();
if (IsSelecting) if (IsBoxSelecting)
{ {
DrawSelection(); DrawSelection();
} }

View File

@@ -590,6 +590,9 @@ namespace FlaxEditor.Surface
// Cache flags and state // Cache flags and state
if (_leftMouseDown && button == MouseButton.Left) if (_leftMouseDown && button == MouseButton.Left)
{ {
WasBoxSelecting = IsBoxSelecting;
WasMovingSelection = _isMovingSelection;
_leftMouseDown = false; _leftMouseDown = false;
EndMouseCapture(); EndMouseCapture();
Cursor = CursorType.Default; Cursor = CursorType.Default;

View File

@@ -232,15 +232,25 @@ namespace FlaxEditor.Surface
} }
/// <summary> /// <summary>
/// Gets a value indicating whether user is selecting nodes. /// Gets a value indicating whether user is box selecting nodes.
/// </summary> /// </summary>
public bool IsSelecting => _leftMouseDown && !_isMovingSelection && _connectionInstigator == null; public bool IsBoxSelecting => _leftMouseDown && !_isMovingSelection && _connectionInstigator == null;
/// <summary>
/// Gets a value indicating whether user was previously box selecting nodes.
/// </summary>
public bool WasBoxSelecting { get; private set; }
/// <summary> /// <summary>
/// Gets a value indicating whether user is moving selected nodes. /// Gets a value indicating whether user is moving selected nodes.
/// </summary> /// </summary>
public bool IsMovingSelection => _leftMouseDown && _isMovingSelection && _connectionInstigator == null; public bool IsMovingSelection => _leftMouseDown && _isMovingSelection && _connectionInstigator == null;
/// <summary>
/// Gets a value indicating whether user was previously moving selected nodes.
/// </summary>
public bool WasMovingSelection { get; private set; }
/// <summary> /// <summary>
/// Gets a value indicating whether user is connecting nodes. /// Gets a value indicating whether user is connecting nodes.
/// </summary> /// </summary>

View File

@@ -97,10 +97,7 @@ namespace FlaxEditor.Windows.Assets
// For single node selected scroll view so user can see it // For single node selected scroll view so user can see it
if (nodes.Count == 1) if (nodes.Count == 1)
{ ScrollToSelectedNode();
nodes[0].ExpandAllParents(true);
ScrollViewTo(nodes[0]);
}
} }
// Update properties editor // Update properties editor

View File

@@ -219,6 +219,13 @@ namespace FlaxEditor.Windows
{ {
} }
/// <summary>
/// Called when Editor will leave the play mode.
/// </summary>
public virtual void OnPlayEnding()
{
}
/// <summary> /// <summary>
/// Called when Editor leaves the play mode. /// Called when Editor leaves the play mode.
/// </summary> /// </summary>

View File

@@ -33,6 +33,7 @@ namespace FlaxEditor.Windows
private DragScriptItems _dragScriptItems; private DragScriptItems _dragScriptItems;
private DragHandlers _dragHandlers; private DragHandlers _dragHandlers;
private bool _isDropping = false; private bool _isDropping = false;
private bool _forceScrollNodeToView = false;
/// <summary> /// <summary>
/// Scene tree panel. /// Scene tree panel.
@@ -90,6 +91,15 @@ namespace FlaxEditor.Windows
_tree.SelectedChanged += Tree_OnSelectedChanged; _tree.SelectedChanged += Tree_OnSelectedChanged;
_tree.RightClick += OnTreeRightClick; _tree.RightClick += OnTreeRightClick;
_tree.Parent = _sceneTreePanel; _tree.Parent = _sceneTreePanel;
_tree.AfterDeferredLayout += () =>
{
if (_forceScrollNodeToView)
{
_forceScrollNodeToView = false;
ScrollToSelectedNode();
}
};
headerPanel.Parent = this; headerPanel.Parent = this;
// Setup input actions // Setup input actions
@@ -141,6 +151,16 @@ namespace FlaxEditor.Windows
root.TreeNode.UpdateFilter(query); root.TreeNode.UpdateFilter(query);
_tree.UnlockChildrenRecursive(); _tree.UnlockChildrenRecursive();
// When keep the selected nodes in a view
var nodeSelection = _tree.Selection;
if (nodeSelection.Count != 0)
{
var node = nodeSelection[nodeSelection.Count - 1];
node.Expand(true);
_forceScrollNodeToView = true;
}
PerformLayout(); PerformLayout();
PerformLayout(); PerformLayout();
} }

View File

@@ -42,6 +42,7 @@ namespace FlaxEditor.Windows.Search
if (value == _selectedItem || (value != null && !_matchedItems.Contains(value))) if (value == _selectedItem || (value != null && !_matchedItems.Contains(value)))
return; return;
// Restore the previous selected item to the non-selected color
if (_selectedItem != null) if (_selectedItem != null)
{ {
_selectedItem.BackgroundColor = Color.Transparent; _selectedItem.BackgroundColor = Color.Transparent;
@@ -54,6 +55,7 @@ namespace FlaxEditor.Windows.Search
_selectedItem.BackgroundColor = Style.Current.BackgroundSelected; _selectedItem.BackgroundColor = Style.Current.BackgroundSelected;
if (_matchedItems.Count > VisibleItemCount) if (_matchedItems.Count > VisibleItemCount)
{ {
_selectedItem.Focus();
_resultPanel.ScrollViewTo(_selectedItem, true); _resultPanel.ScrollViewTo(_selectedItem, true);
} }
} }
@@ -180,39 +182,17 @@ namespace FlaxEditor.Windows.Search
switch (key) switch (key)
{ {
case KeyboardKeys.ArrowDown: case KeyboardKeys.ArrowDown:
{
if (_matchedItems.Count == 0)
return true;
int currentPos;
if (_selectedItem != null)
{
currentPos = _matchedItems.IndexOf(_selectedItem) + 1;
if (currentPos >= _matchedItems.Count)
currentPos--;
}
else
{
currentPos = 0;
}
SelectedItem = _matchedItems[currentPos];
return true;
}
case KeyboardKeys.ArrowUp: case KeyboardKeys.ArrowUp:
{ {
if (_matchedItems.Count == 0) if (_matchedItems.Count == 0)
return true; return true;
int currentPos;
if (_selectedItem != null) var focusedIndex = _matchedItems.IndexOf(_selectedItem);
{ int delta = key == KeyboardKeys.ArrowDown ? -1 : 1;
currentPos = _matchedItems.IndexOf(_selectedItem) - 1; int nextIndex = Mathf.Wrap(focusedIndex - delta, 0, _matchedItems.Count - 1);
if (currentPos < 0) var nextItem = _matchedItems[nextIndex];
currentPos = 0;
} SelectedItem = nextItem;
else
{
currentPos = 0;
}
SelectedItem = _matchedItems[currentPos];
return true; return true;
} }
case KeyboardKeys.Return: case KeyboardKeys.Return:
@@ -234,6 +214,17 @@ namespace FlaxEditor.Windows.Search
Hide(); Hide();
return true; return true;
} }
case KeyboardKeys.Backspace:
{
// Alow the user to quickly focus the searchbar
if (_searchBox != null && !_searchBox.IsFocused)
{
_searchBox.Focus();
_searchBox.SelectAll();
return true;
}
break;
}
} }
return base.OnKeyDown(key); return base.OnKeyDown(key);

View File

@@ -3,7 +3,7 @@
// Ben Golus // Ben Golus
// https://bgolus.medium.com/the-best-darn-grid-shader-yet-727f9278b9d8#3e73 // https://bgolus.medium.com/the-best-darn-grid-shader-yet-727f9278b9d8#3e73
#define USE_FORWARD true; #define MIN_DERIV 0.00001f
#include "./Flax/Common.hlsl" #include "./Flax/Common.hlsl"
@@ -61,11 +61,6 @@ float remap(float origFrom, float origTo, float targetFrom, float targetTo, floa
return lerp(targetFrom, targetTo, rel); return lerp(targetFrom, targetTo, rel);
} }
float ddLength(float a)
{
return length(float2(ddx(a), ddy(a)));
}
float GetLine(float pos, float scale, float thickness) float GetLine(float pos, float scale, float thickness)
{ {
float lineWidth = thickness; float lineWidth = thickness;
@@ -73,7 +68,7 @@ float GetLine(float pos, float scale, float thickness)
float2 uvDDXY = float2(ddx(coord), ddy(coord)); float2 uvDDXY = float2(ddx(coord), ddy(coord));
float deriv = float(length(uvDDXY.xy)); float deriv = max(float(length(uvDDXY.xy)), MIN_DERIV);
float drawWidth = clamp(lineWidth, deriv, 0.5); float drawWidth = clamp(lineWidth, deriv, 0.5);
float lineAA = deriv * 1.5; float lineAA = deriv * 1.5;
float gridUV = abs(coord); float gridUV = abs(coord);
@@ -92,7 +87,7 @@ float GetGrid(float3 pos, float scale, float thickness)
float4 uvDDXY = float4(ddx(coord), ddy(coord)); float4 uvDDXY = float4(ddx(coord), ddy(coord));
float2 deriv = float2(length(uvDDXY.xz), length(uvDDXY.yw)); float2 deriv = max(float2(length(uvDDXY.xz), length(uvDDXY.yw)), float2(MIN_DERIV, MIN_DERIV));
float2 drawWidth = clamp(lineWidth, deriv, 0.5); float2 drawWidth = clamp(lineWidth, deriv, 0.5);
float2 lineAA = deriv * 1.5; float2 lineAA = deriv * 1.5;
float2 gridUV = 1.0 - abs(frac(coord) * 2.0 - 1.0); float2 gridUV = 1.0 - abs(frac(coord) * 2.0 - 1.0);