Hide ImGui compat factories behind legacy XCUI interop
This commit is contained in:
@@ -61,8 +61,6 @@ public:
|
||||
virtual void FreeTextureDescriptor(const UITextureRegistration& registration) = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<IEditorHostCompositor> CreateImGuiHostCompositor();
|
||||
|
||||
} // namespace XCUIBackend
|
||||
} // namespace Editor
|
||||
} // namespace XCEngine
|
||||
|
||||
@@ -61,7 +61,6 @@ public:
|
||||
virtual void FreeTextureDescriptor(const UITextureRegistration& registration) = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<IWindowUICompositor> CreateImGuiWindowUICompositor();
|
||||
std::unique_ptr<IWindowUICompositor> CreateNativeWindowUICompositor();
|
||||
|
||||
} // namespace XCUIBackend
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace XCUIBackend {
|
||||
class ImGuiWindowUICompositor final : public IWindowUICompositor {
|
||||
public:
|
||||
explicit ImGuiWindowUICompositor(
|
||||
std::unique_ptr<IEditorHostCompositor> hostCompositor = CreateImGuiHostCompositor())
|
||||
std::unique_ptr<IEditorHostCompositor> hostCompositor)
|
||||
: m_hostCompositor(std::move(hostCompositor)) {
|
||||
}
|
||||
|
||||
@@ -79,10 +79,6 @@ private:
|
||||
std::unique_ptr<IEditorHostCompositor> m_hostCompositor;
|
||||
};
|
||||
|
||||
inline std::unique_ptr<IWindowUICompositor> CreateImGuiWindowUICompositor() {
|
||||
return std::make_unique<ImGuiWindowUICompositor>();
|
||||
}
|
||||
|
||||
} // namespace XCUIBackend
|
||||
} // namespace Editor
|
||||
} // namespace XCEngine
|
||||
|
||||
@@ -12,14 +12,11 @@ namespace Editor {
|
||||
namespace XCUIBackend {
|
||||
|
||||
bool ConfigureLegacyImGuiHostFonts() {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImFont* uiFont = nullptr;
|
||||
if (!BuildDefaultXCUIEditorFontAtlas(*io.Fonts, uiFont)) {
|
||||
return false;
|
||||
}
|
||||
return ConfigureDefaultXCUIEditorFontsForCurrentContext();
|
||||
}
|
||||
|
||||
io.FontDefault = uiFont;
|
||||
return io.FontDefault != nullptr;
|
||||
std::unique_ptr<IWindowUICompositor> CreateImGuiWindowUICompositor() {
|
||||
return std::make_unique<ImGuiWindowUICompositor>(CreateImGuiHostCompositor());
|
||||
}
|
||||
|
||||
std::unique_ptr<IWindowUICompositor> CreateLegacyImGuiWindowUICompositor() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "XCUIBackend/IEditorHostCompositor.h"
|
||||
#include "XCUIBackend/XCUIInputBridge.h"
|
||||
#include "XCUIBackend/IWindowUICompositor.h"
|
||||
#include "XCUIBackend/XCUIHostedPreviewPresenter.h"
|
||||
@@ -13,6 +14,10 @@ namespace XCUIBackend {
|
||||
|
||||
bool ConfigureLegacyImGuiHostFonts();
|
||||
|
||||
std::unique_ptr<IEditorHostCompositor> CreateImGuiHostCompositor();
|
||||
|
||||
std::unique_ptr<IWindowUICompositor> CreateImGuiWindowUICompositor();
|
||||
|
||||
std::unique_ptr<IWindowUICompositor> CreateLegacyImGuiWindowUICompositor();
|
||||
|
||||
std::unique_ptr<IXCUIHostedPreviewPresenter> CreateLegacyImGuiHostedPreviewPresenter();
|
||||
|
||||
@@ -12,8 +12,6 @@ constexpr float kUiFontSize = 18.0f;
|
||||
constexpr const char* kPrimaryUiFontPath = "C:/Windows/Fonts/segoeui.ttf";
|
||||
constexpr const char* kChineseFallbackFontPath = "C:/Windows/Fonts/msyh.ttc";
|
||||
|
||||
} // namespace
|
||||
|
||||
bool BuildDefaultXCUIEditorFontAtlas(::ImFontAtlas& atlas, ::ImFont*& outDefaultFont) {
|
||||
outDefaultFont = nullptr;
|
||||
atlas.Clear();
|
||||
@@ -55,6 +53,19 @@ bool BuildDefaultXCUIEditorFontAtlas(::ImFontAtlas& atlas, ::ImFont*& outDefault
|
||||
return outDefaultFont != nullptr;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool ConfigureDefaultXCUIEditorFontsForCurrentContext() {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImFont* uiFont = nullptr;
|
||||
if (!BuildDefaultXCUIEditorFontAtlas(*io.Fonts, uiFont)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
io.FontDefault = uiFont;
|
||||
return io.FontDefault != nullptr;
|
||||
}
|
||||
|
||||
} // namespace XCUIBackend
|
||||
} // namespace Editor
|
||||
} // namespace XCEngine
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
struct ImFont;
|
||||
struct ImFontAtlas;
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Editor {
|
||||
namespace XCUIBackend {
|
||||
|
||||
bool BuildDefaultXCUIEditorFontAtlas(::ImFontAtlas& atlas, ::ImFont*& outDefaultFont);
|
||||
bool ConfigureDefaultXCUIEditorFontsForCurrentContext();
|
||||
|
||||
} // namespace XCUIBackend
|
||||
} // namespace Editor
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "IXCUITextAtlasProvider.h"
|
||||
#include "XCUIEditorFontSetup.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user