Split XCUI hosted preview ImGui presenter seam

This commit is contained in:
2026-04-05 06:34:15 +08:00
parent 6159eef3af
commit 9525053624
7 changed files with 142 additions and 83 deletions

View File

@@ -1,5 +1,6 @@
#include "XCUIDemoPanel.h"
#include "XCUIBackend/ImGuiXCUIHostedPreviewPresenter.h"
#include "XCUIBackend/ImGuiXCUIInputAdapter.h"
#include <XCEngine/UI/Types.h>
@@ -30,6 +31,16 @@ UI::UIRect ToUIRect(const ImVec2& minPoint, const ImVec2& size) {
return UI::UIRect(minPoint.x, minPoint.y, size.x, size.y);
}
ImTextureID ToImTextureId(const UI::UITextureHandle& texture) {
return texture.IsValid()
? static_cast<ImTextureID>(texture.nativeHandle)
: ImTextureID{};
}
ImVec2 ToImVec2(const UI::UIPoint& point) {
return ImVec2(point.x, point.y);
}
bool ContainsPoint(const UI::UIRect& rect, const UI::UIPoint& point) {
return point.x >= rect.x &&
point.y >= rect.y &&
@@ -216,7 +227,11 @@ void XCUIDemoPanel::Render() {
if (validCanvas) {
ImGui::SetCursorScreenPos(canvasMin);
if (showHostedSurfaceImage) {
ImGui::Image(hostedSurfaceImage.textureId, canvasSize, hostedSurfaceImage.uvMin, hostedSurfaceImage.uvMax);
ImGui::Image(
ToImTextureId(hostedSurfaceImage.texture),
canvasSize,
ToImVec2(hostedSurfaceImage.uvMin),
ToImVec2(hostedSurfaceImage.uvMax));
DrawHostedPreviewFrame(drawList, canvasMin, canvasSize);
} else {
ImGui::InvisibleButton("##XCUIDemoCanvas", canvasSize);

View File

@@ -1,5 +1,6 @@
#include "XCUILayoutLabPanel.h"
#include "XCUIBackend/ImGuiXCUIHostedPreviewPresenter.h"
#include <XCEngine/UI/Types.h>
#include <imgui.h>
@@ -23,6 +24,16 @@ UI::UIRect ToUIRect(const ImVec2& minPoint, const ImVec2& size) {
return UI::UIRect(minPoint.x, minPoint.y, size.x, size.y);
}
ImTextureID ToImTextureId(const UI::UITextureHandle& texture) {
return texture.IsValid()
? static_cast<ImTextureID>(texture.nativeHandle)
: ImTextureID{};
}
ImVec2 ToImVec2(const UI::UIPoint& point) {
return ImVec2(point.x, point.y);
}
bool ContainsPoint(const UI::UIRect& rect, const UI::UIPoint& point) {
return point.x >= rect.x &&
point.y >= rect.y &&
@@ -197,7 +208,11 @@ void XCUILayoutLabPanel::Render() {
if (validCanvas) {
ImGui::SetCursorScreenPos(canvasMin);
if (showHostedSurfaceImage) {
ImGui::Image(hostedSurfaceImage.textureId, canvasSize, hostedSurfaceImage.uvMin, hostedSurfaceImage.uvMax);
ImGui::Image(
ToImTextureId(hostedSurfaceImage.texture),
canvasSize,
ToImVec2(hostedSurfaceImage.uvMin),
ToImVec2(hostedSurfaceImage.uvMax));
DrawHostedPreviewFrame(drawList, canvasMin, canvasSize);
} else {
ImGui::InvisibleButton("##XCUILayoutLabCanvas", canvasSize);