Merge branch 'master' into PE-1.4

This commit is contained in:
Preben Eriksen
2022-10-25 09:19:01 +02:00
committed by GitHub
39 changed files with 468 additions and 112 deletions

View File

@@ -536,15 +536,6 @@ namespace FlaxEditor.Content.GUI
}
}
/// <summary>
/// Called when user wants to rename item.
/// </summary>
/// <param name="item">The item.</param>
public void OnItemDoubleClickName(ContentItem item)
{
OnRename?.Invoke(item);
}
/// <summary>
/// Called when user wants to open item.
/// </summary>
@@ -725,19 +716,24 @@ namespace FlaxEditor.Content.GUI
case ContentViewType.Tiles:
{
float defaultItemsWidth = ContentItem.DefaultWidth * viewScale;
int itemsToFit = Mathf.FloorToInt(width / defaultItemsWidth);
int itemsToFit = Mathf.FloorToInt(width / defaultItemsWidth) - 1;
if (itemsToFit < 1)
itemsToFit = 1;
float itemsWidth = width / Mathf.Max(itemsToFit, 1);
float itemsHeight = itemsWidth / defaultItemsWidth * (ContentItem.DefaultHeight * viewScale);
var flooredItemsWidth = Mathf.Floor(itemsWidth);
var flooredItemsHeight = Mathf.Floor(itemsHeight);
x = itemsToFit == 1 ? 0 : itemsWidth / itemsToFit;
for (int i = 0; i < _children.Count; i++)
{
var c = _children[i];
c.Bounds = new Rectangle(x, y, itemsWidth, itemsHeight);
c.Bounds = new Rectangle(Mathf.Floor(x), Mathf.Floor(y), flooredItemsWidth, flooredItemsHeight);
x += itemsWidth;
x += itemsWidth + itemsWidth / itemsToFit;
if (x + itemsWidth > width)
{
x = 0;
y += itemsHeight + 1;
x = itemsToFit == 1 ? 0 : itemsWidth / itemsToFit;
y += itemsHeight + 5;
}
}
if (x > 0)
@@ -752,7 +748,7 @@ namespace FlaxEditor.Content.GUI
{
var c = _children[i];
c.Bounds = new Rectangle(x, y, width, itemsHeight);
y += itemsHeight + 1;
y += itemsHeight + 5;
}
y += 40.0f;

View File

@@ -690,18 +690,9 @@ namespace FlaxEditor.Content
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
Focus();
// Check if clicked on name area (and can be renamed)
if (CanRename && TextRectangle.Contains(ref location))
{
// Rename
(Parent as ContentView).OnItemDoubleClickName(this);
}
else
{
// Open
(Parent as ContentView).OnItemDoubleClick(this);
}
// Open
(Parent as ContentView).OnItemDoubleClick(this);
return true;
}

View File

@@ -95,11 +95,19 @@ namespace FlaxEditor.Content
{
if (!_folder.CanRename)
return;
Editor.Instance.Windows.ContentWin.ScrollingOnTreeView(false);
// Start renaming the folder
var dialog = RenamePopup.Show(this, HeaderRect, _folder.ShortName, false);
dialog.Tag = _folder;
dialog.Renamed += popup => Editor.Instance.Windows.ContentWin.Rename((ContentFolder)popup.Tag, popup.Text);
dialog.Renamed += popup =>
{
Editor.Instance.Windows.ContentWin.Rename((ContentFolder)popup.Tag, popup.Text);
Editor.Instance.Windows.ContentWin.ScrollingOnTreeView(true);
};
dialog.Closed += popup =>
{
Editor.Instance.Windows.ContentWin.ScrollingOnTreeView(true);
};
}
/// <summary>

View File

