--- a/ui/winui/container.cpp Tue Oct 03 12:36:57 2023 +0200 +++ b/ui/winui/container.cpp Tue Oct 03 14:18:25 2023 +0200 @@ -487,9 +487,52 @@ return tabview; } +UiMainTabView::UiMainTabView(UiObject* obj, TabView tabview, UiTabViewArgs args) { + this->current = obj; + this->tabview = tabview; + this->margin = args.margin; + this->spacing = args.spacing; + this->columnspacing = args.columnspacing; + this->rowspacing = args.rowspacing; +} + +UiObject* UiMainTabView::AddTab(const char* label) { + TextBlock text = TextBlock(); + wchar_t* wlabel = str2wstr(label, nullptr); + winrt::hstring hstr(wlabel); + text.Text(hstr); + free(wlabel); + + TabViewItem item = TabViewItem(); + item.Header(text); + item.CanDrag(false); + item.IsClosable(false); + + // sub container + Grid subcontainer = Grid(); + item.Content(subcontainer); + tabview.TabItems().Append(item); + + return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing); +} + +FrameworkElement UiMainTabView::GetFrameworkElement() { + return tabview; +} + +static UiTabView* tabview_doc_create(UiObject* obj, UiTabViewArgs args) { + TabView tabview = TabView(); + tabview.IsAddTabButtonVisible(false); + tabview.CanDragTabs(false); + tabview.CanReorderTabs(false); + UiMainTabView* uitabview = new UiMainTabView(obj, tabview, args); + + return uitabview; +} + UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) { UiTabViewType type = args.tabview == UI_TABVIEW_DEFAULT ? UI_TABVIEW_NAVIGATION_TOP2 : args.tabview; - UiTabView *tabview = tabview_pivot_create(obj, args); + UiTabView *tabview = tabview_doc_create(obj, args); UiTabViewContainer* ctn = new UiTabViewContainer(tabview); // add frame to the parent container