# HG changeset patch # User Olaf Wintermann # Date 1697111538 -7200 # Node ID 5d71a36b833b8c5d213b48c4dbab10bcbaf44108 # Parent 83556205edad1bad2dbfcd2433c75e42f5fd06a5 add custom titlebar (WinUI3) diff -r 83556205edad -r 5d71a36b833b make/vs/testapp/app.manifest --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/vs/testapp/app.manifest Thu Oct 12 13:52:18 2023 +0200 @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + PerMonitorV2 + + + \ No newline at end of file diff -r 83556205edad -r 5d71a36b833b make/vs/testapp/main.c --- a/make/vs/testapp/main.c Thu Oct 12 13:51:44 2023 +0200 +++ b/make/vs/testapp/main.c Thu Oct 12 13:52:18 2023 +0200 @@ -283,6 +283,10 @@ ui_toolbar_menu("Menu", .label = "Menu") { ui_menuitem(.label = "x", NULL, NULL); + ui_menuitem(.label = "x", NULL, NULL); + ui_menuitem(.label = "x", NULL, NULL); + ui_menuitem(.label = "x", NULL, NULL); + ui_menuitem(.label = "x", NULL, NULL); ui_menu("TB Sub") { ui_menuitem("TB subitem", NULL, NULL); } diff -r 83556205edad -r 5d71a36b833b make/vs/testapp/testapp.vcxproj --- a/make/vs/testapp/testapp.vcxproj Thu Oct 12 13:51:44 2023 +0200 +++ b/make/vs/testapp/testapp.vcxproj Thu Oct 12 13:52:18 2023 +0200 @@ -151,6 +151,9 @@ {27da0164-3475-43e2-a1a4-a5d07d305749} + + + diff -r 83556205edad -r 5d71a36b833b make/vs/testapp/testapp.vcxproj.filters --- a/make/vs/testapp/testapp.vcxproj.filters Thu Oct 12 13:51:44 2023 +0200 +++ b/make/vs/testapp/testapp.vcxproj.filters Thu Oct 12 13:52:18 2023 +0200 @@ -25,4 +25,7 @@ + + + \ No newline at end of file diff -r 83556205edad -r 5d71a36b833b ui/winui/App.xaml --- a/ui/winui/App.xaml Thu Oct 12 13:51:44 2023 +0200 +++ b/ui/winui/App.xaml Thu Oct 12 13:52:18 2023 +0200 @@ -11,6 +11,8 @@ + Transparent + Transparent diff -r 83556205edad -r 5d71a36b833b ui/winui/MainWindow.xaml --- a/ui/winui/MainWindow.xaml Thu Oct 12 13:51:44 2023 +0200 +++ b/ui/winui/MainWindow.xaml Thu Oct 12 13:52:18 2023 +0200 @@ -9,11 +9,12 @@ mc:Ignorable="d"> - - + - - - + + + + + diff -r 83556205edad -r 5d71a36b833b ui/winui/MainWindow.xaml.cpp --- a/ui/winui/MainWindow.xaml.cpp Thu Oct 12 13:51:44 2023 +0200 +++ b/ui/winui/MainWindow.xaml.cpp Thu Oct 12 13:52:18 2023 +0200 @@ -18,6 +18,8 @@ MainWindow::MainWindow() { InitializeComponent(); + //ExtendsContentIntoTitleBar(true); + //SetTitleBar(AppTitleBar()); } int32_t MainWindow::MyProperty() @@ -32,6 +34,6 @@ void MainWindow::myButton_Click(IInspectable const&, RoutedEventArgs const&) { - myButton().Content(box_value(L"Clicked")); + } } diff -r 83556205edad -r 5d71a36b833b ui/winui/window.cpp --- a/ui/winui/window.cpp Thu Oct 12 13:51:44 2023 +0200 +++ b/ui/winui/window.cpp Thu Oct 12 13:52:18 2023 +0200 @@ -62,7 +62,7 @@ //Window window = Window(); Window window = make(); - //window.ExtendsContentIntoTitleBar(true); + window.ExtendsContentIntoTitleBar(true); if (title) { wchar_t *wtitle = str2wstr(title, nullptr); window.Title(wtitle); @@ -76,6 +76,16 @@ Grid grid = Grid(); window.Content(grid); + StackPanel titleBar = StackPanel(); + Thickness titleBarPadding = { 10, 5, 5, 10 }; + titleBar.Padding(titleBarPadding); + titleBar.Orientation(Orientation::Horizontal); + TextBlock titleLabel = TextBlock(); + titleLabel.Text(hstring(L"Window Title")); + titleBar.Children().Append(titleLabel); + + window.SetTitleBar(titleBar); + obj->wobj = new UiWindow(window); @@ -86,6 +96,9 @@ obj->container = new UiBoxContainer(grid, UI_BOX_CONTAINER_VBOX, 0, 0); + titleBar.VerticalAlignment(VerticalAlignment::Top); + obj->container->Add(titleBar, false); + if (uic_get_menu_list()) { // create/add menubar MenuBar mb = ui_create_menubar(obj);