@@ -24,7 +24,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
public override void Initialize(LayoutElementsContainer layout)
{
string[] layerNames = LayersAndTagsSettings.GetCurrentLayers();
int layersCount = Math.Max(4, layerNames.Length);
int layersCount = layerNames.Length;
_checkBoxes = new List<CheckBox>();
_layersCount = layersCount;

View File

@@ -31,6 +31,7 @@ namespace FlaxEditor.CustomEditors.GUI
private float _splitterValue;
private Rectangle _splitterRect;
private bool _splitterClicked, _mouseOverSplitter;
private bool _cursorChanged;
/// <summary>
/// Gets or sets the splitter value (always in range [0; 1]).
@@ -124,6 +125,18 @@ namespace FlaxEditor.CustomEditors.GUI
if (_splitterClicked)
{
SplitterValue = location.X / Width;
Cursor = CursorType.SizeWE;
_cursorChanged = true;
}
else if (_mouseOverSplitter)
{
Cursor = CursorType.SizeWE;
_cursorChanged = true;
}
else if (_cursorChanged)
{
Cursor = CursorType.Default;
_cursorChanged = false;
}
base.OnMouseMove(location);
@@ -162,6 +175,12 @@ namespace FlaxEditor.CustomEditors.GUI
{
// Clear flag
_mouseOverSplitter = false;
if (_cursorChanged)
{
Cursor = CursorType.Default;
_cursorChanged = false;
}
base.OnMouseLeave();
}

View File

@@ -155,11 +155,19 @@ namespace FlaxEditor.GUI.ContextMenu
if (parent is ContextMenu menu && menu._childCM != null)
locationSS.Y += 30.0f * dpiScale;
}
if (monitorBounds.Right < rightBottomLocationSS.X)
if (monitorBounds.Right < rightBottomLocationSS.X || _parentCM?.Direction == ContextMenuDirection.LeftDown || _parentCM?.Direction == ContextMenuDirection.LeftUp)
{
// Direction: left
isLeft = true;
locationSS.X -= dpiSize.X;
if (IsSubMenu && _parentCM != null)
{
locationSS.X -= _parentCM.Width + dpiSize.X;
}
else
{
locationSS.X -= dpiSize.X;
}
}
}

View File

@@ -26,6 +26,7 @@ namespace FlaxEditor.GUI.ContextMenu
: base(parent, text)
{
Text = text;
CloseMenuOnClick = false;
}
/// <inheritdoc />

View File

@@ -56,6 +56,8 @@ namespace FlaxEditor.GUI.Input
private Float2 _startSlideLocation;
private double _clickStartTime = -1;
private bool _cursorChanged;
private Float2 _mouseClickedPosition;
/// <summary>
/// Occurs when value gets changed.
@@ -172,6 +174,11 @@ namespace FlaxEditor.GUI.Input
{
_isSliding = false;
EndMouseCapture();
if (_cursorChanged)
{
Cursor = CursorType.Default;
_cursorChanged = false;
}
SlidingEnd?.Invoke();
}
@@ -223,6 +230,8 @@ namespace FlaxEditor.GUI.Input
UpdateText();
}
Cursor = CursorType.Default;
ResetViewOffset();
}
@@ -236,6 +245,12 @@ namespace FlaxEditor.GUI.Input
_startSlideLocation = location;
_startSlideValue = _value;
StartMouseCapture(true);
// Hide cursor and cache location
Cursor = CursorType.Hidden;
_mouseClickedPosition = location;
_cursorChanged = true;
SlidingStart?.Invoke();
return true;
}
@@ -249,7 +264,7 @@ namespace FlaxEditor.GUI.Input
/// <inheritdoc />
public override void OnMouseMove(Float2 location)
{
if (_isSliding)
if (_isSliding && !RootWindow.Window.IsMouseFlippingHorizontally)
{
// Update sliding
var slideLocation = location + Root.TrackingMouseOffset;
@@ -257,6 +272,18 @@ namespace FlaxEditor.GUI.Input
return;
}
// Update cursor type so user knows they can slide value
if (CanUseSliding && SlideRect.Contains(location) && !_isSliding)
{
Cursor = CursorType.SizeWE;
_cursorChanged = true;
}
else if (_cursorChanged && !_isSliding)
{
Cursor = CursorType.Default;
_cursorChanged = false;
}
base.OnMouseMove(location);
}
@@ -265,7 +292,8 @@ namespace FlaxEditor.GUI.Input
{
if (button == MouseButton.Left && _isSliding)
{
// End sliding
// End sliding and return mouse to original location
Root.MousePosition = ScreenPos + _mouseClickedPosition;
EndSliding();
return true;
}
@@ -281,6 +309,18 @@ namespace FlaxEditor.GUI.Input
return base.OnMouseUp(location, button);
}
/// <inheritdoc />
public override void OnMouseLeave()
{
if (_cursorChanged)
{
Cursor = CursorType.Default;
_cursorChanged = false;
}
base.OnMouseLeave();
}
/// <inheritdoc />
protected override void OnEditBegin()
{

View File

@@ -69,10 +69,10 @@ namespace FlaxEditor.GUI.Timeline.GUI
/// <inheritdoc />
public override void OnMouseMove(Float2 location)
{
if (_isMoving)
if (_isMoving && !_timeline.RootWindow.Window.IsMouseFlippingHorizontally)
{
var moveLocation = Root.MousePosition;
var moveLocationDelta = moveLocation - _startMoveLocation;
var moveLocationDelta = moveLocation - _startMoveLocation + _timeline.Root.TrackingMouseOffset.X;
var moveDelta = (int)(moveLocationDelta.X / (Timeline.UnitsPerSecond * _timeline.Zoom) * _timeline.FramesPerSecond);
var durationFrames = _timeline.DurationFrames;
@@ -83,6 +83,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
else
{
_timeline.DurationFrames = _startMoveDuration + moveDelta;
_timeline.MediaBackground.HScrollBar.Value = _timeline.MediaBackground.HScrollBar.Maximum;
}
if (_timeline.DurationFrames != durationFrames)
@@ -140,6 +141,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
_timeline.DurationFrames = duration;
}
_isMoving = false;
_timeline.MediaBackground.HScrollBar.Value = _timeline.MediaBackground.HScrollBar.Maximum;
EndMouseCapture();
}

View File

@@ -450,7 +450,13 @@ namespace FlaxEditor.Modules
SelectionDeleteEnd?.Invoke();
if (isSceneTreeFocus)
{
Editor.Windows.SceneWin.Focus();
}
// fix scene window layout
Editor.Windows.SceneWin.PerformLayout();
Editor.Windows.SceneWin.PerformLayout();
}
/// <summary>
@@ -514,6 +520,9 @@ namespace FlaxEditor.Modules
Undo.AddAction(new MultiUndoAction(pasteAction, selectAction));
OnSelectionChanged();
}
// Scroll to new selected node while pasting
Editor.Windows.SceneWin.ScrollToSelectedNode();
}
/// <summary>
@@ -611,6 +620,9 @@ namespace FlaxEditor.Modules
Undo.AddAction(new MultiUndoAction(undoActions));
OnSelectionChanged();
}
// Scroll to new selected node while duplicating
Editor.Windows.SceneWin.ScrollToSelectedNode();
}
/// <summary>

