ui/winui/container.cpp

branch
newapi
changeset 200
f40dadf3498f
parent 199
84e0a24bab4a
child 202
9f309d1914a2
--- a/ui/winui/container.cpp	Tue Oct 03 14:18:25 2023 +0200
+++ b/ui/winui/container.cpp	Tue Oct 03 15:32:46 2023 +0200
@@ -520,7 +520,7 @@
 	return tabview;
 }
 
-static UiTabView* tabview_doc_create(UiObject* obj, UiTabViewArgs args) {
+static UiTabView* tabview_main_create(UiObject* obj, UiTabViewArgs args) {
 	TabView tabview = TabView();
 	tabview.IsAddTabButtonVisible(false);
 	tabview.CanDragTabs(false);
@@ -530,9 +530,52 @@
 	return uitabview;
 }
 
+UiNavigationTabView::UiNavigationTabView(UiObject* obj, NavigationView NavigationView, UiTabViewArgs args, enum UiNavigationViewType type) {
+	this->current = obj;
+	this->navigationview = navigationview;
+	this->type = type;
+	this->margin = args.margin;
+	this->spacing = args.spacing;
+	this->columnspacing = args.columnspacing;
+	this->rowspacing = args.rowspacing;
+}
+
+UiObject* UiNavigationTabView::AddTab(const char* label) {
+	TextBlock text = TextBlock();
+	wchar_t* wlabel = str2wstr(label, nullptr);
+	winrt::hstring hstr(wlabel);
+	text.Text(hstr);
+	free(wlabel);
+
+	NavigationViewItem item = NavigationViewItem();
+	item.Content(text);
+
+	// sub container
+	Grid subcontainer = Grid();
+	//item.Content(subcontainer);
+	navigationview.MenuItems().Append(item);
+
+	Button b1 = Button();
+	b1.Content(box_value(L"Test"));
+	navigationview.Content(b1);
+
+	return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
+}
+
+FrameworkElement UiNavigationTabView::GetFrameworkElement() {
+	return navigationview;
+}
+
+static UiTabView* tabview_navigationview_create(UiObject* obj, UiTabViewArgs args) {
+	NavigationView navigationview = NavigationView();
+	UiNavigationTabView* tabview = new UiNavigationTabView(obj, navigationview, args, UI_NAVIGATIONVIEW_SIDE);
+
+	return tabview;
+}
+
 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) {
 	UiTabViewType type = args.tabview == UI_TABVIEW_DEFAULT ? UI_TABVIEW_NAVIGATION_TOP2 : args.tabview;
-	UiTabView *tabview = tabview_doc_create(obj, args);
+	UiTabView *tabview = tabview_navigationview_create(obj, args);
 	UiTabViewContainer* ctn = new UiTabViewContainer(tabview);
 
 	// add frame to the parent container

mercurial