60 obj->ctx = uic_context(obj, mp); |
60 obj->ctx = uic_context(obj, mp); |
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) { |
66 if (title) { |
67 wchar_t *wtitle = str2wstr(title, nullptr); |
67 wchar_t *wtitle = str2wstr(title, nullptr); |
68 window.Title(wtitle); |
68 window.Title(wtitle); |
69 free(wtitle); |
69 free(wtitle); |
70 } |
70 } |
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 |
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 |
75 |
76 Grid grid = Grid(); |
76 Grid grid = Grid(); |
77 window.Content(grid); |
77 window.Content(grid); |
78 |
78 |
|
79 StackPanel titleBar = StackPanel(); |
|
80 Thickness titleBarPadding = { 10, 5, 5, 10 }; |
|
81 titleBar.Padding(titleBarPadding); |
|
82 titleBar.Orientation(Orientation::Horizontal); |
|
83 TextBlock titleLabel = TextBlock(); |
|
84 titleLabel.Text(hstring(L"Window Title")); |
|
85 titleBar.Children().Append(titleLabel); |
|
86 |
|
87 window.SetTitleBar(titleBar); |
|
88 |
79 obj->wobj = new UiWindow(window); |
89 obj->wobj = new UiWindow(window); |
80 |
90 |
81 |
91 |
82 window.Closed([obj](IInspectable const& sender, WindowEventArgs) { |
92 window.Closed([obj](IInspectable const& sender, WindowEventArgs) { |
83 // TODO: destroy UiObject*, context, ... |
93 // TODO: destroy UiObject*, context, ... |
84 delete obj->wobj; |
94 delete obj->wobj; |
85 }); |
95 }); |
86 |
96 |
87 obj->container = new UiBoxContainer(grid, UI_BOX_CONTAINER_VBOX, 0, 0); |
97 obj->container = new UiBoxContainer(grid, UI_BOX_CONTAINER_VBOX, 0, 0); |
|
98 |
|
99 titleBar.VerticalAlignment(VerticalAlignment::Top); |
|
100 obj->container->Add(titleBar, false); |
88 |
101 |
89 if (uic_get_menu_list()) { |
102 if (uic_get_menu_list()) { |
90 // create/add menubar |
103 // create/add menubar |
91 MenuBar mb = ui_create_menubar(obj); |
104 MenuBar mb = ui_create_menubar(obj); |
92 mb.VerticalAlignment(VerticalAlignment::Top); |
105 mb.VerticalAlignment(VerticalAlignment::Top); |