ui/winui/container.cpp

branch
newapi
changeset 374
eae5d6623fd3
parent 221
a82d9beaa94a
equal deleted inserted replaced
373:2eede3d98aba 374:eae5d6623fd3
467 this->spacing = args.spacing; 467 this->spacing = args.spacing;
468 this->columnspacing = args.columnspacing; 468 this->columnspacing = args.columnspacing;
469 this->rowspacing = args.rowspacing; 469 this->rowspacing = args.rowspacing;
470 } 470 }
471 471
472 UiObject* UiPivotTabView::AddTab(const char* label) { 472 UiObject* UiPivotTabView::AddTab(const char* label, int index) {
473 TextBlock text = TextBlock(); 473 TextBlock text = TextBlock();
474 wchar_t* wlabel = str2wstr(label, nullptr); 474 wchar_t* wlabel = str2wstr(label, nullptr);
475 winrt::hstring hstr(wlabel); 475 winrt::hstring hstr(wlabel);
476 text.Text(hstr); 476 text.Text(hstr);
477 free(wlabel); 477 free(wlabel);
483 Grid subcontainer = Grid(); 483 Grid subcontainer = Grid();
484 item.Content(subcontainer); 484 item.Content(subcontainer);
485 pivot.Items().Append(item); 485 pivot.Items().Append(item);
486 486
487 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing); 487 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
488 }
489
490 void UiPivotTabView::Remove(int index) {
491 pivot.Items().RemoveAt(index);
488 } 492 }
489 493
490 FrameworkElement UiPivotTabView::GetFrameworkElement() { 494 FrameworkElement UiPivotTabView::GetFrameworkElement() {
491 return pivot; 495 return pivot;
492 } 496 }
505 this->spacing = args.spacing; 509 this->spacing = args.spacing;
506 this->columnspacing = args.columnspacing; 510 this->columnspacing = args.columnspacing;
507 this->rowspacing = args.rowspacing; 511 this->rowspacing = args.rowspacing;
508 } 512 }
509 513
510 UiObject* UiMainTabView::AddTab(const char* label) { 514 UiObject* UiMainTabView::AddTab(const char* label, int index) {
511 TextBlock text = TextBlock(); 515 TextBlock text = TextBlock();
512 wchar_t* wlabel = str2wstr(label, nullptr); 516 wchar_t* wlabel = str2wstr(label, nullptr);
513 winrt::hstring hstr(wlabel); 517 winrt::hstring hstr(wlabel);
514 text.Text(hstr); 518 text.Text(hstr);
515 free(wlabel); 519 free(wlabel);
523 Grid subcontainer = Grid(); 527 Grid subcontainer = Grid();
524 item.Content(subcontainer); 528 item.Content(subcontainer);
525 tabview.TabItems().Append(item); 529 tabview.TabItems().Append(item);
526 530
527 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing); 531 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
532 }
533
534 void UiMainTabView::Remove(int index) {
535 this->tabview.TabItems().RemoveAt(index);
528 } 536 }
529 537
530 FrameworkElement UiMainTabView::GetFrameworkElement() { 538 FrameworkElement UiMainTabView::GetFrameworkElement() {
531 return tabview; 539 return tabview;
532 } 540 }
555 } 563 }
556 564
557 navigationview.SelectionChanged({ this, &UiNavigationTabView::SelectionChanged }); 565 navigationview.SelectionChanged({ this, &UiNavigationTabView::SelectionChanged });
558 } 566 }
559 567
560 UiObject* UiNavigationTabView::AddTab(const char* label) { 568 UiObject* UiNavigationTabView::AddTab(const char* label, int index1) {
561 TextBlock text = TextBlock(); 569 TextBlock text = TextBlock();
562 wchar_t* wlabel = str2wstr(label, nullptr); 570 wchar_t* wlabel = str2wstr(label, nullptr);
563 winrt::hstring hstr(wlabel); 571 winrt::hstring hstr(wlabel);
564 text.Text(hstr); 572 text.Text(hstr);
565 free(wlabel); 573 free(wlabel);
577 navigationview.MenuItems().Append(item); 585 navigationview.MenuItems().Append(item);
578 auto page = std::tuple<NavigationViewItem, FrameworkElement>{ item, subcontainer }; 586 auto page = std::tuple<NavigationViewItem, FrameworkElement>{ item, subcontainer };
579 pages.push_back(page); 587 pages.push_back(page);
580 588
581 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing); 589 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
590 }
591
592 void UiNavigationTabView::Remove(int index) {
593 navigationview.MenuItems().RemoveAt(index);
594 pages.erase(pages.begin() + index);
582 } 595 }
583 596
584 FrameworkElement UiNavigationTabView::GetFrameworkElement() { 597 FrameworkElement UiNavigationTabView::GetFrameworkElement() {
585 return navigationview; 598 return navigationview;
586 } 599 }
654 UiTabView* tabview = (UiTabView*)current->widget->data1; 667 UiTabView* tabview = (UiTabView*)current->widget->data1;
655 UiObject* newobj = tabview->AddTab(title); 668 UiObject* newobj = tabview->AddTab(title);
656 uic_obj_add(current, newobj); 669 uic_obj_add(current, newobj);
657 } 670 }
658 671
672 UIEXPORT void ui_tabview_select(UIWIDGET tabview, int tab) {
673 UiTabView* t = (UiTabView*)tabview->data1;
674 t->Remove(tab);
675 }
676
677 UIEXPORT void ui_tabview_remove(UIWIDGET tabview, int tab) {
678 UiTabView* t = (UiTabView*)tabview->data1;
679 t->Remove(tab);
680 }
681
682 UIEXPORT UiObject* ui_tabview_add(UIWIDGET tabview, const char *name, int tab_index) {
683 UiTabView* t = (UiTabView*)tabview->data1;
684 UiObject* newobj = t->AddTab(name, tab_index);
685 return newobj;
686 }
687
688
689
690 // --------------------- UI Headerbar ---------------------
691
692 // TODO: replace placeholder implementation
693
694 UIEXPORT UIWIDGET ui_headerbar_create(UiObject *obj, UiHeaderbarArgs args) {
695 UiContainerArgs boxargs = { };
696 boxargs.fill = UI_OFF;
697 return ui_hbox_create(obj, boxargs);
698 }
699
700 UIEXPORT void ui_headerbar_start_create(UiObject *obj) {
701 UiContainerArgs boxargs = { };
702 boxargs.fill = UI_OFF;
703 ui_hbox_create(obj, boxargs);
704 }
705
706 UIEXPORT void ui_headerbar_center_create(UiObject *obj) {
707 UiContainerArgs boxargs = { };
708 boxargs.fill = UI_OFF;
709 ui_hbox_create(obj, boxargs);
710 }
711
712 UIEXPORT void ui_headerbar_end_create(UiObject *obj) {
713 UiContainerArgs boxargs = { };
714 boxargs.fill = UI_OFF;
715 ui_hbox_create(obj, boxargs);
716 }
717
718
659 /* 719 /*
660 * -------------------- Layout Functions -------------------- 720 * -------------------- Layout Functions --------------------
661 * 721 *
662 * functions for setting layout attributes for the current container 722 * functions for setting layout attributes for the current container
663 * 723 *

mercurial