--- a/ui/winui/container.cpp Wed Oct 30 11:07:52 2024 +0100 +++ b/ui/winui/container.cpp Wed Oct 30 12:23:52 2024 +0100 @@ -469,7 +469,7 @@ this->rowspacing = args.rowspacing; } -UiObject* UiPivotTabView::AddTab(const char* label) { +UiObject* UiPivotTabView::AddTab(const char* label, int index) { TextBlock text = TextBlock(); wchar_t* wlabel = str2wstr(label, nullptr); winrt::hstring hstr(wlabel); @@ -487,6 +487,10 @@ return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing); } +void UiPivotTabView::Remove(int index) { + pivot.Items().RemoveAt(index); +} + FrameworkElement UiPivotTabView::GetFrameworkElement() { return pivot; } @@ -507,7 +511,7 @@ this->rowspacing = args.rowspacing; } -UiObject* UiMainTabView::AddTab(const char* label) { +UiObject* UiMainTabView::AddTab(const char* label, int index) { TextBlock text = TextBlock(); wchar_t* wlabel = str2wstr(label, nullptr); winrt::hstring hstr(wlabel); @@ -527,6 +531,10 @@ return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing); } +void UiMainTabView::Remove(int index) { + this->tabview.TabItems().RemoveAt(index); +} + FrameworkElement UiMainTabView::GetFrameworkElement() { return tabview; } @@ -557,7 +565,7 @@ navigationview.SelectionChanged({ this, &UiNavigationTabView::SelectionChanged }); } -UiObject* UiNavigationTabView::AddTab(const char* label) { +UiObject* UiNavigationTabView::AddTab(const char* label, int index1) { TextBlock text = TextBlock(); wchar_t* wlabel = str2wstr(label, nullptr); winrt::hstring hstr(wlabel); @@ -581,6 +589,11 @@ return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing); } +void UiNavigationTabView::Remove(int index) { + navigationview.MenuItems().RemoveAt(index); + pages.erase(pages.begin() + index); +} + FrameworkElement UiNavigationTabView::GetFrameworkElement() { return navigationview; } @@ -656,6 +669,53 @@ uic_obj_add(current, newobj); } +UIEXPORT void ui_tabview_select(UIWIDGET tabview, int tab) { + UiTabView* t = (UiTabView*)tabview->data1; + t->Remove(tab); +} + +UIEXPORT void ui_tabview_remove(UIWIDGET tabview, int tab) { + UiTabView* t = (UiTabView*)tabview->data1; + t->Remove(tab); +} + +UIEXPORT UiObject* ui_tabview_add(UIWIDGET tabview, const char *name, int tab_index) { + UiTabView* t = (UiTabView*)tabview->data1; + UiObject* newobj = t->AddTab(name, tab_index); + return newobj; +} + + + +// --------------------- UI Headerbar --------------------- + +// TODO: replace placeholder implementation + +UIEXPORT UIWIDGET ui_headerbar_create(UiObject *obj, UiHeaderbarArgs args) { + UiContainerArgs boxargs = { }; + boxargs.fill = UI_OFF; + return ui_hbox_create(obj, boxargs); +} + +UIEXPORT void ui_headerbar_start_create(UiObject *obj) { + UiContainerArgs boxargs = { }; + boxargs.fill = UI_OFF; + ui_hbox_create(obj, boxargs); +} + +UIEXPORT void ui_headerbar_center_create(UiObject *obj) { + UiContainerArgs boxargs = { }; + boxargs.fill = UI_OFF; + ui_hbox_create(obj, boxargs); +} + +UIEXPORT void ui_headerbar_end_create(UiObject *obj) { + UiContainerArgs boxargs = { }; + boxargs.fill = UI_OFF; + ui_hbox_create(obj, boxargs); +} + + /* * -------------------- Layout Functions -------------------- *