View File

@@ -137,9 +137,9 @@ namespace FlaxEditor.Options
/// <summary>
/// Gets or sets an order of script properties/fields in properties panel.
/// </summary>
[DefaultValue(MembersOrder.Alphabetical)]
[DefaultValue(MembersOrder.Declaration)]
[EditorDisplay("Scripting", "Script Members Order"), EditorOrder(503), Tooltip("Order of script properties/fields in properties panel")]
public MembersOrder ScriptMembersOrder { get; set; } = MembersOrder.Alphabetical;
public MembersOrder ScriptMembersOrder { get; set; } = MembersOrder.Declaration;
/// <summary>
/// Gets or sets a value indicating whether automatically save the Visual Script asset editors when starting the play mode in editor.

View File

@@ -273,15 +273,26 @@ namespace FlaxEditor.SceneGraph.GUI
Select();
// Disable scrolling of scene view
Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(false);
// Start renaming the actor
var dialog = RenamePopup.Show(this, HeaderRect, _actorNode.Name, false);
dialog.Renamed += OnRenamed;
dialog.Closed += popup =>
{
// Enable scrolling of scene view
Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true);
};
}
private void OnRenamed(RenamePopup renamePopup)
{
using (new UndoBlock(ActorNode.Root.Undo, Actor, "Rename"))
Actor.Name = renamePopup.Text;
// Enable scrolling of scene view
Editor.Instance.Windows.SceneWin.ScrollingOnSceneTreeView(true);
}
/// <inheritdoc />

View File

@@ -47,7 +47,7 @@ namespace FlaxEditor.Surface.Archetypes
Description = desc,
Flags = NodeFlags.AllGraphs,
AlternativeTitles = altTitles,
Size = new Float2(110, 40),
Size = new Float2(140, 40),
DefaultType = new ScriptType(inputType),
ConnectionsHints = hints,
IndependentBoxes = new[] { 0, 1 },

View File

