@@ -2435,11 +2435,11 @@ void oc_ui_layout_downward_dependent_size(oc_ui_context* ui, oc_ui_box* box, int
2435
2435
if (box -> style .layout .axis == axis )
2436
2436
{
2437
2437
count ++ ;
2438
- minSum += child -> minSize [axis ];
2438
+ minSum += child -> minSize [axis ] + 2 * child -> style . borderSize ;
2439
2439
}
2440
2440
else
2441
2441
{
2442
- minSum = oc_max (minSum , child -> minSize [axis ]);
2442
+ minSum = oc_max (minSum , child -> minSize [axis ] + 2 * child -> style . borderSize );
2443
2443
}
2444
2444
}
2445
2445
}
@@ -2480,7 +2480,7 @@ void oc_ui_layout_downward_dependent_size(oc_ui_context* ui, oc_ui_box* box, int
2480
2480
{
2481
2481
if (oc_ui_layout_downward_dependency (child , axis ))
2482
2482
{
2483
- sum += child -> rect .c [2 + axis ];
2483
+ sum += child -> rect .c [2 + axis ] + 2 * child -> style . borderSize ;
2484
2484
}
2485
2485
}
2486
2486
}
@@ -2490,12 +2490,11 @@ void oc_ui_layout_downward_dependent_size(oc_ui_context* ui, oc_ui_box* box, int
2490
2490
{
2491
2491
if (oc_ui_layout_downward_dependency (child , axis ))
2492
2492
{
2493
- sum = oc_max (sum , child -> rect .c [2 + axis ]);
2493
+ sum = oc_max (sum , child -> rect .c [2 + axis ] + 2 * child -> style . borderSize );
2494
2494
}
2495
2495
}
2496
2496
}
2497
- f32 margin = box -> style .layout .margin .c [axis ];
2498
- box -> rect .c [2 + axis ] = sum + box -> spacing [axis ] + 2 * margin ;
2497
+ box -> rect .c [2 + axis ] = sum + box -> spacing [axis ] + 2 * box -> style .layout .margin .c [axis ];
2499
2498
}
2500
2499
}
2501
2500
@@ -2511,11 +2510,11 @@ void oc_ui_layout_upward_dependent_size(oc_ui_context* ui, oc_ui_box* box, int a
2511
2510
oc_ui_size * size = & child -> style .size .c [axis ];
2512
2511
if (size -> kind == OC_UI_SIZE_PARENT )
2513
2512
{
2514
- child -> rect .c [2 + axis ] = oc_max (child -> minSize [axis ], availableSize * size -> value );
2513
+ child -> rect .c [2 + axis ] = oc_max (child -> minSize [axis ], availableSize * size -> value ) - 2 * child -> style . borderSize ;
2515
2514
}
2516
2515
else if (size -> kind == OC_UI_SIZE_PARENT_MINUS_PIXELS )
2517
2516
{
2518
- child -> rect .c [2 + axis ] = oc_max (child -> minSize [axis ], oc_max (0 , availableSize - size -> value ));
2517
+ child -> rect .c [2 + axis ] = oc_max (child -> minSize [axis ], oc_max (0 , availableSize - size -> value )) - 2 * child -> style . borderSize ;
2519
2518
}
2520
2519
}
2521
2520
@@ -2552,7 +2551,7 @@ void oc_ui_layout_upward_dependent_size(oc_ui_context* ui, oc_ui_box* box, int a
2552
2551
if (!oc_ui_box_hidden (child )
2553
2552
&& !child -> style .floating .c [axis ])
2554
2553
{
2555
- sum += child -> rect .c [2 + axis ];
2554
+ sum += child -> rect .c [2 + axis ] + 2 * child -> style . borderSize ;
2556
2555
slack += oc_min (child -> rect .c [2 + axis ] * child -> style .size .c [axis ].relax ,
2557
2556
child -> rect .c [2 + axis ] - child -> minSize [axis ]);
2558
2557
}
@@ -2615,11 +2614,11 @@ void oc_ui_layout_upward_dependent_size(oc_ui_context* ui, oc_ui_box* box, int a
2615
2614
{
2616
2615
if (box -> style .layout .axis == axis )
2617
2616
{
2618
- sum += child -> rect .c [2 + axis ];
2617
+ sum += child -> rect .c [2 + axis ] + 2 * child -> style . borderSize ;
2619
2618
}
2620
2619
else
2621
2620
{
2622
- sum = oc_max (sum , child -> rect .c [2 + axis ]);
2621
+ sum = oc_max (sum , child -> rect .c [2 + axis ] + 2 * child -> style . borderSize );
2623
2622
}
2624
2623
}
2625
2624
}
@@ -2634,6 +2633,7 @@ void oc_ui_layout_upward_dependent_size(oc_ui_context* ui, oc_ui_box* box, int a
2634
2633
box -> minSize [axis ]);
2635
2634
}
2636
2635
2636
+ /*
2637
2637
void oc_ui_layout_upward_dependent_fixup(oc_ui_context* ui, oc_ui_box* box, int axis)
2638
2638
{
2639
2639
f32 margin = box->style.layout.margin.c[axis];
@@ -2710,6 +2710,7 @@ void oc_ui_layout_upward_dependent_fixup(oc_ui_context* ui, oc_ui_box* box, int
2710
2710
oc_ui_layout_upward_dependent_fixup(ui, child, axis);
2711
2711
}
2712
2712
}
2713
+ */
2713
2714
2714
2715
void oc_ui_layout_compute_rect (oc_ui_context * ui , oc_ui_box * box , oc_vec2 pos )
2715
2716
{
@@ -2718,8 +2719,8 @@ void oc_ui_layout_compute_rect(oc_ui_context* ui, oc_ui_box* box, oc_vec2 pos)
2718
2719
return ;
2719
2720
}
2720
2721
2721
- box -> rect .x = pos .x ;
2722
- box -> rect .y = pos .y ;
2722
+ box -> rect .x = pos .x + box -> style . borderSize ;
2723
+ box -> rect .y = pos .y + box -> style . borderSize ;
2723
2724
box -> z = ui -> z ;
2724
2725
ui -> z ++ ;
2725
2726
@@ -2729,12 +2730,16 @@ void oc_ui_layout_compute_rect(oc_ui_context* ui, oc_ui_box* box, oc_vec2 pos)
2729
2730
2730
2731
oc_ui_align * align = box -> style .layout .align .c ;
2731
2732
2732
- oc_vec2 origin = { box -> rect .x ,
2733
- box -> rect .y };
2733
+ oc_vec2 origin = {
2734
+ box -> rect .x ,
2735
+ box -> rect .y ,
2736
+ };
2734
2737
oc_vec2 currentPos = origin ;
2735
2738
2736
- oc_vec2 margin = { box -> style .layout .margin .x ,
2737
- box -> style .layout .margin .y };
2739
+ oc_vec2 margin = {
2740
+ box -> style .layout .margin .x ,
2741
+ box -> style .layout .margin .y ,
2742
+ };
2738
2743
2739
2744
currentPos .x += margin .x ;
2740
2745
currentPos .y += margin .y ;
@@ -2759,7 +2764,7 @@ void oc_ui_layout_compute_rect(oc_ui_context* ui, oc_ui_box* box, oc_vec2 pos)
2759
2764
{
2760
2765
if (align [secondAxis ] == OC_UI_ALIGN_CENTER )
2761
2766
{
2762
- currentPos .c [secondAxis ] = origin .c [secondAxis ] + 0.5 * (box -> rect .c [2 + secondAxis ] - child -> rect .c [2 + secondAxis ]);
2767
+ currentPos .c [secondAxis ] = origin .c [secondAxis ] + 0.5 * (box -> rect .c [2 + secondAxis ] - child -> rect .c [2 + secondAxis ] - 2 * child -> style . borderSize );
2763
2768
}
2764
2769
2765
2770
oc_vec2 childPos = currentPos ;
@@ -2785,7 +2790,7 @@ void oc_ui_layout_compute_rect(oc_ui_context* ui, oc_ui_box* box, oc_vec2 pos)
2785
2790
2786
2791
if (!child -> style .floating .c [layoutAxis ])
2787
2792
{
2788
- currentPos .c [layoutAxis ] += child -> rect .c [2 + layoutAxis ] + spacing ;
2793
+ currentPos .c [layoutAxis ] += child -> rect .c [2 + layoutAxis ] + 2 * child -> style . borderSize + spacing ;
2789
2794
}
2790
2795
}
2791
2796
if (isnan (box -> rect .w ) || isnan (box -> rect .h ))
@@ -2895,10 +2900,10 @@ void oc_ui_draw_box(oc_ui_box* box)
2895
2900
{
2896
2901
oc_rect clipRect = oc_clip_top ();
2897
2902
oc_rect expRect = {
2898
- box -> rect .x - 0.5 * style -> borderSize ,
2899
- box -> rect .y - 0.5 * style -> borderSize ,
2900
- box -> rect .w + style -> borderSize ,
2901
- box -> rect .h + style -> borderSize
2903
+ box -> rect .x - style -> borderSize ,
2904
+ box -> rect .y - style -> borderSize ,
2905
+ box -> rect .w + 2 * style -> borderSize ,
2906
+ box -> rect .h + 2 * style -> borderSize
2902
2907
};
2903
2908
2904
2909
if ((expRect .x + expRect .w < clipRect .x )
@@ -3009,7 +3014,16 @@ void oc_ui_draw_box(oc_ui_box* box)
3009
3014
{
3010
3015
oc_set_width (style -> borderSize );
3011
3016
oc_set_color (style -> borderColor );
3012
- oc_ui_rectangle_stroke (box -> rect , style -> roundness );
3017
+
3018
+ oc_rect rect = {
3019
+ box -> rect .x - 0.5 * style -> borderSize ,
3020
+ box -> rect .y - 0.5 * style -> borderSize ,
3021
+ box -> rect .w + style -> borderSize ,
3022
+ box -> rect .h + style -> borderSize ,
3023
+ };
3024
+ f32 roundness = style -> roundness ? style -> roundness + style -> borderSize : 0 ;
3025
+
3026
+ oc_ui_rectangle_stroke (rect , roundness );
3013
3027
}
3014
3028
}
3015
3029
0 commit comments