Split XCUI hosted preview ImGui presenter seam
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user