@@ -223,6 +223,22 @@ namespace FlaxEditor.Viewport
editor.SceneEditing.SelectionChanged += OnSelectionChanged;
// Initialize snapping enabled from cached values
if (_editor.ProjectCache.TryGetCustomData("TranslateSnapState", out var cachedState))
TransformGizmo.TranslationSnapEnable = bool.Parse(cachedState);
if (_editor.ProjectCache.TryGetCustomData("RotationSnapState", out cachedState))
TransformGizmo.RotationSnapEnabled = bool.Parse(cachedState);
if (_editor.ProjectCache.TryGetCustomData("ScaleSnapState", out cachedState))
TransformGizmo.ScaleSnapEnabled = bool.Parse(cachedState);
if (_editor.ProjectCache.TryGetCustomData("TranslateSnapValue", out cachedState))
TransformGizmo.TranslationSnapValue = float.Parse(cachedState);
if (_editor.ProjectCache.TryGetCustomData("RotationSnapValue", out cachedState))
TransformGizmo.RotationSnapValue = float.Parse(cachedState);
if (_editor.ProjectCache.TryGetCustomData("ScaleSnapValue", out cachedState))
TransformGizmo.ScaleSnapValue = float.Parse(cachedState);
if (_editor.ProjectCache.TryGetCustomData("TransformSpaceState", out cachedState) && Enum.TryParse(cachedState, out TransformGizmoBase.TransformSpace space))
TransformGizmo.ActiveTransformSpace = space;
// Transform space widget
var transformSpaceWidget = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight);
var transformSpaceToggle = new ViewportWidgetButton(string.Empty, editor.Icons.Globe32, null, true)
@@ -528,21 +544,29 @@ namespace FlaxEditor.Viewport
private void OnTranslateSnappingToggle(ViewportWidgetButton button)
{
TransformGizmo.TranslationSnapEnable = !TransformGizmo.TranslationSnapEnable;
// cache value
_editor.ProjectCache.SetCustomData("TranslateSnapState", TransformGizmo.TranslationSnapEnable.ToString());
}
private void OnRotateSnappingToggle(ViewportWidgetButton button)
{
TransformGizmo.RotationSnapEnabled = !TransformGizmo.RotationSnapEnabled;
// cache value
_editor.ProjectCache.SetCustomData("RotationSnapState", TransformGizmo.RotationSnapEnabled.ToString());
}
private void OnScaleSnappingToggle(ViewportWidgetButton button)
{
TransformGizmo.ScaleSnapEnabled = !TransformGizmo.ScaleSnapEnabled;
// cache value
_editor.ProjectCache.SetCustomData("ScaleSnapState", TransformGizmo.ScaleSnapEnabled.ToString());
}
private void OnTransformSpaceToggle(ViewportWidgetButton button)
{
TransformGizmo.ToggleTransformSpace();
// cache value
_editor.ProjectCache.SetCustomData("TransformSpaceState", TransformGizmo.ActiveTransformSpace.ToString());
}
private void OnGizmoModeChanged()
@@ -572,6 +596,8 @@ namespace FlaxEditor.Viewport
var v = (float)button.Tag;
TransformGizmo.ScaleSnapValue = v;
_scaleSnapping.Text = v.ToString();
// cache value
_editor.ProjectCache.SetCustomData("ScaleSnapValue", TransformGizmo.ScaleSnapValue.ToString("N"));
}
private void OnWidgetScaleSnapShowHide(Control control)
@@ -609,6 +635,8 @@ namespace FlaxEditor.Viewport
var v = (float)button.Tag;
TransformGizmo.RotationSnapValue = v;
_rotateSnapping.Text = v.ToString();
// cache value
_editor.ProjectCache.SetCustomData("RotationSnapValue", TransformGizmo.RotationSnapValue.ToString("N"));
}
private void OnWidgetRotateSnapShowHide(Control control)
@@ -648,6 +676,8 @@ namespace FlaxEditor.Viewport
_translateSnapping.Text = "Bounding Box";
else
_translateSnapping.Text = v.ToString();
// cache value
_editor.ProjectCache.SetCustomData("TranslateSnapValue", TransformGizmo.TranslationSnapValue.ToString("N"));
}
private void OnWidgetTranslateSnapShowHide(Control control)

View File

