2026-03-26 22:31:22 +08:00
|
|
|
#include "Actions/ActionRouting.h"
|
2026-03-28 17:40:14 +08:00
|
|
|
#include "Core/IEditorContext.h"
|
2026-03-20 17:08:06 +08:00
|
|
|
#include "SceneViewPanel.h"
|
2026-03-28 17:04:14 +08:00
|
|
|
#include "ViewportPanelContent.h"
|
2026-03-26 21:18:33 +08:00
|
|
|
#include "UI/UI.h"
|
2026-03-20 17:08:06 +08:00
|
|
|
#include <imgui.h>
|
|
|
|
|
|
2026-03-24 20:02:38 +08:00
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace Editor {
|
2026-03-20 17:08:06 +08:00
|
|
|
|
|
|
|
|
SceneViewPanel::SceneViewPanel() : Panel("Scene") {}
|
|
|
|
|
|
|
|
|
|
void SceneViewPanel::Render() {
|
2026-03-26 16:43:06 +08:00
|
|
|
UI::PanelWindowScope panel(m_name.c_str());
|
2026-03-26 22:31:22 +08:00
|
|
|
if (!panel.IsOpen()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-28 17:40:14 +08:00
|
|
|
const ViewportPanelContentResult content = RenderViewportPanelContent(*m_context, EditorViewportKind::Scene);
|
|
|
|
|
if (IViewportHostService* viewportHostService = m_context->GetViewportHostService()) {
|
|
|
|
|
const ImGuiIO& io = ImGui::GetIO();
|
|
|
|
|
if (!m_orbitDragging && content.hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Right)) {
|
|
|
|
|
m_orbitDragging = true;
|
|
|
|
|
}
|
|
|
|
|
if (!m_panDragging && content.hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Middle)) {
|
|
|
|
|
m_panDragging = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_orbitDragging && !ImGui::IsMouseDown(ImGuiMouseButton_Right)) {
|
|
|
|
|
m_orbitDragging = false;
|
|
|
|
|
}
|
|
|
|
|
if (m_panDragging && !ImGui::IsMouseDown(ImGuiMouseButton_Middle)) {
|
|
|
|
|
m_panDragging = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SceneViewportInput input = {};
|
|
|
|
|
input.viewportSize = content.availableSize;
|
|
|
|
|
input.hovered = content.hovered;
|
|
|
|
|
input.focused = content.focused;
|
|
|
|
|
input.mouseWheel = content.hovered ? io.MouseWheel : 0.0f;
|
|
|
|
|
input.orbiting = m_orbitDragging;
|
|
|
|
|
input.panning = m_panDragging;
|
|
|
|
|
input.focusSelectionRequested =
|
|
|
|
|
content.focused && !io.WantTextInput && ImGui::IsKeyPressed(ImGuiKey_F, false);
|
|
|
|
|
|
|
|
|
|
if (m_orbitDragging || m_panDragging) {
|
|
|
|
|
input.mouseDelta = io.MouseDelta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
viewportHostService->UpdateSceneViewInput(*m_context, input);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 22:31:22 +08:00
|
|
|
Actions::ObserveInactiveActionRoute(*m_context);
|
2026-03-20 17:08:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2026-03-24 20:02:38 +08:00
|
|
|
}
|