Files
XCEngine/editor/app/Features/Game/GameViewportController.cpp

63 lines
2.0 KiB
C++

#include "Game/GameViewportController.h"
#include "Panels/EditorPanelIds.h"
#include "State/EditorCommandFocusService.h"
#include <algorithm>
namespace XCEngine::UI::Editor::App {
namespace {
bool ContainsPoint(
const ::XCEngine::UI::UIRect& rect,
const ::XCEngine::UI::UIPoint& point) {
return point.x >= rect.x &&
point.x <= rect.x + rect.width &&
point.y >= rect.y &&
point.y <= rect.y + rect.height;
}
} // namespace
void GameViewportController::ResetInteractionState() {}
void GameViewportController::SetCommandFocusService(
EditorCommandFocusService* commandFocusService) {
m_commandFocusService = commandFocusService;
}
void GameViewportController::Update(
const UIEditorWorkspaceComposeState& composeState,
const UIEditorWorkspaceComposeFrame& composeFrame) {
const UIEditorWorkspaceViewportComposeFrame* viewportFrame =
FindUIEditorWorkspaceViewportPresentationFrame(composeFrame, kGamePanelId);
const UIEditorWorkspacePanelPresentationState* panelState =
FindUIEditorWorkspacePanelPresentationState(composeState, kGamePanelId);
if (viewportFrame == nullptr || panelState == nullptr) {
return;
}
const auto& inputFrame = viewportFrame->viewportShellFrame.inputFrame;
const auto& slotLayout = viewportFrame->viewportShellFrame.slotLayout;
if (m_commandFocusService != nullptr &&
(inputFrame.focused ||
std::any_of(
inputFrame.pointerButtonTransitions.begin(),
inputFrame.pointerButtonTransitions.end(),
[&](const auto& transition) {
return transition.pressed &&
ContainsPoint(slotLayout.bounds, transition.screenPosition);
}))) {
m_commandFocusService->ClaimFocus(EditorActionRoute::Game);
}
(void)panelState;
}
void GameViewportController::Append(::XCEngine::UI::UIDrawList& drawList) const {
(void)drawList;
}
} // namespace XCEngine::UI::Editor::App