@@ -0,0 +1,610 @@
# ifndef NOMINMAX
# define NOMINMAX
# endif
# include <XCEditor/Core/UIEditorPanelContentHost.h>
# include <XCEditor/Core/UIEditorWorkspaceCompose.h>
# include <XCEditor/Core/UIEditorWorkspaceController.h>
# include "Host/AutoScreenshot.h"
# include "Host/NativeRenderer.h"
# include <XCEngine/UI/DrawData.h>
# include <windows.h>
# include <windowsx.h>
# include <algorithm>
# include <filesystem>
# include <sstream>
# include <string>
# include <string_view>
# include <utility>
# include <vector>
# ifndef XCENGINE_EDITOR_UI_TESTS_REPO_ROOT
# define XCENGINE_EDITOR_UI_TESTS_REPO_ROOT "."
# endif
namespace {
using XCEngine : : UI : : UIColor ;
using XCEngine : : UI : : UIDrawData ;
using XCEngine : : UI : : UIDrawList ;
using XCEngine : : UI : : UIPoint ;
using XCEngine : : UI : : UIRect ;
using XCEngine : : UI : : Editor : : AppendUIEditorWorkspaceCompose ;
using XCEngine : : UI : : Editor : : BuildDefaultUIEditorWorkspaceController ;
using XCEngine : : UI : : Editor : : BuildUIEditorWorkspacePanel ;
using XCEngine : : UI : : Editor : : BuildUIEditorWorkspaceSplit ;
using XCEngine : : UI : : Editor : : BuildUIEditorWorkspaceTabStack ;
using XCEngine : : UI : : Editor : : CollectUIEditorWorkspaceComposeExternalBodyPanelIds ;
using XCEngine : : UI : : Editor : : GetUIEditorPanelContentHostEventKindName ;
using XCEngine : : UI : : Editor : : GetUIEditorWorkspaceCommandStatusName ;
using XCEngine : : UI : : Editor : : Host : : AutoScreenshotController ;
using XCEngine : : UI : : Editor : : Host : : NativeRenderer ;
using XCEngine : : UI : : Editor : : UIEditorPanelContentHostPanelState ;
using XCEngine : : UI : : Editor : : UIEditorPanelPresentationKind ;
using XCEngine : : UI : : Editor : : UIEditorPanelRegistry ;
using XCEngine : : UI : : Editor : : UIEditorWorkspaceCommand ;
using XCEngine : : UI : : Editor : : UIEditorWorkspaceCommandKind ;
using XCEngine : : UI : : Editor : : UIEditorWorkspaceComposeFrame ;
using XCEngine : : UI : : Editor : : UIEditorWorkspaceComposeState ;
using XCEngine : : UI : : Editor : : UIEditorWorkspaceController ;
using XCEngine : : UI : : Editor : : UIEditorWorkspaceModel ;
using XCEngine : : UI : : Editor : : UIEditorWorkspacePanelPresentationModel ;
using XCEngine : : UI : : Editor : : UIEditorWorkspaceSplitAxis ;
using XCEngine : : UI : : Editor : : UpdateUIEditorWorkspaceCompose ;
constexpr const wchar_t * kWindowClassName = L " XCUIEditorPanelContentHostBasicValidation " ;
constexpr const wchar_t * kWindowTitle = L " XCUI Editor | Panel Content Host " ;
constexpr UIColor kWindowBg ( 0.12f , 0.12f , 0.12f , 1.0f ) ;
constexpr UIColor kCardBg ( 0.18f , 0.18f , 0.18f , 1.0f ) ;
constexpr UIColor kCardBorder ( 0.29f , 0.29f , 0.29f , 1.0f ) ;
constexpr UIColor kTextPrimary ( 0.94f , 0.94f , 0.94f , 1.0f ) ;
constexpr UIColor kTextMuted ( 0.72f , 0.72f , 0.72f , 1.0f ) ;
constexpr UIColor kTextWeak ( 0.56f , 0.56f , 0.56f , 1.0f ) ;
constexpr UIColor kSuccess ( 0.46f , 0.72f , 0.50f , 1.0f ) ;
constexpr UIColor kWarning ( 0.82f , 0.68f , 0.36f , 1.0f ) ;
constexpr UIColor kDanger ( 0.78f , 0.35f , 0.35f , 1.0f ) ;
constexpr UIColor kButtonBg ( 0.25f , 0.25f , 0.25f , 1.0f ) ;
constexpr UIColor kButtonHover ( 0.33f , 0.33f , 0.33f , 1.0f ) ;
constexpr UIColor kButtonBorder ( 0.46f , 0.46f , 0.46f , 1.0f ) ;
constexpr UIColor kMountedFill ( 0.22f , 0.28f , 0.36f , 1.0f ) ;
constexpr UIColor kMountedBorder ( 0.66f , 0.76f , 0.86f , 1.0f ) ;
enum class ActionId : unsigned char {
ActivateDocA = 0 ,
ActivateDocB ,
ActivateConsole ,
ActivateInspector ,
CloseInspector ,
OpenInspector ,
Reset ,
Capture
} ;
struct ButtonState {
ActionId action = ActionId : : ActivateDocA ;
std : : string label = { } ;
UIRect rect = { } ;
bool hovered = false ;
} ;
std : : filesystem : : path ResolveRepoRootPath ( ) {
std : : string root = XCENGINE_EDITOR_UI_TESTS_REPO_ROOT ;
if ( root . size ( ) > = 2u & & root . front ( ) = = ' " ' & & root . back ( ) = = ' " ' ) {
root = root . substr ( 1u , root . size ( ) - 2u ) ;
}
return std : : filesystem : : path ( root ) . lexically_normal ( ) ;
}
bool ContainsPoint ( const UIRect & rect , float x , float y ) {
return x > = rect . x & &
x < = rect . x + rect . width & &
y > = rect . y & &
y < = rect . y + rect . height ;
}
UIEditorPanelRegistry BuildPanelRegistry ( ) {
UIEditorPanelRegistry registry = { } ;
registry . panels = {
{ " doc-a " , " Document A " , UIEditorPanelPresentationKind : : HostedContent , false , true , true } ,
{ " doc-b " , " Document B " , UIEditorPanelPresentationKind : : HostedContent , false , true , true } ,
{ " console " , " Console " , UIEditorPanelPresentationKind : : Placeholder , true , true , true } ,
{ " inspector " , " Inspector " , UIEditorPanelPresentationKind : : HostedContent , false , true , true }
} ;
return registry ;
}
UIEditorWorkspaceModel BuildWorkspace ( ) {
UIEditorWorkspaceModel workspace = { } ;
workspace . root = BuildUIEditorWorkspaceSplit (
" root " ,
UIEditorWorkspaceSplitAxis : : Horizontal ,
0.68f ,
BuildUIEditorWorkspaceTabStack (
" documents " ,
{
BuildUIEditorWorkspacePanel ( " doc-a-node " , " doc-a " , " Document A " ) ,
BuildUIEditorWorkspacePanel ( " doc-b-node " , " doc-b " , " Document B " ) ,
BuildUIEditorWorkspacePanel ( " console-node " , " console " , " Console " , true )
} ,
0u ) ,
BuildUIEditorWorkspacePanel ( " inspector-node " , " inspector " , " Inspector " ) ) ;
workspace . activePanelId = " doc-a " ;
return workspace ;
}
std : : vector < UIEditorWorkspacePanelPresentationModel > BuildPresentationModels ( ) {
std : : vector < UIEditorWorkspacePanelPresentationModel > models = { } ;
for ( std : : string_view panelId : { " doc-a " , " doc-b " , " inspector " } ) {
UIEditorWorkspacePanelPresentationModel model = { } ;
model . panelId = std : : string ( panelId ) ;
model . kind = UIEditorPanelPresentationKind : : HostedContent ;
models . push_back ( std : : move ( model ) ) ;
}
return models ;
}
std : : string JoinExternalBodyPanelIds ( const UIEditorWorkspaceComposeFrame & frame ) {
const auto panelIds = CollectUIEditorWorkspaceComposeExternalBodyPanelIds ( frame ) ;
if ( panelIds . empty ( ) ) {
return " (none) " ;
}
std : : ostringstream stream = { } ;
for ( std : : size_t index = 0 ; index < panelIds . size ( ) ; + + index ) {
if ( index > 0u ) {
stream < < " , " ;
}
stream < < panelIds [ index ] ;
}
return stream . str ( ) ;
}
std : : string FormatEvents ( const UIEditorWorkspaceComposeFrame & frame ) {
if ( frame . contentHostFrame . events . empty ( ) ) {
return " (none) " ;
}
std : : ostringstream stream = { } ;
for ( std : : size_t index = 0 ; index < frame . contentHostFrame . events . size ( ) ; + + index ) {
if ( index > 0u ) {
stream < < " | " ;
}
stream < < GetUIEditorPanelContentHostEventKindName ( frame . contentHostFrame . events [ index ] . kind )
< < " : " < < frame . contentHostFrame . events [ index ] . panelId ;
}
return stream . str ( ) ;
}
std : : string DescribeMountedState (
const UIEditorWorkspaceComposeFrame & frame ,
std : : string_view panelId ) {
for ( const UIEditorPanelContentHostPanelState & panelState : frame . contentHostFrame . panelStates ) {
if ( panelState . panelId ! = panelId ) {
continue ;
}
if ( ! panelState . mounted ) {
return std : : string ( panelId ) + " : unmounted " ;
}
std : : ostringstream stream = { } ;
stream < < panelId < < " : mounted @ "
< < static_cast < int > ( panelState . bounds . width ) < < " x "
< < static_cast < int > ( panelState . bounds . height ) ;
return stream . str ( ) ;
}
return std : : string ( panelId ) + " : missing " ;
}
void DrawCard (
UIDrawList & drawList ,
const UIRect & rect ,
std : : string_view title ,
std : : string_view subtitle = { } ) {
drawList . AddFilledRect ( rect , kCardBg , 12.0f ) ;
drawList . AddRectOutline ( rect , kCardBorder , 1.0f , 12.0f ) ;
drawList . AddText ( UIPoint ( rect . x + 18.0f , rect . y + 16.0f ) , std : : string ( title ) , kTextPrimary , 17.0f ) ;
if ( ! subtitle . empty ( ) ) {
drawList . AddText ( UIPoint ( rect . x + 18.0f , rect . y + 42.0f ) , std : : string ( subtitle ) , kTextMuted , 12.0f ) ;
}
}
void DrawButton ( UIDrawList & drawList , const ButtonState & button ) {
drawList . AddFilledRect ( button . rect , button . hovered ? kButtonHover : kButtonBg , 8.0f ) ;
drawList . AddRectOutline ( button . rect , kButtonBorder , 1.0f , 8.0f ) ;
drawList . AddText ( UIPoint ( button . rect . x + 12.0f , button . rect . y + 10.0f ) , button . label , kTextPrimary , 12.0f ) ;
}
class ScenarioApp {
public :
int Run ( HINSTANCE hInstance , int nCmdShow ) {
if ( ! Initialize ( hInstance , nCmdShow ) ) {
Shutdown ( ) ;
return 1 ;
}
MSG message = { } ;
while ( message . message ! = WM_QUIT ) {
if ( PeekMessageW ( & message , nullptr , 0U , 0U , PM_REMOVE ) ) {
TranslateMessage ( & message ) ;
DispatchMessageW ( & message ) ;
continue ;
}
RenderFrame ( ) ;
Sleep ( 8 ) ;
}
Shutdown ( ) ;
return static_cast < int > ( message . wParam ) ;
}
private :
static LRESULT CALLBACK WndProc ( HWND hwnd , UINT message , WPARAM wParam , LPARAM lParam ) {
if ( message = = WM_NCCREATE ) {
const auto * createStruct = reinterpret_cast < CREATESTRUCTW * > ( lParam ) ;
auto * app = reinterpret_cast < ScenarioApp * > ( createStruct - > lpCreateParams ) ;
SetWindowLongPtrW ( hwnd , GWLP_USERDATA , reinterpret_cast < LONG_PTR > ( app ) ) ;
return TRUE ;
}
auto * app = reinterpret_cast < ScenarioApp * > ( GetWindowLongPtrW ( hwnd , GWLP_USERDATA ) ) ;
switch ( message ) {
case WM_SIZE :
if ( app ! = nullptr & & wParam ! = SIZE_MINIMIZED ) {
app - > OnResize ( static_cast < UINT > ( LOWORD ( lParam ) ) , static_cast < UINT > ( HIWORD ( lParam ) ) ) ;
}
return 0 ;
case WM_PAINT :
if ( app ! = nullptr ) {
PAINTSTRUCT paintStruct = { } ;
BeginPaint ( hwnd , & paintStruct ) ;
app - > RenderFrame ( ) ;
EndPaint ( hwnd , & paintStruct ) ;
return 0 ;
}
break ;
case WM_MOUSEMOVE :
if ( app ! = nullptr ) {
app - > HandleMouseMove (
static_cast < float > ( GET_X_LPARAM ( lParam ) ) ,
static_cast < float > ( GET_Y_LPARAM ( lParam ) ) ) ;
return 0 ;
}
break ;
case WM_LBUTTONUP :
if ( app ! = nullptr ) {
app - > HandleClick (
static_cast < float > ( GET_X_LPARAM ( lParam ) ) ,
static_cast < float > ( GET_Y_LPARAM ( lParam ) ) ) ;
return 0 ;
}
break ;
case WM_KEYDOWN :
case WM_SYSKEYDOWN :
if ( app ! = nullptr & & wParam = = VK_F12 ) {
app - > m_autoScreenshot . RequestCapture ( " manual_f12 " ) ;
return 0 ;
}
break ;
case WM_ERASEBKGND :
return 1 ;
case WM_DESTROY :
if ( app ! = nullptr ) {
app - > m_hwnd = nullptr ;
}
PostQuitMessage ( 0 ) ;
return 0 ;
default :
break ;
}
return DefWindowProcW ( hwnd , message , wParam , lParam ) ;
}
bool Initialize ( HINSTANCE hInstance , int nCmdShow ) {
m_hInstance = hInstance ;
WNDCLASSEXW windowClass = { } ;
windowClass . cbSize = sizeof ( windowClass ) ;
windowClass . style = CS_HREDRAW | CS_VREDRAW ;
windowClass . lpfnWndProc = & ScenarioApp : : WndProc ;
windowClass . hInstance = hInstance ;
windowClass . hCursor = LoadCursorW ( nullptr , IDC_ARROW ) ;
windowClass . lpszClassName = kWindowClassName ;
m_windowClassAtom = RegisterClassExW ( & windowClass ) ;
if ( m_windowClassAtom = = 0 ) {
return false ;
}
m_hwnd = CreateWindowExW (
0 ,
kWindowClassName ,
kWindowTitle ,
WS_OVERLAPPEDWINDOW | WS_VISIBLE ,
CW_USEDEFAULT ,
CW_USEDEFAULT ,
1460 ,
920 ,
nullptr ,
nullptr ,
hInstance ,
this ) ;
if ( m_hwnd = = nullptr ) {
return false ;
}
ShowWindow ( m_hwnd , nCmdShow ) ;
UpdateWindow ( m_hwnd ) ;
if ( ! m_renderer . Initialize ( m_hwnd ) ) {
return false ;
}
m_captureRoot =
ResolveRepoRootPath ( ) /
" tests/UI/Editor/integration/shell/panel_content_host_basic/captures " ;
m_autoScreenshot . Initialize ( m_captureRoot ) ;
ResetScenario ( ) ;
return true ;
}
void Shutdown ( ) {
m_autoScreenshot . Shutdown ( ) ;
m_renderer . Shutdown ( ) ;
if ( m_hwnd ! = nullptr ) {
DestroyWindow ( m_hwnd ) ;
m_hwnd = nullptr ;
}
if ( m_windowClassAtom ! = 0 ) {
UnregisterClassW ( kWindowClassName , m_hInstance ) ;
m_windowClassAtom = 0 ;
}
}
void ResetScenario ( ) {
m_controller =
BuildDefaultUIEditorWorkspaceController ( BuildPanelRegistry ( ) , BuildWorkspace ( ) ) ;
m_composeState = { } ;
m_lastStatus = " Ready " ;
m_lastMessage =
" 当前先看 doc-a 与 inspector: 两者都会 mount; 切到 Console 后, tab body 会回退成 placeholder。 " ;
UpdateComposeFrame ( ) ;
}
void UpdateLayout ( ) {
RECT clientRect = { } ;
GetClientRect ( m_hwnd , & clientRect ) ;
const float width = static_cast < float > ( ( std : : max ) ( clientRect . right - clientRect . left , 1L ) ) ;
const float height = static_cast < float > ( ( std : : max ) ( clientRect . bottom - clientRect . top , 1L ) ) ;
constexpr float padding = 20.0f ;
constexpr float leftWidth = 430.0f ;
m_introRect = UIRect ( padding , padding , leftWidth , 206.0f ) ;
m_controlsRect = UIRect ( padding , 242.0f , leftWidth , 208.0f ) ;
m_stateRect = UIRect ( padding , 466.0f , leftWidth , height - 486.0f ) ;
m_previewRect = UIRect ( leftWidth + padding * 2.0f , padding , width - leftWidth - padding * 3.0f , height - padding * 2.0f ) ;
m_workspaceRect = UIRect ( m_previewRect . x + 18.0f , m_previewRect . y + 54.0f , m_previewRect . width - 36.0f , m_previewRect . height - 72.0f ) ;
const float buttonWidth = ( m_controlsRect . width - 32.0f - 16.0f ) * 0.5f ;
const float buttonLeft = m_controlsRect . x + 16.0f ;
const float buttonTop = m_controlsRect . y + 62.0f ;
const float buttonHeight = 34.0f ;
const float rowGap = 10.0f ;
m_buttons = {
{ ActionId : : ActivateDocA , " Activate Doc A " , UIRect ( buttonLeft , buttonTop , buttonWidth , buttonHeight ) , false } ,
{ ActionId : : ActivateDocB , " Activate Doc B " , UIRect ( buttonLeft + buttonWidth + 16.0f , buttonTop , buttonWidth , buttonHeight ) , false } ,
{ ActionId : : ActivateConsole , " Activate Console " , UIRect ( buttonLeft , buttonTop + buttonHeight + rowGap , buttonWidth , buttonHeight ) , false } ,
{ ActionId : : ActivateInspector , " Activate Inspector " , UIRect ( buttonLeft + buttonWidth + 16.0f , buttonTop + buttonHeight + rowGap , buttonWidth , buttonHeight ) , false } ,
{ ActionId : : CloseInspector , " Close Inspector " , UIRect ( buttonLeft , buttonTop + ( buttonHeight + rowGap ) * 2.0f , buttonWidth , buttonHeight ) , false } ,
{ ActionId : : OpenInspector , " Open Inspector " , UIRect ( buttonLeft + buttonWidth + 16.0f , buttonTop + ( buttonHeight + rowGap ) * 2.0f , buttonWidth , buttonHeight ) , false } ,
{ ActionId : : Reset , " Reset " , UIRect ( buttonLeft , buttonTop + ( buttonHeight + rowGap ) * 3.0f , buttonWidth , buttonHeight ) , false } ,
{ ActionId : : Capture , " Capture(F12) " , UIRect ( buttonLeft + buttonWidth + 16.0f , buttonTop + ( buttonHeight + rowGap ) * 3.0f , buttonWidth , buttonHeight ) , false }
} ;
}
void OnResize ( UINT width , UINT height ) {
m_renderer . Resize ( width , height ) ;
InvalidateRect ( m_hwnd , nullptr , FALSE ) ;
}
void HandleMouseMove ( float x , float y ) {
UpdateLayout ( ) ;
for ( ButtonState & button : m_buttons ) {
button . hovered = ContainsPoint ( button . rect , x , y ) ;
}
}
void HandleClick ( float x , float y ) {
UpdateLayout ( ) ;
for ( const ButtonState & button : m_buttons ) {
if ( ContainsPoint ( button . rect , x , y ) ) {
ExecuteAction ( button . action ) ;
return ;
}
}
}
void ExecuteAction ( ActionId action ) {
if ( action = = ActionId : : Reset ) {
ResetScenario ( ) ;
return ;
}
if ( action = = ActionId : : Capture ) {
m_autoScreenshot . RequestCapture ( " manual_button " ) ;
m_lastStatus = " Ready " ;
m_lastMessage =
" 截图已排队,输出到 tests/UI/Editor/integration/shell/panel_content_host_basic/captures/。 " ;
return ;
}
UIEditorWorkspaceCommand command = { } ;
switch ( action ) {
case ActionId : : ActivateDocA :
command . kind = UIEditorWorkspaceCommandKind : : ActivatePanel ;
command . panelId = " doc-a " ;
break ;
case ActionId : : ActivateDocB :
command . kind = UIEditorWorkspaceCommandKind : : ActivatePanel ;
command . panelId = " doc-b " ;
break ;
case ActionId : : ActivateConsole :
command . kind = UIEditorWorkspaceCommandKind : : ActivatePanel ;
command . panelId = " console " ;
break ;
case ActionId : : ActivateInspector :
command . kind = UIEditorWorkspaceCommandKind : : ActivatePanel ;
command . panelId = " inspector " ;
break ;
case ActionId : : CloseInspector :
command . kind = UIEditorWorkspaceCommandKind : : ClosePanel ;
command . panelId = " inspector " ;
break ;
case ActionId : : OpenInspector :
command . kind = UIEditorWorkspaceCommandKind : : OpenPanel ;
command . panelId = " inspector " ;
break ;
default :
return ;
}
const auto result = m_controller . Dispatch ( command ) ;
m_lastStatus = std : : string ( GetUIEditorWorkspaceCommandStatusName ( result . status ) ) ;
m_lastMessage = result . message ;
UpdateComposeFrame ( ) ;
}
void UpdateComposeFrame ( ) {
UpdateLayout ( ) ;
m_composeFrame = UpdateUIEditorWorkspaceCompose (
m_composeState ,
m_workspaceRect ,
m_controller . GetPanelRegistry ( ) ,
m_controller . GetWorkspace ( ) ,
m_controller . GetSession ( ) ,
BuildPresentationModels ( ) ,
{ } ) ;
}
void RenderFrame ( ) {
UpdateComposeFrame ( ) ;
RECT clientRect = { } ;
GetClientRect ( m_hwnd , & clientRect ) ;
const float width = static_cast < float > ( ( std : : max ) ( clientRect . right - clientRect . left , 1L ) ) ;
const float height = static_cast < float > ( ( std : : max ) ( clientRect . bottom - clientRect . top , 1L ) ) ;
UIDrawData drawData = { } ;
UIDrawList & drawList = drawData . EmplaceDrawList ( " PanelContentHostBasic " ) ;
drawList . AddFilledRect ( UIRect ( 0.0f , 0.0f , width , height ) , kWindowBg ) ;
DrawCard ( drawList , m_introRect , " 这个测试验证什么功能 " , " 只验证 Editor panel content host contract, 不做业务逻辑。 " ) ;
drawList . AddText ( UIPoint ( m_introRect . x + 18.0f , m_introRect . y + 72.0f ) , " 1. 验证 HostedContent panel 会正式接管 DockHost body, 而不是继续画 placeholder。 " , kTextPrimary , 12.0f ) ;
drawList . AddText ( UIPoint ( m_introRect . x + 18.0f , m_introRect . y + 94.0f ) , " 2. 验证 tab 切换时,旧 body unmount, 新 body mount。 " , kTextPrimary , 12.0f ) ;
drawList . AddText ( UIPoint ( m_introRect . x + 18.0f , m_introRect . y + 116.0f ) , " 3. 验证切到 Console 这种 placeholder panel 后, external host 会退出。 " , kTextPrimary , 12.0f ) ;
drawList . AddText ( UIPoint ( m_introRect . x + 18.0f , m_introRect . y + 138.0f ) , " 4. 验证 standalone HostedContent close/open 时,会发生 unmount / remount。 " , kTextPrimary , 12.0f ) ;
drawList . AddText ( UIPoint ( m_introRect . x + 18.0f , m_introRect . y + 164.0f ) , " 建议操作: Doc A -> Doc B -> Console -> Open/Close Inspector, 观察 Mounted Panels 和 Events。 " , kTextWeak , 11.0f ) ;
DrawCard ( drawList , m_controlsRect , " 操作 " , " 只保留内容承载 contract 必要按钮。 " ) ;
for ( const ButtonState & button : m_buttons ) {
DrawButton ( drawList , button ) ;
}
DrawCard ( drawList , m_stateRect , " 状态 " , " 重点检查 mounted panel 集合和本帧 mount events。 " ) ;
float stateY = m_stateRect . y + 66.0f ;
auto addStateLine = [ & ] ( std : : string label , std : : string value , const UIColor & color , float fontSize = 12.0f ) {
drawList . AddText ( UIPoint ( m_stateRect . x + 18.0f , stateY ) , std : : move ( label ) + " : " + std : : move ( value ) , color , fontSize ) ;
stateY + = 20.0f ;
} ;
const UIColor resultColor =
m_lastStatus = = " Rejected " ? kDanger :
( m_lastStatus = = " Ready " ? kWarning : kSuccess ) ;
addStateLine ( " Active Panel " , m_controller . GetWorkspace ( ) . activePanelId , kTextPrimary , 11.0f ) ;
addStateLine ( " Mounted Panels " , JoinExternalBodyPanelIds ( m_composeFrame ) , kSuccess , 11.0f ) ;
addStateLine ( " Events " , FormatEvents ( m_composeFrame ) , kWarning , 11.0f ) ;
addStateLine ( " Result " , m_lastStatus , resultColor ) ;
drawList . AddText ( UIPoint ( m_stateRect . x + 18.0f , stateY + 4.0f ) , m_lastMessage , kTextMuted , 11.0f ) ;
stateY + = 32.0f ;
addStateLine ( " doc-a " , DescribeMountedState ( m_composeFrame , " doc-a " ) , kTextWeak , 11.0f ) ;
addStateLine ( " doc-b " , DescribeMountedState ( m_composeFrame , " doc-b " ) , kTextWeak , 11.0f ) ;
addStateLine ( " inspector " , DescribeMountedState ( m_composeFrame , " inspector " ) , kTextWeak , 11.0f ) ;
addStateLine (
" Screenshot " ,
m_autoScreenshot . HasPendingCapture ( )
? " 截图排队中... "
: ( m_autoScreenshot . GetLastCaptureSummary ( ) . empty ( )
? std : : string ( " F12 或 Capture -> captures/ " )
: m_autoScreenshot . GetLastCaptureSummary ( ) ) ,
kTextWeak ,
11.0f ) ;
DrawCard ( drawList , m_previewRect , " Preview " , " DockHost 画壳;蓝色内容块是 external content host 实际挂进去的 body。 " ) ;
AppendUIEditorWorkspaceCompose ( drawList , m_composeFrame ) ;
for ( const UIEditorPanelContentHostPanelState & panelState : m_composeFrame . contentHostFrame . panelStates ) {
if ( ! panelState . mounted | |
panelState . kind ! = UIEditorPanelPresentationKind : : HostedContent ) {
continue ;
}
drawList . AddFilledRect ( panelState . bounds , kMountedFill , 8.0f ) ;
drawList . AddRectOutline ( panelState . bounds , kMountedBorder , 2.0f , 8.0f ) ;
drawList . AddText (
UIPoint ( panelState . bounds . x + 16.0f , panelState . bounds . y + 16.0f ) ,
panelState . panelId ,
kTextPrimary ,
18.0f ) ;
drawList . AddText (
UIPoint ( panelState . bounds . x + 16.0f , panelState . bounds . y + 44.0f ) ,
" External Content Host " ,
kTextMuted ,
12.0f ) ;
drawList . AddText (
UIPoint ( panelState . bounds . x + 16.0f , panelState . bounds . y + 66.0f ) ,
" Mounted Body owned outside DockHost placeholder path. " ,
kTextWeak ,
11.0f ) ;
}
const bool framePresented = m_renderer . Render ( drawData ) ;
m_autoScreenshot . CaptureIfRequested (
m_renderer ,
drawData ,
static_cast < unsigned int > ( width ) ,
static_cast < unsigned int > ( height ) ,
framePresented ) ;
}
HINSTANCE m_hInstance = nullptr ;
HWND m_hwnd = nullptr ;
ATOM m_windowClassAtom = 0 ;
NativeRenderer m_renderer = { } ;
AutoScreenshotController m_autoScreenshot = { } ;
std : : filesystem : : path m_captureRoot = { } ;
UIEditorWorkspaceController m_controller = { } ;
UIEditorWorkspaceComposeState m_composeState = { } ;
UIEditorWorkspaceComposeFrame m_composeFrame = { } ;
std : : string m_lastStatus = { } ;
std : : string m_lastMessage = { } ;
UIRect m_introRect = { } ;
UIRect m_controlsRect = { } ;
UIRect m_stateRect = { } ;
UIRect m_previewRect = { } ;
UIRect m_workspaceRect = { } ;
std : : vector < ButtonState > m_buttons = { } ;
} ;
} // namespace
int WINAPI wWinMain ( HINSTANCE hInstance , HINSTANCE , LPWSTR , int nCmdShow ) {
return ScenarioApp ( ) . Run ( hInstance , nCmdShow ) ;
}