--- a/ui/winui/window.cpp Fri Oct 06 19:38:10 2023 +0200 +++ b/ui/winui/window.cpp Tue Oct 10 10:58:14 2023 +0200 @@ -26,19 +26,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "pch.h" + #include "window.h" -#include <Windows.h> -#undef GetCurrentTime -#include <winrt/Windows.Foundation.Collections.h> -#include <winrt/Windows.UI.Xaml.Interop.h> -#include <winrt/Microsoft.UI.Xaml.Controls.h> -#include <winrt/Microsoft.UI.Xaml.Controls.Primitives.h> -#include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h> -#include <winrt/Microsoft.UI.Xaml.Markup.h> -#include <winrt/Microsoft.UI.Xaml.Media.h> - #include "appmenu.h" +#include "commandbar.h" #include "container.h" #include "util.h" @@ -48,6 +41,8 @@ #include <cx/mempool.h> +#include "MainWindow.xaml.h" + using namespace winrt; using namespace Microsoft::UI::Xaml; using namespace Microsoft::UI::Xaml::Controls; @@ -58,7 +53,6 @@ UiWindow::UiWindow(winrt::Microsoft::UI::Xaml::Window& win) : window(win) {} - UiObject* ui_window(const char* title, void* window_data) { CxMempool* mp = cxBasicMempoolCreate(256); UiObject* obj = (UiObject*)cxCalloc(mp->allocator, 1, sizeof(UiObject)); @@ -66,15 +60,16 @@ obj->ctx = uic_context(obj, mp); obj->window = window_data; - Window window = Window(); + //Window window = Window(); + Window window = make<winui::implementation::MainWindow>(); if (title) { wchar_t *wtitle = str2wstr(title, nullptr); window.Title(wtitle); free(wtitle); } - auto backdrop = winrt::Microsoft::UI::Xaml::Media::MicaBackdrop(); - backdrop.Kind(winrt::Microsoft::UI::Composition::SystemBackdrops::MicaKind::Base); // alternative: BaseAlt + //auto backdrop = winrt::Microsoft::UI::Xaml::Media::MicaBackdrop(); + //backdrop.Kind(winrt::Microsoft::UI::Composition::SystemBackdrops::MicaKind::Base); // alternative: BaseAlt // TODO: https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/system-backdrop-controller#example-use-mica-in-a-windows-appsdkwinui-3-app Grid grid = Grid(); @@ -97,6 +92,13 @@ obj->container->Add(mb, false); } + if (uic_toolbar_isenabled()) { + // create/add toolbar + CommandBar toolbar = ui_create_toolbar(); + toolbar.VerticalAlignment(VerticalAlignment::Top); + obj->container->Add(toolbar, false); + } + obj->window = window_data; return obj;