@@ -7,6 +7,7 @@ using FlaxEditor.CustomEditors;
using FlaxEditor.CustomEditors.Editors;
using FlaxEditor.CustomEditors.Elements;
using FlaxEditor.GUI;
using FlaxEditor.GUI.Tree;
using FlaxEditor.Viewport.Cameras;
using FlaxEditor.Viewport.Previews;
using FlaxEngine;
@@ -166,8 +167,21 @@ namespace FlaxEditor.Windows.Assets
var proxy = (PropertiesProxy)Values[0];
int nodeIndex = (int)checkBox.Tag;
proxy.NodesMask[nodeIndex] = checkBox.Checked;
if (Input.GetKey(KeyboardKeys.Shift))
SetTreeChecked(checkBox.Parent as TreeNode, checkBox.Checked);
proxy.Window.MarkAsEdited();
}
private void SetTreeChecked(TreeNode tree, bool state)
{
foreach (var node in tree.Children)
{
if (node is TreeNode treeNode)
SetTreeChecked(treeNode, state);
else if (node is CheckBox checkBox)
checkBox.Checked = state;
}
}
}
}

View File

@@ -27,6 +27,8 @@ namespace FlaxEditor.Windows
private const string ProjectDataLastViewedFolder = "LastViewedFolder";
private bool _isWorkspaceDirty;
private SplitPanel _split;
private Panel _contentViewPanel;
private Panel _contentTreePanel;
private ContentView _view;
private readonly ToolStrip _toolStrip;
@@ -95,7 +97,7 @@ namespace FlaxEditor.Windows
};
// Split panel
_split = new SplitPanel(options.Options.Interface.ContentWindowOrientation, ScrollBars.Both, ScrollBars.Vertical)
_split = new SplitPanel(options.Options.Interface.ContentWindowOrientation, ScrollBars.None, ScrollBars.None)
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, _toolStrip.Bottom, 0),
@@ -120,11 +122,20 @@ namespace FlaxEditor.Windows
};
_foldersSearchBox.TextChanged += OnFoldersSearchBoxTextChanged;
// Content tree panel
_contentTreePanel = new Panel
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, headerPanel.Bottom, 0),
IsScrollable = true,
ScrollBars = ScrollBars.Both,
Parent = _split.Panel1,
};
// Content structure tree
_tree = new Tree(false)
{
Y = headerPanel.Bottom,
Parent = _split.Panel1,
Parent = _contentTreePanel,
};
_tree.SelectedChanged += OnTreeSelectionChanged;
headerPanel.Parent = _split.Panel1;
@@ -159,13 +170,23 @@ namespace FlaxEditor.Windows
_viewDropdown.Items.Add(((ContentItemSearchFilter)i).ToString());
_viewDropdown.PopupCreate += OnViewDropdownPopupCreate;
// Content view panel
_contentViewPanel = new Panel
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, contentItemsSearchPanel.Bottom + 4, 0),
IsScrollable = true,
ScrollBars = ScrollBars.Vertical,
Parent = _split.Panel2,
};
// Content View
_view = new ContentView
{
AnchorPreset = AnchorPresets.HorizontalStretchTop,
Offsets = new Margin(0, 0, contentItemsSearchPanel.Bottom + 4, 0),
Offsets = new Margin(0, 0, 0, 0),
IsScrollable = true,
Parent = _split.Panel2,
Parent = _contentViewPanel,
};
_view.OnOpen += Open;
_view.OnNavigateBack += NavigateBackward;
@@ -271,6 +292,30 @@ namespace FlaxEditor.Windows
RefreshView(SelectedNode);
}
/// <summary>
/// Enables or disables vertical and horizontal scrolling on the content tree panel
/// </summary>
/// <param name="enabled">The state to set scrolling to</param>
public void ScrollingOnTreeView(bool enabled)
{
if (_contentTreePanel.VScrollBar != null)
_contentTreePanel.VScrollBar.ThumbEnabled = enabled;
if (_contentTreePanel.HScrollBar != null)
_contentTreePanel.HScrollBar.ThumbEnabled = enabled;
}
/// <summary>
/// Enables or disables vertical and horizontal scrolling on the content view panel
/// </summary>
/// <param name="enabled">The state to set scrolling to</param>
public void ScrollingOnContentView(bool enabled)
{
if (_contentViewPanel.VScrollBar != null)
_contentViewPanel.VScrollBar.ThumbEnabled = enabled;
if (_contentViewPanel.HScrollBar != null)
_contentViewPanel.HScrollBar.ThumbEnabled = enabled;
}
/// <summary>
/// Shows popup dialog with UI to rename content item.
/// </summary>
@@ -285,6 +330,7 @@ namespace FlaxEditor.Windows
_split.Panel2.VScrollBar.ThumbEnabled = false;
if (_split.Panel2.HScrollBar != null)
_split.Panel2.HScrollBar.ThumbEnabled = false;
ScrollingOnContentView(false);
// Show rename popup
var popup = RenamePopup.Show(item, item.TextRectangle, item.ShortName, true);
@@ -298,6 +344,7 @@ namespace FlaxEditor.Windows
_split.Panel2.VScrollBar.ThumbEnabled = true;
if (_split.Panel2.HScrollBar != null)
_split.Panel2.HScrollBar.ThumbEnabled = true;
ScrollingOnContentView(true);
// Check if was creating new element
if (_newElement != null)

