61 obj->window = window_data; |
61 obj->window = window_data; |
62 |
62 |
63 //Window window = Window(); |
63 //Window window = Window(); |
64 Window window = make<winui::implementation::MainWindow>(); |
64 Window window = make<winui::implementation::MainWindow>(); |
65 window.ExtendsContentIntoTitleBar(true); |
65 window.ExtendsContentIntoTitleBar(true); |
66 if (title) { |
|
67 wchar_t *wtitle = str2wstr(title, nullptr); |
|
68 window.Title(wtitle); |
|
69 free(wtitle); |
|
70 } |
|
71 |
|
72 //auto backdrop = winrt::Microsoft::UI::Xaml::Media::MicaBackdrop(); |
|
73 //backdrop.Kind(winrt::Microsoft::UI::Composition::SystemBackdrops::MicaKind::Base); // alternative: BaseAlt |
|
74 // TODO: https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/system-backdrop-controller#example-use-mica-in-a-windows-appsdkwinui-3-app |
|
75 |
66 |
76 Grid grid = Grid(); |
67 Grid grid = Grid(); |
77 window.Content(grid); |
68 window.Content(grid); |
78 |
69 |
79 StackPanel titleBar = StackPanel(); |
70 StackPanel titleBar = StackPanel(); |
80 Thickness titleBarPadding = { 10, 5, 5, 10 }; |
71 Thickness titleBarPadding = { 10, 5, 5, 10 }; |
81 titleBar.Padding(titleBarPadding); |
72 titleBar.Padding(titleBarPadding); |
82 titleBar.Orientation(Orientation::Horizontal); |
73 titleBar.Orientation(Orientation::Horizontal); |
83 TextBlock titleLabel = TextBlock(); |
74 TextBlock titleLabel = TextBlock(); |
84 titleLabel.Text(hstring(L"Window Title")); |
|
85 titleBar.Children().Append(titleLabel); |
75 titleBar.Children().Append(titleLabel); |
|
76 |
|
77 if (title) { |
|
78 wchar_t* wtitle = str2wstr(title, nullptr); |
|
79 window.Title(wtitle); |
|
80 titleLabel.Text(hstring(wtitle)); |
|
81 free(wtitle); |
|
82 } |
86 |
83 |
87 window.SetTitleBar(titleBar); |
84 window.SetTitleBar(titleBar); |
88 |
85 |
89 obj->wobj = new UiWindow(window); |
86 obj->wobj = new UiWindow(window); |
90 |
87 ui_context_add_window_destructor(obj->ctx, obj->wobj); |
91 |
88 |
92 window.Closed([obj](IInspectable const& sender, WindowEventArgs) { |
89 window.Closed([obj](IInspectable const& sender, WindowEventArgs) { |
93 // TODO: destroy UiObject*, context, ... |
90 cxMempoolDestroy(obj->ctx->mp); |
94 delete obj->wobj; |
|
95 }); |
91 }); |
96 |
92 |
97 obj->container = new UiBoxContainer(grid, UI_BOX_CONTAINER_VBOX, 0, 0); |
93 obj->container = new UiBoxContainer(grid, UI_BOX_CONTAINER_VBOX, 0, 0); |
98 |
94 |
99 titleBar.VerticalAlignment(VerticalAlignment::Top); |
95 titleBar.VerticalAlignment(VerticalAlignment::Top); |