528 UiMainTabView* uitabview = new UiMainTabView(obj, tabview, args); |
528 UiMainTabView* uitabview = new UiMainTabView(obj, tabview, args); |
529 |
529 |
530 return uitabview; |
530 return uitabview; |
531 } |
531 } |
532 |
532 |
533 UiNavigationTabView::UiNavigationTabView(UiObject* obj, NavigationView NavigationView, UiTabViewArgs args, enum UiNavigationViewType type) { |
533 UiNavigationTabView::UiNavigationTabView(UiObject* obj, NavigationView navigationview, UiTabViewArgs args, UiTabViewType type) { |
534 this->current = obj; |
534 this->current = obj; |
535 this->navigationview = navigationview; |
535 this->navigationview = navigationview; |
536 this->type = type; |
536 this->type = type; |
537 this->margin = args.margin; |
537 this->margin = args.margin; |
538 this->spacing = args.spacing; |
538 this->spacing = args.spacing; |
539 this->columnspacing = args.columnspacing; |
539 this->columnspacing = args.columnspacing; |
540 this->rowspacing = args.rowspacing; |
540 this->rowspacing = args.rowspacing; |
|
541 |
|
542 if (type == UI_TABVIEW_NAVIGATION_TOP) { |
|
543 navigationview.PaneDisplayMode(NavigationViewPaneDisplayMode::Top); |
|
544 } |
|
545 |
|
546 navigationview.SelectionChanged({ this, &UiNavigationTabView::SelectionChanged }); |
541 } |
547 } |
542 |
548 |
543 UiObject* UiNavigationTabView::AddTab(const char* label) { |
549 UiObject* UiNavigationTabView::AddTab(const char* label) { |
544 TextBlock text = TextBlock(); |
550 TextBlock text = TextBlock(); |
545 wchar_t* wlabel = str2wstr(label, nullptr); |
551 wchar_t* wlabel = str2wstr(label, nullptr); |
550 NavigationViewItem item = NavigationViewItem(); |
556 NavigationViewItem item = NavigationViewItem(); |
551 item.Content(text); |
557 item.Content(text); |
552 |
558 |
553 // sub container |
559 // sub container |
554 Grid subcontainer = Grid(); |
560 Grid subcontainer = Grid(); |
555 //item.Content(subcontainer); |
561 if (pages.size() == 0) { |
|
562 navigationview.Content(subcontainer); |
|
563 navigationview.SelectedItem(item); |
|
564 } |
|
565 |
556 navigationview.MenuItems().Append(item); |
566 navigationview.MenuItems().Append(item); |
557 |
567 auto page = std::tuple<NavigationViewItem, FrameworkElement>{ item, subcontainer }; |
558 Button b1 = Button(); |
568 pages.push_back(page); |
559 b1.Content(box_value(L"Test")); |
|
560 navigationview.Content(b1); |
|
561 |
569 |
562 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing); |
570 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing); |
563 } |
571 } |
564 |
572 |
565 FrameworkElement UiNavigationTabView::GetFrameworkElement() { |
573 FrameworkElement UiNavigationTabView::GetFrameworkElement() { |
566 return navigationview; |
574 return navigationview; |
567 } |
575 } |
568 |
576 |
569 static UiTabView* tabview_navigationview_create(UiObject* obj, UiTabViewArgs args) { |
577 void UiNavigationTabView::SelectionChanged(NavigationView const& sender, NavigationViewSelectionChangedEventArgs const& args) { |
|
578 for (auto page : pages) { |
|
579 NavigationViewItem item = std::get<0>(page); |
|
580 FrameworkElement elm = std::get<1>(page); |
|
581 if (item == navigationview.SelectedItem()) { |
|
582 navigationview.Content(elm); |
|
583 break; |
|
584 } |
|
585 } |
|
586 } |
|
587 |
|
588 static UiTabView* tabview_navigationview_create(UiObject* obj, UiTabViewArgs args, UiTabViewType type) { |
570 NavigationView navigationview = NavigationView(); |
589 NavigationView navigationview = NavigationView(); |
571 UiNavigationTabView* tabview = new UiNavigationTabView(obj, navigationview, args, UI_NAVIGATIONVIEW_SIDE); |
590 UiNavigationTabView* tabview = new UiNavigationTabView(obj, navigationview, args, type); |
|
591 navigationview.IsBackButtonVisible(NavigationViewBackButtonVisible::Collapsed); |
|
592 navigationview.IsSettingsVisible(false); |
572 |
593 |
573 return tabview; |
594 return tabview; |
574 } |
595 } |
575 |
596 |
576 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) { |
597 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) { |
577 UiTabViewType type = args.tabview == UI_TABVIEW_DEFAULT ? UI_TABVIEW_NAVIGATION_TOP2 : args.tabview; |
598 UiTabViewType type = args.tabview == UI_TABVIEW_DEFAULT ? UI_TABVIEW_NAVIGATION_TOP2 : args.tabview; |
578 UiTabView *tabview = tabview_navigationview_create(obj, args); |
599 UiTabView* tabview = nullptr; |
|
600 switch (type) { |
|
601 default: { |
|
602 tabview = tabview_pivot_create(obj, args); |
|
603 break; |
|
604 } |
|
605 case UI_TABVIEW_DOC: { |
|
606 tabview = tabview_main_create(obj, args); |
|
607 break; |
|
608 } |
|
609 case UI_TABVIEW_NAVIGATION_SIDE: { |
|
610 tabview = tabview_navigationview_create(obj, args, type); |
|
611 break; |
|
612 } |
|
613 case UI_TABVIEW_NAVIGATION_TOP: { |
|
614 tabview = tabview_navigationview_create(obj, args, type); |
|
615 break; |
|
616 } |
|
617 case UI_TABVIEW_NAVIGATION_TOP2: { |
|
618 tabview = tabview_pivot_create(obj, args); |
|
619 break; |
|
620 } |
|
621 } |
579 UiTabViewContainer* ctn = new UiTabViewContainer(tabview); |
622 UiTabViewContainer* ctn = new UiTabViewContainer(tabview); |
580 |
623 |
581 // add frame to the parent container |
624 // add frame to the parent container |
582 UiObject* current = uic_current_obj(obj); |
625 UiObject* current = uic_current_obj(obj); |
583 UI_APPLY_LAYOUT1(current, args); |
626 UI_APPLY_LAYOUT1(current, args); |