View File

@@ -150,9 +150,23 @@ namespace FlaxEditor.Windows
};
Viewport.Task.ViewFlags = ViewFlags.DefaultEditor;
Editor.SceneEditing.SelectionChanged += OnSelectionChanged;
Editor.Scene.ActorRemoved += SceneOnActorRemoved;
}
/// <inheritdoc />
public override void OnEditorStateChanged()
{
base.OnEditorStateChanged();
UpdateCameraPreview();
}
private void OnSelectionChanged()
{
UpdateCameraPreview();
}
/// <summary>
/// Gets a value indicating whether actor pilot feature is active and in use.
/// </summary>
@@ -376,9 +390,6 @@ namespace FlaxEditor.Windows
/// <inheritdoc />
public override void Update(float deltaTime)
{
// TODO: call camera preview update only on selection change, or state change
UpdateCameraPreview();
if (Root.GetKeyDown(KeyboardKeys.F12))
{
Viewport.TakeScreenshot();

View File

@@ -131,6 +131,7 @@ namespace FlaxEditor.Windows
private TextBox _searchBox;
private Tree _tree;
private Panel _sceneTreePanel;
private bool _isUpdatingSelection;
private bool _isMouseDown;
@@ -143,10 +144,9 @@ namespace FlaxEditor.Windows
/// </summary>
/// <param name="editor">The editor.</param>
public SceneTreeWindow(Editor editor)
: base(editor, true, ScrollBars.Both)
: base(editor, true, ScrollBars.None)
{
Title = "Scene";
ScrollMargin = new Margin(0, 0, 0, 100.0f);
// Scene searching query input box
var headerPanel = new ContainerControl
@@ -165,19 +165,29 @@ namespace FlaxEditor.Windows
};
_searchBox.TextChanged += OnSearchBoxTextChanged;
// Scene tree panel
_sceneTreePanel = new Panel
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, headerPanel.Bottom, 0),
IsScrollable = true,
ScrollBars = ScrollBars.Both,
Parent = this,
};
// Create scene structure tree
var root = editor.Scene.Root;
root.TreeNode.ChildrenIndent = 0;
root.TreeNode.Expand();
_tree = new Tree(true)
{
Y = headerPanel.Bottom,
Margin = new Margin(0.0f, 0.0f, -16.0f, 0.0f), // Hide root node
IsScrollable = true,
};
_tree.AddChild(root.TreeNode);
_tree.SelectedChanged += Tree_OnSelectedChanged;
_tree.RightClick += OnTreeRightClick;
_tree.Parent = this;
_tree.Parent = _sceneTreePanel;
headerPanel.Parent = this;
// Setup input actions
@@ -188,6 +198,32 @@ namespace FlaxEditor.Windows
InputActions.Add(options => options.Rename, Rename);
}
/// <summary>
/// Enables or disables vertical and horizontal scrolling on the scene tree panel.
/// </summary>
/// <param name="enabled">The state to set scrolling to</param>
public void ScrollingOnSceneTreeView(bool enabled)
{
if (_sceneTreePanel.VScrollBar != null)
_sceneTreePanel.VScrollBar.ThumbEnabled = enabled;
if (_sceneTreePanel.HScrollBar != null)
_sceneTreePanel.HScrollBar.ThumbEnabled = enabled;
}
/// <summary>
/// Scrolls to the selected node in the scene tree.
/// </summary>
public void ScrollToSelectedNode()
{
// Scroll to node
var nodeSelection = _tree.Selection;
if (nodeSelection.Count != 0)
{
var scrollControl = nodeSelection[nodeSelection.Count - 1];
_sceneTreePanel.ScrollViewTo(scrollControl);
}
}
private void OnSearchBoxTextChanged()
{
// Skip events during setup or init stuff