ui/winui/window.cpp

branch
newapi
changeset 181
c52d88ea020b
parent 180
f34953bf4ac7
child 182
6cf690e042bd
--- a/ui/winui/window.cpp	Tue May 23 14:19:06 2023 +0200
+++ b/ui/winui/window.cpp	Mon May 29 10:37:23 2023 +0200
@@ -39,8 +39,12 @@
 
 #include "appmenu.h"
 
+#include "../common/context.h"
+
 #include <stdlib.h>
 
+#include <cx/basic_mempool.h>
+
 using namespace winrt;
 using namespace Microsoft::UI::Xaml;
 using namespace Microsoft::UI::Xaml::Controls;
@@ -49,34 +53,26 @@
 using namespace Windows::UI::Xaml::Interop;
 
 
-class UiWindow : UiWidget {
-public:
-	UiWindow(const char* title, UiObject *obj) {
-		window = Window();
+
+
+UiObject* ui_window(const char* title, void* window_data) {
+	CxMempool* mp = cxBasicMempoolCreate(256);
+	UiObject* obj = (UiObject*)cxCalloc(mp->allocator, 1, sizeof(UiObject));
+
+	obj->ctx = uic_context(obj, mp->allocator);
+	obj->window = window_data;
 
-		grid = Grid();
-		window.Content(grid);
+	obj->wobj = Window();
+	Grid grid = Grid();
+	obj->wobj.Content(grid);
 
-		if (uic_get_menu_list()) {
-			MenuBar mb = ui_create_menubar(obj);
-			mb.VerticalAlignment(VerticalAlignment::Top);
-			grid.Children().Append(mb);
-		}
+	if (uic_get_menu_list()) {
+		MenuBar mb = ui_create_menubar(obj);
+		mb.VerticalAlignment(VerticalAlignment::Top);
+		grid.Children().Append(mb);
 	}
 
-	virtual void show() {
-		window.Activate();
-	}
-
-	Window window{ nullptr };
-	Grid grid;
-};
-
-UiObject* ui_window(const char* title, void* window_data) {
-	UiObject* obj = (UiObject*)malloc(sizeof(UiObject));
-
-	UiWindow* window = new UiWindow(title, obj);
-	obj->widget = window;
+	obj->window = window_data;
 
 	return obj;
 }

mercurial