Simplified enabling and disabling scrolling and implimented the stop scrolling functionality when renaming in the content tree panel as well

This commit is contained in:
Chandler Cox
2022-10-06 00:03:38 -05:00
parent 656fcf9847
commit 020351e56b
2 changed files with 36 additions and 18 deletions

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

@@ -292,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>
@@ -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)