ui/winui/container.cpp

changeset 108
77254bd6dccb
parent 103
6606616eca9f
equal deleted inserted replaced
107:b34bd1557c6c 108:77254bd6dccb
32 32
33 #include "../common/context.h" 33 #include "../common/context.h"
34 #include "../common/object.h" 34 #include "../common/object.h"
35 35
36 #include "util.h" 36 #include "util.h"
37 #include "../ui/widget.h"
37 38
38 39
39 void ui_container_begin_close(UiObject* obj) { 40 void ui_container_begin_close(UiObject* obj) {
40 UiContainer* ct = uic_get_current_container(obj); 41 UiContainer* ct = uic_get_current_container(obj);
41 ct->close = 1; 42 ct->close = 1;
49 } 50 }
50 return 1; 51 return 1;
51 } 52 }
52 53
53 54
54 UIEXPORT UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs args) { 55 UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs *args) {
55 UiObject* current = uic_current_obj(obj); 56 UiObject* current = uic_current_obj(obj);
56 57
57 UIWIDGET widget = create_widget(obj, args, userdata); 58 UIWIDGET widget = create_widget(obj, args, userdata);
58 FrameworkElement w = widget->uielement.as<FrameworkElement>(); 59 FrameworkElement w = widget->uielement.as<FrameworkElement>();
59 60
60 UI_APPLY_LAYOUT1(current, args); 61 UI_APPLY_LAYOUT2(current, args);
61 62
62 current->container->Add(w, false); 63 current->container->Add(w, false);
63 64
64 return widget; 65 return widget;
65 } 66 }
66 67
67 // --------------------- UiBoxContainer --------------------- 68 // --------------------- UiBoxContainer ---------------------
68 69
69 static UIWIDGET ui_box(UiObject* obj, UiContainerArgs args, UiBoxContainerType type) { 70 static UIWIDGET ui_box(UiObject* obj, UiContainerArgs *args, UiBoxContainerType type) {
70 UiObject* current = uic_current_obj(obj); 71 UiObject* current = uic_current_obj(obj);
71 UI_APPLY_LAYOUT1(current, args); 72 UI_APPLY_LAYOUT2(current, args);
72 73
73 Grid grid = Grid(); 74 Grid grid = Grid();
74 current->container->Add(grid, true); 75 current->container->Add(grid, true);
75 76
76 UIElement elm = grid; 77 UIElement elm = grid;
77 UiWidget* widget = new UiWidget(elm); 78 UiWidget* widget = new UiWidget(elm);
78 ui_context_add_widget_destructor(current->ctx, widget); 79 ui_context_add_widget_destructor(current->ctx, widget);
79 80
80 UiObject* newobj = uic_object_new(obj, widget); 81 UiObject* newobj = uic_object_new(obj, widget);
81 newobj->container = new UiBoxContainer(grid, type, args.margin, args.spacing); 82 newobj->container = new UiBoxContainer(grid, type, args->margin, args->spacing);
82 ui_context_add_container_destructor(current->ctx, newobj->container); 83 ui_context_add_container_destructor(current->ctx, newobj->container);
83 uic_obj_add(obj, newobj); 84 uic_obj_add(obj, newobj);
84 85
85 return widget; 86 return widget;
86 } 87 }
87 88
88 UIWIDGET ui_vbox_create(UiObject* obj, UiContainerArgs args) { 89 UIWIDGET ui_vbox_create(UiObject* obj, UiContainerArgs *args) {
89 return ui_box(obj, args, UI_BOX_CONTAINER_VBOX); 90 return ui_box(obj, args, UI_BOX_CONTAINER_VBOX);
90 } 91 }
91 92
92 UIWIDGET ui_hbox_create(UiObject* obj, UiContainerArgs args) { 93 UIWIDGET ui_hbox_create(UiObject* obj, UiContainerArgs *args) {
93 return ui_box(obj, args, UI_BOX_CONTAINER_HBOX); 94 return ui_box(obj, args, UI_BOX_CONTAINER_HBOX);
94 } 95 }
95 96
96 UiBoxContainer::UiBoxContainer(Grid grid, enum UiBoxContainerType type, int margin, int spacing) { 97 UiBoxContainer::UiBoxContainer(Grid grid, enum UiBoxContainerType type, int margin, int spacing) {
97 this->grid = grid; 98 this->grid = grid;
159 } 160 }
160 161
161 162
162 // --------------------- UiGridContainer --------------------- 163 // --------------------- UiGridContainer ---------------------
163 164
164 UIWIDGET ui_grid_create(UiObject* obj, UiContainerArgs args) { 165 UIWIDGET ui_grid_create(UiObject* obj, UiContainerArgs *args) {
165 UiObject* current = uic_current_obj(obj); 166 UiObject* current = uic_current_obj(obj);
166 UI_APPLY_LAYOUT1(current, args); 167 UI_APPLY_LAYOUT2(current, args);
167 168
168 Grid grid = Grid(); 169 Grid grid = Grid();
169 current->container->Add(grid, true); 170 current->container->Add(grid, true);
170 171
171 UIElement elm = grid; 172 UIElement elm = grid;
172 UiWidget* widget = new UiWidget(elm); 173 UiWidget* widget = new UiWidget(elm);
173 ui_context_add_widget_destructor(current->ctx, widget); 174 ui_context_add_widget_destructor(current->ctx, widget);
174 175
175 UiObject* newobj = uic_object_new(obj, widget); 176 UiObject* newobj = uic_object_new(obj, widget);
176 newobj->container = new UiGridContainer(grid, args.margin, args.columnspacing, args.rowspacing); 177 newobj->container = new UiGridContainer(grid, args->margin, args->columnspacing, args->rowspacing);
177 ui_context_add_container_destructor(current->ctx, newobj->container); 178 ui_context_add_container_destructor(current->ctx, newobj->container);
178 uic_obj_add(obj, newobj); 179 uic_obj_add(obj, newobj);
179 180
180 return widget; 181 return widget;
181 } 182 }
301 ui_reset_layout(layout); 302 ui_reset_layout(layout);
302 } 303 }
303 304
304 // --------------------- UI Frame --------------------- 305 // --------------------- UI Frame ---------------------
305 306
306 UIWIDGET ui_frame_create(UiObject* obj, UiFrameArgs args) { 307 UIWIDGET ui_frame_create(UiObject* obj, UiFrameArgs *args) {
307 // create a grid for the frame, that contains the label and a sub-frame 308 // create a grid for the frame, that contains the label and a sub-frame
308 Grid frame = Grid(); 309 Grid frame = Grid();
309 310
310 GridLength gl; 311 GridLength gl;
311 gl.GridUnitType = GridUnitType::Star; 312 gl.GridUnitType = GridUnitType::Star;
318 RowDefinition rowdefFrame = RowDefinition(); 319 RowDefinition rowdefFrame = RowDefinition();
319 rowdefFrame.Height(gl); 320 rowdefFrame.Height(gl);
320 321
321 // label 322 // label
322 int row = 0; 323 int row = 0;
323 if (args.label) { 324 if (args->label) {
324 RowDefinition rowdefLabel = RowDefinition(); 325 RowDefinition rowdefLabel = RowDefinition();
325 gl.GridUnitType = GridUnitType::Auto; 326 gl.GridUnitType = GridUnitType::Auto;
326 gl.Value = 0; 327 gl.Value = 0;
327 rowdefLabel.Height(gl); 328 rowdefLabel.Height(gl);
328 frame.RowDefinitions().Append(rowdefLabel); 329 frame.RowDefinitions().Append(rowdefLabel);
329 330
330 TextBlock label = TextBlock(); 331 TextBlock label = TextBlock();
331 wchar_t* wlabel = str2wstr(args.label, nullptr); 332 wchar_t* wlabel = str2wstr(args->label, nullptr);
332 winrt::hstring hstr(wlabel); 333 winrt::hstring hstr(wlabel);
333 label.Text(hstr); 334 label.Text(hstr);
334 free(wlabel); 335 free(wlabel);
335 336
336 frame.SetRow(label, row++); 337 frame.SetRow(label, row++);
357 Thickness padding = { 10, 10, 10, 10 }; 358 Thickness padding = { 10, 10, 10, 10 };
358 workarea.Padding(padding); 359 workarea.Padding(padding);
359 360
360 // add frame to the parent container 361 // add frame to the parent container
361 UiObject* current = uic_current_obj(obj); 362 UiObject* current = uic_current_obj(obj);
362 UI_APPLY_LAYOUT1(current, args); 363 UI_APPLY_LAYOUT2(current, args);
363 current->container->Add(frame, true); 364 current->container->Add(frame, true);
364 365
365 UIElement elm = frame; 366 UIElement elm = frame;
366 UiWidget* widget = new UiWidget(elm); 367 UiWidget* widget = new UiWidget(elm);
367 ui_context_add_widget_destructor(current->ctx, widget); 368 ui_context_add_widget_destructor(current->ctx, widget);
368 369
369 // sub container 370 // sub container
370 UiContainer* ctn = nullptr; 371 UiContainer* ctn = nullptr;
371 switch (args.subcontainer) { 372 switch (args->subcontainer) {
372 default: 373 default:
373 case UI_CONTAINER_VBOX: { 374 case UI_CONTAINER_VBOX: {
374 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing); 375 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_VBOX, args->margin, args->spacing);
375 break; 376 break;
376 } 377 }
377 case UI_CONTAINER_HBOX: { 378 case UI_CONTAINER_HBOX: {
378 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing); 379 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_HBOX, args->margin, args->spacing);
379 break; 380 break;
380 } 381 }
381 case UI_CONTAINER_GRID: { 382 case UI_CONTAINER_GRID: {
382 ctn = new UiGridContainer(workarea, args.margin, args.columnspacing, args.rowspacing); 383 ctn = new UiGridContainer(workarea, args->margin, args->columnspacing, args->rowspacing);
383 break; 384 break;
384 } 385 }
385 } 386 }
386 ui_context_add_container_destructor(current->ctx, ctn); 387 ui_context_add_container_destructor(current->ctx, ctn);
387 388
392 return widget; 393 return widget;
393 } 394 }
394 395
395 // --------------------- UI Expander --------------------- 396 // --------------------- UI Expander ---------------------
396 397
397 UIWIDGET ui_expander_create(UiObject* obj, UiFrameArgs args) { 398 UIWIDGET ui_expander_create(UiObject* obj, UiFrameArgs *args) {
398 Expander expander = Expander(); 399 Expander expander = Expander();
399 if (args.label) { 400 if (args->label) {
400 wchar_t* wlabel = str2wstr(args.label, nullptr); 401 wchar_t* wlabel = str2wstr(args->label, nullptr);
401 expander.Header(box_value(wlabel)); 402 expander.Header(box_value(wlabel));
402 free(wlabel); 403 free(wlabel);
403 } 404 }
404 expander.IsExpanded(args.isexpanded); 405 expander.IsExpanded(args->isexpanded);
405 406
406 // add frame to the parent container 407 // add frame to the parent container
407 UiObject* current = uic_current_obj(obj); 408 UiObject* current = uic_current_obj(obj);
408 UI_APPLY_LAYOUT1(current, args); 409 UI_APPLY_LAYOUT2(current, args);
409 current->container->Add(expander, true); 410 current->container->Add(expander, true);
410 411
411 UIElement elm = expander; 412 UIElement elm = expander;
412 UiWidget* widget = new UiWidget(elm); 413 UiWidget* widget = new UiWidget(elm);
413 ui_context_add_widget_destructor(current->ctx, widget); 414 ui_context_add_widget_destructor(current->ctx, widget);
414 415
415 Grid content = Grid(); 416 Grid content = Grid();
416 expander.Content(content); 417 expander.Content(content);
417 418
418 UiContainer* ctn = nullptr; 419 UiContainer* ctn = nullptr;
419 switch (args.subcontainer) { 420 switch (args->subcontainer) {
420 default: 421 default:
421 case UI_CONTAINER_VBOX: { 422 case UI_CONTAINER_VBOX: {
422 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing); 423 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_VBOX, args->margin, args->spacing);
423 break; 424 break;
424 } 425 }
425 case UI_CONTAINER_HBOX: { 426 case UI_CONTAINER_HBOX: {
426 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing); 427 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_HBOX, args->margin, args->spacing);
427 break; 428 break;
428 } 429 }
429 case UI_CONTAINER_GRID: { 430 case UI_CONTAINER_GRID: {
430 ctn = new UiGridContainer(content, args.margin, args.columnspacing, args.rowspacing); 431 ctn = new UiGridContainer(content, args->margin, args->columnspacing, args->rowspacing);
431 break; 432 break;
432 } 433 }
433 } 434 }
434 ui_context_add_container_destructor(current->ctx, ctn); 435 ui_context_add_container_destructor(current->ctx, ctn);
435 436
440 return widget; 441 return widget;
441 } 442 }
442 443
443 // --------------------- UI ScrolledWindow --------------------- 444 // --------------------- UI ScrolledWindow ---------------------
444 445
445 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) { 446 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs *args) {
446 ScrollViewer scrollW = ScrollViewer(); 447 ScrollViewer scrollW = ScrollViewer();
447 448
448 // add frame to the parent container 449 // add frame to the parent container
449 UiObject* current = uic_current_obj(obj); 450 UiObject* current = uic_current_obj(obj);
450 UI_APPLY_LAYOUT1(current, args); 451 UI_APPLY_LAYOUT2(current, args);
451 current->container->Add(scrollW, true); 452 current->container->Add(scrollW, true);
452 453
453 UIElement elm = scrollW; 454 UIElement elm = scrollW;
454 UiWidget* widget = new UiWidget(elm); 455 UiWidget* widget = new UiWidget(elm);
455 ui_context_add_widget_destructor(current->ctx, widget); 456 ui_context_add_widget_destructor(current->ctx, widget);
457 // create child container 458 // create child container
458 Grid content = Grid(); 459 Grid content = Grid();
459 scrollW.Content(content); 460 scrollW.Content(content);
460 461
461 UiContainer* ctn = nullptr; 462 UiContainer* ctn = nullptr;
462 switch (args.subcontainer) { 463 switch (args->subcontainer) {
463 default: 464 default:
464 case UI_CONTAINER_VBOX: { 465 case UI_CONTAINER_VBOX: {
465 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing); 466 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_VBOX, args->margin, args->spacing);
466 break; 467 break;
467 } 468 }
468 case UI_CONTAINER_HBOX: { 469 case UI_CONTAINER_HBOX: {
469 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing); 470 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_HBOX, args->margin, args->spacing);
470 break; 471 break;
471 } 472 }
472 case UI_CONTAINER_GRID: { 473 case UI_CONTAINER_GRID: {
473 ctn = new UiGridContainer(content, args.margin, args.columnspacing, args.rowspacing); 474 ctn = new UiGridContainer(content, args->margin, args->columnspacing, args->rowspacing);
474 break; 475 break;
475 } 476 }
476 } 477 }
477 ui_context_add_container_destructor(current->ctx, ctn); 478 ui_context_add_container_destructor(current->ctx, ctn);
478 479
518 UiObject* newobj = uic_object_new(current, widget); 519 UiObject* newobj = uic_object_new(current, widget);
519 newobj->container = ctn; 520 newobj->container = ctn;
520 return newobj; 521 return newobj;
521 } 522 }
522 523
523 static UiTabView* tabview_pivot_create(UiObject* obj, UiTabViewArgs args) { 524 static UiTabView* tabview_pivot_create(UiObject* obj, UiTabViewArgs *args) {
524 Pivot pivot = Pivot(); 525 Pivot pivot = Pivot();
525 UiPivotTabView* tabview = new UiPivotTabView(obj, pivot, args); 526 UiPivotTabView* tabview = new UiPivotTabView(obj, pivot, args);
526 527
527 return tabview; 528 return tabview;
528 } 529 }
529 530
530 UiPivotTabView::UiPivotTabView(UiObject* obj, Pivot pivot, UiTabViewArgs args) { 531 UiPivotTabView::UiPivotTabView(UiObject* obj, Pivot pivot, UiTabViewArgs *args) {
531 this->current = obj; 532 this->current = obj;
532 this->pivot = pivot; 533 this->pivot = pivot;
533 this->subcontainer = args.subcontainer; 534 this->subcontainer = args->subcontainer;
534 this->margin = args.margin; 535 this->margin = args->margin;
535 this->spacing = args.spacing; 536 this->spacing = args->spacing;
536 this->columnspacing = args.columnspacing; 537 this->columnspacing = args->columnspacing;
537 this->rowspacing = args.rowspacing; 538 this->rowspacing = args->rowspacing;
538 } 539 }
539 540
540 UiObject* UiPivotTabView::AddTab(const char* label, int index) { 541 UiObject* UiPivotTabView::AddTab(const char* label, int index) {
541 TextBlock text = TextBlock(); 542 TextBlock text = TextBlock();
542 wchar_t* wlabel = str2wstr(label, nullptr); 543 wchar_t* wlabel = str2wstr(label, nullptr);
566 FrameworkElement UiPivotTabView::GetFrameworkElement() { 567 FrameworkElement UiPivotTabView::GetFrameworkElement() {
567 return pivot; 568 return pivot;
568 } 569 }
569 570
570 571
571 static UiTabView* tabview_invisible_create(UiObject *obj, UiTabViewArgs args) { 572 static UiTabView* tabview_invisible_create(UiObject *obj, UiTabViewArgs *args) {
572 Grid container = Grid(); 573 Grid container = Grid();
573 container.HorizontalAlignment(HorizontalAlignment::Stretch); 574 container.HorizontalAlignment(HorizontalAlignment::Stretch);
574 container.VerticalAlignment(VerticalAlignment::Stretch); 575 container.VerticalAlignment(VerticalAlignment::Stretch);
575 UiInvisibleTabView *tabview = new UiInvisibleTabView(obj, container, args); 576 UiInvisibleTabView *tabview = new UiInvisibleTabView(obj, container, args);
576 return tabview; 577 return tabview;
577 } 578 }
578 579
579 UiInvisibleTabView::UiInvisibleTabView(UiObject* obj, Grid container, UiTabViewArgs args) { 580 UiInvisibleTabView::UiInvisibleTabView(UiObject* obj, Grid container, UiTabViewArgs *args) {
580 this->current = obj; 581 this->current = obj;
581 this->container = container; 582 this->container = container;
582 this->subcontainer = args.subcontainer; 583 this->subcontainer = args->subcontainer;
583 this->margin = args.margin; 584 this->margin = args->margin;
584 this->spacing = args.spacing; 585 this->spacing = args->spacing;
585 this->columnspacing = args.columnspacing; 586 this->columnspacing = args->columnspacing;
586 this->rowspacing = args.rowspacing; 587 this->rowspacing = args->rowspacing;
587 this->currentIndex = -1; 588 this->currentIndex = -1;
588 589
589 GridLength gl; 590 GridLength gl;
590 gl.GridUnitType = GridUnitType::Star; 591 gl.GridUnitType = GridUnitType::Star;
591 gl.Value = 1; 592 gl.Value = 1;
636 FrameworkElement UiInvisibleTabView::GetFrameworkElement() { 637 FrameworkElement UiInvisibleTabView::GetFrameworkElement() {
637 return container; 638 return container;
638 } 639 }
639 640
640 641
641 static UiTabView* tabview_main_create(UiObject* obj, UiTabViewArgs args) { 642 static UiTabView* tabview_main_create(UiObject* obj, UiTabViewArgs *args) {
642 TabView tabview = TabView(); 643 TabView tabview = TabView();
643 tabview.IsAddTabButtonVisible(false); 644 tabview.IsAddTabButtonVisible(false);
644 //tabview.CanDragTabs(false); 645 //tabview.CanDragTabs(false);
645 //tabview.CanReorderTabs(false); 646 //tabview.CanReorderTabs(false);
646 UiMainTabView* uitabview = new UiMainTabView(obj, tabview, args); 647 UiMainTabView* uitabview = new UiMainTabView(obj, tabview, args);
647 648
648 return uitabview; 649 return uitabview;
649 } 650 }
650 651
651 UiMainTabView::UiMainTabView(UiObject* obj, TabView tabview, UiTabViewArgs args) { 652 UiMainTabView::UiMainTabView(UiObject* obj, TabView tabview, UiTabViewArgs *args) {
652 this->current = obj; 653 this->current = obj;
653 this->tabview = tabview; 654 this->tabview = tabview;
654 this->subcontainer = args.subcontainer; 655 this->subcontainer = args->subcontainer;
655 this->margin = args.margin; 656 this->margin = args->margin;
656 this->spacing = args.spacing; 657 this->spacing = args->spacing;
657 this->columnspacing = args.columnspacing; 658 this->columnspacing = args->columnspacing;
658 this->rowspacing = args.rowspacing; 659 this->rowspacing = args->rowspacing;
659 } 660 }
660 661
661 UiObject* UiMainTabView::AddTab(const char* label, int index) { 662 UiObject* UiMainTabView::AddTab(const char* label, int index) {
662 TextBlock text = TextBlock(); 663 TextBlock text = TextBlock();
663 wchar_t* wlabel = str2wstr(label, nullptr); 664 wchar_t* wlabel = str2wstr(label, nullptr);
689 FrameworkElement UiMainTabView::GetFrameworkElement() { 690 FrameworkElement UiMainTabView::GetFrameworkElement() {
690 return tabview; 691 return tabview;
691 } 692 }
692 693
693 694
694 static UiTabView* tabview_navigationview_create(UiObject* obj, UiTabViewArgs args, UiTabViewType type) { 695 static UiTabView* tabview_navigationview_create(UiObject* obj, UiTabViewArgs *args, UiTabViewType type) {
695 NavigationView navigationview = NavigationView(); 696 NavigationView navigationview = NavigationView();
696 UiNavigationTabView* tabview = new UiNavigationTabView(obj, navigationview, args, type); 697 UiNavigationTabView* tabview = new UiNavigationTabView(obj, navigationview, args, type);
697 navigationview.IsBackButtonVisible(NavigationViewBackButtonVisible::Collapsed); 698 navigationview.IsBackButtonVisible(NavigationViewBackButtonVisible::Collapsed);
698 navigationview.IsSettingsVisible(false); 699 navigationview.IsSettingsVisible(false);
699 700
700 return tabview; 701 return tabview;
701 } 702 }
702 703
703 UiNavigationTabView::UiNavigationTabView(UiObject* obj, NavigationView navigationview, UiTabViewArgs args, UiTabViewType type) { 704 UiNavigationTabView::UiNavigationTabView(UiObject* obj, NavigationView navigationview, UiTabViewArgs *args, UiTabViewType type) {
704 this->current = obj; 705 this->current = obj;
705 this->navigationview = navigationview; 706 this->navigationview = navigationview;
706 this->type = type; 707 this->type = type;
707 this->margin = args.margin; 708 this->margin = args->margin;
708 this->spacing = args.spacing; 709 this->spacing = args->spacing;
709 this->columnspacing = args.columnspacing; 710 this->columnspacing = args->columnspacing;
710 this->rowspacing = args.rowspacing; 711 this->rowspacing = args->rowspacing;
711 712
712 if (type == UI_TABVIEW_NAVIGATION_TOP) { 713 if (type == UI_TABVIEW_NAVIGATION_TOP) {
713 navigationview.PaneDisplayMode(NavigationViewPaneDisplayMode::Top); 714 navigationview.PaneDisplayMode(NavigationViewPaneDisplayMode::Top);
714 } 715 }
715 716
771 static void ui_tabview_set(UiInteger *i, int64_t value) { 772 static void ui_tabview_set(UiInteger *i, int64_t value) {
772 UiTabView *tabview = (UiTabView*)i->obj; 773 UiTabView *tabview = (UiTabView*)i->obj;
773 tabview->Select(value); 774 tabview->Select(value);
774 } 775 }
775 776
776 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) { 777 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs *args) {
777 UiTabViewType type = args.tabview == UI_TABVIEW_DEFAULT ? UI_TABVIEW_NAVIGATION_TOP2 : args.tabview; 778 UiTabViewType type = args->tabview == UI_TABVIEW_DEFAULT ? UI_TABVIEW_NAVIGATION_TOP2 : args->tabview;
778 UiTabView* tabview = nullptr; 779 UiTabView* tabview = nullptr;
779 switch (type) { 780 switch (type) {
780 default: { 781 default: {
781 tabview = tabview_pivot_create(obj, args); 782 tabview = tabview_pivot_create(obj, args);
782 break; 783 break;
804 } 805 }
805 UiTabViewContainer* ctn = new UiTabViewContainer(tabview); 806 UiTabViewContainer* ctn = new UiTabViewContainer(tabview);
806 807
807 // add frame to the parent container 808 // add frame to the parent container
808 UiObject* current = uic_current_obj(obj); 809 UiObject* current = uic_current_obj(obj);
809 UI_APPLY_LAYOUT1(current, args); 810 UI_APPLY_LAYOUT2(current, args);
810 current->container->Add(tabview->GetFrameworkElement(), true); 811 current->container->Add(tabview->GetFrameworkElement(), true);
811 812
812 UIElement elm = tabview->GetFrameworkElement(); 813 UIElement elm = tabview->GetFrameworkElement();
813 UiWidget* widget = new UiWidget(elm); 814 UiWidget* widget = new UiWidget(elm);
814 ui_context_add_widget_destructor(current->ctx, widget); 815 ui_context_add_widget_destructor(current->ctx, widget);
815 widget->data1 = tabview; 816 widget->data1 = tabview;
816 817
817 // TODO: add tabview destructor 818 // TODO: add tabview destructor
818 819
819 // bind variable 820 // bind variable
820 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_INTEGER); 821 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args->value, args->varname, UI_VAR_INTEGER);
821 if (var) { 822 if (var) {
822 UiInteger *i = (UiInteger*)var->value; 823 UiInteger *i = (UiInteger*)var->value;
823 i->obj = tabview; 824 i->obj = tabview;
824 i->get = ui_tabview_get; 825 i->get = ui_tabview_get;
825 i->set = ui_tabview_set; 826 i->set = ui_tabview_set;
859 860
860 // --------------------- UI Headerbar --------------------- 861 // --------------------- UI Headerbar ---------------------
861 862
862 // TODO: replace placeholder implementation 863 // TODO: replace placeholder implementation
863 864
864 UIEXPORT UIWIDGET ui_headerbar_create(UiObject *obj, UiHeaderbarArgs args) { 865 UIEXPORT UIWIDGET ui_headerbar_create(UiObject *obj, UiHeaderbarArgs *args) {
865 UiContainerArgs boxargs = { }; 866 UiContainerArgs boxargs = { };
866 boxargs.fill = UI_OFF; 867 boxargs.fill = UI_OFF;
867 return ui_hbox_create(obj, boxargs); 868 return ui_hbox_create(obj, &boxargs);
868 } 869 }
869 870
870 UIEXPORT void ui_headerbar_start_create(UiObject *obj) { 871 UIEXPORT void ui_headerbar_start_create(UiObject *obj) {
871 UiContainerArgs boxargs = { }; 872 UiContainerArgs boxargs = { };
872 boxargs.fill = UI_OFF; 873 boxargs.fill = UI_OFF;
873 ui_hbox_create(obj, boxargs); 874 ui_hbox_create(obj, &boxargs);
874 } 875 }
875 876
876 UIEXPORT void ui_headerbar_center_create(UiObject *obj) { 877 UIEXPORT void ui_headerbar_center_create(UiObject *obj) {
877 UiContainerArgs boxargs = { }; 878 UiContainerArgs boxargs = { };
878 boxargs.fill = UI_OFF; 879 boxargs.fill = UI_OFF;
879 ui_hbox_create(obj, boxargs); 880 ui_hbox_create(obj, &boxargs);
880 } 881 }
881 882
882 UIEXPORT void ui_headerbar_end_create(UiObject *obj) { 883 UIEXPORT void ui_headerbar_end_create(UiObject *obj) {
883 UiContainerArgs boxargs = { }; 884 UiContainerArgs boxargs = { };
884 boxargs.fill = UI_OFF; 885 boxargs.fill = UI_OFF;
885 ui_hbox_create(obj, boxargs); 886 ui_hbox_create(obj, &boxargs);
886 } 887 }
887 888
888 889
889 890
890 /* 891 /*

mercurial