From 656fcf984721bed3d95b4f8249a416f2e85c04ce Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 30 Sep 2022 09:22:36 -0500 Subject: [PATCH 1/2] Changed the content window do the search bars do not scroll with the content. --- Source/Editor/Windows/ContentWindow.cs | 47 +++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs index 0f9eba0c0..56681296e 100644 --- a/Source/Editor/Windows/ContentWindow.cs +++ b/Source/Editor/Windows/ContentWindow.cs @@ -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; @@ -285,6 +306,14 @@ namespace FlaxEditor.Windows _split.Panel2.VScrollBar.ThumbEnabled = false; if (_split.Panel2.HScrollBar != null) _split.Panel2.HScrollBar.ThumbEnabled = false; + if (_contentViewPanel.VScrollBar != null) + _contentViewPanel.VScrollBar.ThumbEnabled = false; + if (_contentViewPanel.HScrollBar != null) + _contentViewPanel.HScrollBar.ThumbEnabled = false; + if (_contentTreePanel.VScrollBar != null) + _contentTreePanel.VScrollBar.ThumbEnabled = false; + if (_contentTreePanel.HScrollBar != null) + _contentTreePanel.HScrollBar.ThumbEnabled = false; // Show rename popup var popup = RenamePopup.Show(item, item.TextRectangle, item.ShortName, true); @@ -298,6 +327,14 @@ namespace FlaxEditor.Windows _split.Panel2.VScrollBar.ThumbEnabled = true; if (_split.Panel2.HScrollBar != null) _split.Panel2.HScrollBar.ThumbEnabled = true; + if (_contentViewPanel.VScrollBar != null) + _contentViewPanel.VScrollBar.ThumbEnabled = true; + if (_contentViewPanel.HScrollBar != null) + _contentViewPanel.HScrollBar.ThumbEnabled = true; + if (_contentTreePanel.VScrollBar != null) + _contentTreePanel.VScrollBar.ThumbEnabled = true; + if (_contentTreePanel.HScrollBar != null) + _contentTreePanel.HScrollBar.ThumbEnabled = true; // Check if was creating new element if (_newElement != null) From 020351e56b229a88767ec8f56e5b3ce7d8bd8601 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 6 Oct 2022 00:03:38 -0500 Subject: [PATCH 2/2] Simplified enabling and disabling scrolling and implimented the stop scrolling functionality when renaming in the content tree panel as well --- Source/Editor/Content/Tree/ContentTreeNode.cs | 12 +++++- Source/Editor/Windows/ContentWindow.cs | 42 ++++++++++++------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Source/Editor/Content/Tree/ContentTreeNode.cs b/Source/Editor/Content/Tree/ContentTreeNode.cs index 2503cde51..1d70a8252 100644 --- a/Source/Editor/Content/Tree/ContentTreeNode.cs +++ b/Source/Editor/Content/Tree/ContentTreeNode.cs @@ -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); + }; } /// diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs index 56681296e..90cd77d11 100644 --- a/Source/Editor/Windows/ContentWindow.cs +++ b/Source/Editor/Windows/ContentWindow.cs @@ -292,6 +292,30 @@ namespace FlaxEditor.Windows RefreshView(SelectedNode); } + /// + /// Enables or disables vertical and horizontal scrolling on the content tree panel + /// + /// The state to set scrolling to + public void ScrollingOnTreeView(bool enabled) + { + if (_contentTreePanel.VScrollBar != null) + _contentTreePanel.VScrollBar.ThumbEnabled = enabled; + if (_contentTreePanel.HScrollBar != null) + _contentTreePanel.HScrollBar.ThumbEnabled = enabled; + } + + /// + /// Enables or disables vertical and horizontal scrolling on the content view panel + /// + /// The state to set scrolling to + public void ScrollingOnContentView(bool enabled) + { + if (_contentViewPanel.VScrollBar != null) + _contentViewPanel.VScrollBar.ThumbEnabled = enabled; + if (_contentViewPanel.HScrollBar != null) + _contentViewPanel.HScrollBar.ThumbEnabled = enabled; + } + /// /// Shows popup dialog with UI to rename content item. /// @@ -306,14 +330,7 @@ namespace FlaxEditor.Windows _split.Panel2.VScrollBar.ThumbEnabled = false; if (_split.Panel2.HScrollBar != null) _split.Panel2.HScrollBar.ThumbEnabled = false; - if (_contentViewPanel.VScrollBar != null) - _contentViewPanel.VScrollBar.ThumbEnabled = false; - if (_contentViewPanel.HScrollBar != null) - _contentViewPanel.HScrollBar.ThumbEnabled = false; - if (_contentTreePanel.VScrollBar != null) - _contentTreePanel.VScrollBar.ThumbEnabled = false; - if (_contentTreePanel.HScrollBar != null) - _contentTreePanel.HScrollBar.ThumbEnabled = false; + ScrollingOnContentView(false); // Show rename popup var popup = RenamePopup.Show(item, item.TextRectangle, item.ShortName, true); @@ -327,14 +344,7 @@ namespace FlaxEditor.Windows _split.Panel2.VScrollBar.ThumbEnabled = true; if (_split.Panel2.HScrollBar != null) _split.Panel2.HScrollBar.ThumbEnabled = true; - if (_contentViewPanel.VScrollBar != null) - _contentViewPanel.VScrollBar.ThumbEnabled = true; - if (_contentViewPanel.HScrollBar != null) - _contentViewPanel.HScrollBar.ThumbEnabled = true; - if (_contentTreePanel.VScrollBar != null) - _contentTreePanel.VScrollBar.ThumbEnabled = true; - if (_contentTreePanel.HScrollBar != null) - _contentTreePanel.HScrollBar.ThumbEnabled = true; + ScrollingOnContentView(true); // Check if was creating new element if (_newElement != null)