editor: switch workspace window sync to projection payload
This commit is contained in:
@@ -30,13 +30,30 @@ EditorWindowContentCursorKind ToContentCursorKind(
|
||||
}
|
||||
}
|
||||
|
||||
EditorWorkspaceWindowProjection BuildWorkspaceProjectionFromController(
|
||||
const UIEditorWorkspaceController& workspaceController,
|
||||
std::string_view windowId) {
|
||||
EditorWorkspaceWindowProjection projection = {};
|
||||
projection.windowState.windowId = std::string(windowId);
|
||||
projection.windowState.workspace = workspaceController.GetWorkspace();
|
||||
projection.windowState.session = workspaceController.GetSession();
|
||||
projection.minimumOuterSize = ResolveUIEditorDetachedWorkspaceMinimumOuterSize(
|
||||
workspaceController);
|
||||
projection.useDetachedTitleBarTabStrip = HasUIEditorSingleVisibleRootTab(workspaceController);
|
||||
projection.tabStripTitleText = ResolveUIEditorDetachedWorkspaceTitle(workspaceController);
|
||||
projection.detachedWindowTitleText = ResolveUIEditorDetachedWorkspaceTitle(workspaceController);
|
||||
return projection;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
EditorWorkspaceWindowContentController::EditorWorkspaceWindowContentController(
|
||||
std::string windowId,
|
||||
UIEditorWorkspaceController workspaceController)
|
||||
: m_windowId(std::move(windowId)),
|
||||
m_workspaceController(std::move(workspaceController)) {}
|
||||
m_workspaceController(std::move(workspaceController)) {
|
||||
m_projection = BuildWorkspaceProjectionFromController(m_workspaceController, m_windowId);
|
||||
}
|
||||
|
||||
EditorWorkspaceWindowContentController::~EditorWorkspaceWindowContentController() = default;
|
||||
|
||||
@@ -85,9 +102,27 @@ EditorWorkspaceWindowContentController::TryGetWorkspaceController() const {
|
||||
return &m_workspaceController;
|
||||
}
|
||||
|
||||
void EditorWorkspaceWindowContentController::ReplaceWorkspaceController(
|
||||
UIEditorWorkspaceController workspaceController) {
|
||||
m_workspaceController = std::move(workspaceController);
|
||||
const EditorWorkspaceWindowProjection*
|
||||
EditorWorkspaceWindowContentController::TryGetWorkspaceProjection() const {
|
||||
return &m_projection;
|
||||
}
|
||||
|
||||
void EditorWorkspaceWindowContentController::RefreshWorkspaceProjection(
|
||||
EditorWorkspaceWindowProjection projection) {
|
||||
projection.windowState.windowId = m_windowId;
|
||||
const auto currentSnapshot = BuildUIEditorWorkspaceLayoutSnapshot(
|
||||
m_workspaceController.GetWorkspace(),
|
||||
m_workspaceController.GetSession());
|
||||
const auto nextSnapshot = BuildUIEditorWorkspaceLayoutSnapshot(
|
||||
projection.windowState.workspace,
|
||||
projection.windowState.session);
|
||||
if (!AreUIEditorWorkspaceLayoutSnapshotsEquivalent(currentSnapshot, nextSnapshot)) {
|
||||
m_workspaceController = UIEditorWorkspaceController(
|
||||
m_workspaceController.GetPanelRegistry(),
|
||||
projection.windowState.workspace,
|
||||
projection.windowState.session);
|
||||
}
|
||||
m_projection = std::move(projection);
|
||||
}
|
||||
|
||||
void EditorWorkspaceWindowContentController::Initialize(
|
||||
@@ -205,21 +240,25 @@ EditorWindowContentCursorKind EditorWorkspaceWindowContentController::GetDockCur
|
||||
}
|
||||
|
||||
::XCEngine::UI::UISize EditorWorkspaceWindowContentController::ResolveMinimumOuterSize() const {
|
||||
return ResolveUIEditorDetachedWorkspaceMinimumOuterSize(m_workspaceController);
|
||||
return m_projection.minimumOuterSize;
|
||||
}
|
||||
|
||||
bool EditorWorkspaceWindowContentController::ShouldUseDetachedTitleBarTabStrip() const {
|
||||
return HasUIEditorSingleVisibleRootTab(m_workspaceController);
|
||||
return m_projection.useDetachedTitleBarTabStrip;
|
||||
}
|
||||
|
||||
std::string EditorWorkspaceWindowContentController::ResolveTabStripTitleText(
|
||||
std::string_view fallbackTitle) const {
|
||||
return ResolveUIEditorDetachedWorkspaceTitle(m_workspaceController, fallbackTitle);
|
||||
return m_projection.tabStripTitleText.empty()
|
||||
? std::string(fallbackTitle)
|
||||
: m_projection.tabStripTitleText;
|
||||
}
|
||||
|
||||
std::string EditorWorkspaceWindowContentController::ResolveDetachedWindowTitleText(
|
||||
std::string_view fallbackWindowTitle) const {
|
||||
return ResolveUIEditorDetachedWorkspaceTitle(m_workspaceController, fallbackWindowTitle);
|
||||
return m_projection.detachedWindowTitleText.empty()
|
||||
? std::string(fallbackWindowTitle)
|
||||
: m_projection.detachedWindowTitleText;
|
||||
}
|
||||
|
||||
std::unique_ptr<EditorWindowContentController> CreateEditorWorkspaceWindowContentController(
|
||||
|
||||
Reference in New Issue
Block a user