Merge branch 'Tryibion-scroll-fix'

This commit is contained in:
Wojtek Figat
2022-10-23 14:19:30 +02:00
3 changed files with 29 additions and 3 deletions

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

@@ -210,6 +210,20 @@ namespace FlaxEditor.Windows
_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

View File

@@ -3,6 +3,7 @@
#include "GPUDevice.h"
#include "RenderTargetPool.h"
#include "GPUPipelineState.h"
#include "GPUSwapChain.h"
#include "RenderTask.h"
#include "RenderTools.h"
#include "Graphics.h"
@@ -12,7 +13,6 @@
#include "Engine/Content/Assets/Material.h"
#include "Engine/Content/Content.h"
#include "Engine/Content/SoftAssetReference.h"
#include "Engine/Platform/Windows/WindowsWindow.h"
#include "Engine/Render2D/Render2D.h"
#include "Engine/Engine/CommandLine.h"
#include "Engine/Engine/Engine.h"
@@ -408,7 +408,7 @@ void GPUDevice::DrawEnd()
for (int32 i = RenderTask::Tasks.Count() - 1; i >= 0; i--)
{
const auto task = RenderTask::Tasks[i];
if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain)
if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain && task->SwapChain->IsReady())
{
lastWindowIndex = i;
break;
@@ -421,7 +421,7 @@ void GPUDevice::DrawEnd()
for (int32 i = 0; i < RenderTask::Tasks.Count(); i++)
{
const auto task = RenderTask::Tasks[i];
if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain)
if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain && task->SwapChain->IsReady())
{
bool vsync = useVSync;
if (lastWindowIndex != i)