cranpose-ui 0.0.60

UI primitives for Cranpose
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
use crate::layout::core::{
    Alignment, Arrangement, HorizontalAlignment, LinearArrangement, Measurable, VerticalAlignment,
};
use cranpose_ui_layout::{
    Axis, Constraints, FlexParentData, MeasurePolicy, MeasureResult, Placement,
};
use smallvec::SmallVec;

/// MeasurePolicy for Box layout - overlays children according to alignment.
#[derive(Clone, Debug, PartialEq)]
pub struct BoxMeasurePolicy {
    pub content_alignment: Alignment,
    pub propagate_min_constraints: bool,
}

impl BoxMeasurePolicy {
    pub fn new(content_alignment: Alignment, propagate_min_constraints: bool) -> Self {
        Self {
            content_alignment,
            propagate_min_constraints,
        }
    }
}

impl MeasurePolicy for BoxMeasurePolicy {
    fn measure(
        &self,
        measurables: &[Box<dyn Measurable>],
        constraints: Constraints,
    ) -> MeasureResult {
        let child_constraints = if self.propagate_min_constraints {
            constraints
        } else {
            Constraints {
                min_width: 0.0,
                max_width: constraints.max_width,
                min_height: 0.0,
                max_height: constraints.max_height,
            }
        };

        let mut max_width = 0.0_f32;
        let mut max_height = 0.0_f32;
        let mut placeables = Vec::with_capacity(measurables.len());

        for measurable in measurables {
            let placeable = measurable.measure(child_constraints);
            max_width = max_width.max(placeable.width());
            max_height = max_height.max(placeable.height());
            placeables.push(placeable);
        }

        let width = max_width.clamp(constraints.min_width, constraints.max_width);
        let height = max_height.clamp(constraints.min_height, constraints.max_height);

        let mut placements = Vec::with_capacity(placeables.len());
        for placeable in placeables {
            let child_width = placeable.width();
            let child_height = placeable.height();

            let x = match self.content_alignment.horizontal {
                HorizontalAlignment::Start => 0.0,
                HorizontalAlignment::CenterHorizontally => ((width - child_width) / 2.0).max(0.0),
                HorizontalAlignment::End => (width - child_width).max(0.0),
            };

            let y = match self.content_alignment.vertical {
                VerticalAlignment::Top => 0.0,
                VerticalAlignment::CenterVertically => ((height - child_height) / 2.0).max(0.0),
                VerticalAlignment::Bottom => (height - child_height).max(0.0),
            };

            placeable.place(x, y);
            placements.push(Placement::new(placeable.node_id(), x, y, 0));
        }

        MeasureResult::new(crate::modifier::Size { width, height }, placements)
    }

    fn min_intrinsic_width(&self, measurables: &[Box<dyn Measurable>], height: f32) -> f32 {
        measurables
            .iter()
            .map(|m| m.min_intrinsic_width(height))
            .fold(0.0, f32::max)
    }

    fn max_intrinsic_width(&self, measurables: &[Box<dyn Measurable>], height: f32) -> f32 {
        measurables
            .iter()
            .map(|m| m.max_intrinsic_width(height))
            .fold(0.0, f32::max)
    }

    fn min_intrinsic_height(&self, measurables: &[Box<dyn Measurable>], width: f32) -> f32 {
        measurables
            .iter()
            .map(|m| m.min_intrinsic_height(width))
            .fold(0.0, f32::max)
    }

    fn max_intrinsic_height(&self, measurables: &[Box<dyn Measurable>], width: f32) -> f32 {
        measurables
            .iter()
            .map(|m| m.max_intrinsic_height(width))
            .fold(0.0, f32::max)
    }
}

// Note: RowMeasurePolicy and ColumnMeasurePolicy have been replaced by FlexMeasurePolicy.
// See FlexMeasurePolicy below for the unified flex layout implementation.

/// Unified Flex layout policy that powers both Row and Column.
///
/// This policy implements Jetpack Compose's flex layout semantics:
/// - Measures children with proper loose constraints (min = 0 on both axes)
/// - Supports weighted distribution of remaining space
/// - Handles bounded/unbounded main axis correctly
/// - Implements correct intrinsics for both axes
///
/// ## Overflow Behavior
///
/// Like Jetpack Compose, this policy **allows children to overflow** their container bounds:
/// - Children can be positioned outside the parent's measured size
/// - Overflowing content is rendered (unless clipped by a modifier)
/// - When content overflows, arrangement switches to `Start` to avoid negative spacing
///
/// Example: A Row with 300px of content in a 200px container will:
/// 1. Measure children at their natural sizes
/// 2. Detect overflow (300px > 200px)
/// 3. Switch to Start arrangement (pack children at the start)
/// 4. Position last children beyond the 200px boundary
///
/// To prevent overflow:
/// - Use weights for flexible sizing: `.weight(1.0, true)`
/// - Use `fillMaxWidth()`/`fillMaxHeight()` modifiers
/// - Design UI to fit within available space
/// - Add a clip modifier (when implemented) to hide overflowing content
///
/// ## Weighted Children
///
/// When the main axis is bounded and children have weights:
/// 1. Fixed children (no weight) are measured first
/// 2. Remaining space is distributed proportionally to weights
/// 3. Each weighted child gets: `remaining * (weight / total_weight)`
/// 4. If `fill=true`, child gets tight constraints; if `fill=false`, loose constraints
///
/// When the main axis is unbounded, weights are ignored (all children wrap content).
#[derive(Clone, Debug, PartialEq)]
pub struct FlexMeasurePolicy {
    /// Main axis direction (Horizontal for Row, Vertical for Column)
    pub axis: Axis,
    /// Arrangement along the main axis
    pub main_axis_arrangement: LinearArrangement,
    /// Alignment along the cross axis (used as default for children without explicit alignment)
    pub cross_axis_alignment: CrossAxisAlignment,
}

/// Cross-axis alignment for flex layouts.
/// This is axis-agnostic and gets interpreted based on the flex axis.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CrossAxisAlignment {
    /// Align to the start of the cross axis (Top for Row, Start for Column)
    Start,
    /// Align to the center of the cross axis
    Center,
    /// Align to the end of the cross axis (Bottom for Row, End for Column)
    End,
}

impl CrossAxisAlignment {
    /// Calculate the offset for positioning a child on the cross axis.
    fn align(&self, available: f32, child: f32) -> f32 {
        match self {
            CrossAxisAlignment::Start => 0.0,
            CrossAxisAlignment::Center => ((available - child) / 2.0).max(0.0),
            CrossAxisAlignment::End => (available - child).max(0.0),
        }
    }
}

impl From<HorizontalAlignment> for CrossAxisAlignment {
    fn from(alignment: HorizontalAlignment) -> Self {
        match alignment {
            HorizontalAlignment::Start => CrossAxisAlignment::Start,
            HorizontalAlignment::CenterHorizontally => CrossAxisAlignment::Center,
            HorizontalAlignment::End => CrossAxisAlignment::End,
        }
    }
}

impl From<VerticalAlignment> for CrossAxisAlignment {
    fn from(alignment: VerticalAlignment) -> Self {
        match alignment {
            VerticalAlignment::Top => CrossAxisAlignment::Start,
            VerticalAlignment::CenterVertically => CrossAxisAlignment::Center,
            VerticalAlignment::Bottom => CrossAxisAlignment::End,
        }
    }
}

impl FlexMeasurePolicy {
    pub fn new(
        axis: Axis,
        main_axis_arrangement: LinearArrangement,
        cross_axis_alignment: CrossAxisAlignment,
    ) -> Self {
        Self {
            axis,
            main_axis_arrangement,
            cross_axis_alignment,
        }
    }

    /// Creates a FlexMeasurePolicy for Row (horizontal main axis).
    pub fn row(
        horizontal_arrangement: LinearArrangement,
        vertical_alignment: VerticalAlignment,
    ) -> Self {
        Self::new(
            Axis::Horizontal,
            horizontal_arrangement,
            vertical_alignment.into(),
        )
    }

    /// Creates a FlexMeasurePolicy for Column (vertical main axis).
    pub fn column(
        vertical_arrangement: LinearArrangement,
        horizontal_alignment: HorizontalAlignment,
    ) -> Self {
        Self::new(
            Axis::Vertical,
            vertical_arrangement,
            horizontal_alignment.into(),
        )
    }

    /// Extract main and cross axis values from constraints.
    fn get_axis_constraints(&self, constraints: Constraints) -> (f32, f32, f32, f32) {
        match self.axis {
            Axis::Horizontal => (
                constraints.min_width,
                constraints.max_width,
                constraints.min_height,
                constraints.max_height,
            ),
            Axis::Vertical => (
                constraints.min_height,
                constraints.max_height,
                constraints.min_width,
                constraints.max_width,
            ),
        }
    }

    /// Create constraints from main and cross axis values.
    fn make_constraints(
        &self,
        min_main: f32,
        max_main: f32,
        min_cross: f32,
        max_cross: f32,
    ) -> Constraints {
        match self.axis {
            Axis::Horizontal => Constraints {
                min_width: min_main,
                max_width: max_main,
                min_height: min_cross,
                max_height: max_cross,
            },
            Axis::Vertical => Constraints {
                min_width: min_cross,
                max_width: max_cross,
                min_height: min_main,
                max_height: max_main,
            },
        }
    }

    /// Get the main axis size from width/height.
    fn get_main_axis_size(&self, width: f32, height: f32) -> f32 {
        match self.axis {
            Axis::Horizontal => width,
            Axis::Vertical => height,
        }
    }

    /// Get the cross axis size from width/height.
    fn get_cross_axis_size(&self, width: f32, height: f32) -> f32 {
        match self.axis {
            Axis::Horizontal => height,
            Axis::Vertical => width,
        }
    }

    /// Calculate spacing between children based on arrangement.
    fn get_spacing(&self) -> f32 {
        match self.main_axis_arrangement {
            LinearArrangement::SpacedBy(value) => value.max(0.0),
            _ => 0.0,
        }
    }
}

impl MeasurePolicy for FlexMeasurePolicy {
    fn measure(
        &self,
        measurables: &[Box<dyn Measurable>],
        constraints: Constraints,
    ) -> MeasureResult {
        if measurables.is_empty() {
            let (width, height) = constraints.constrain(0.0, 0.0);
            return MeasureResult::new(crate::modifier::Size { width, height }, vec![]);
        }

        let (min_main, max_main, min_cross, max_cross) = self.get_axis_constraints(constraints);
        let main_axis_bounded = max_main.is_finite();
        let spacing = self.get_spacing();

        // Separate children into fixed and weighted
        let mut fixed_children: SmallVec<[usize; 8]> = SmallVec::new();
        let mut weighted_children: SmallVec<[(usize, FlexParentData); 8]> = SmallVec::new();

        for (idx, measurable) in measurables.iter().enumerate() {
            let parent_data = measurable.flex_parent_data().unwrap_or_default();
            if parent_data.has_weight() {
                weighted_children.push((idx, parent_data));
            } else {
                fixed_children.push(idx);
            }
        }

        // Measure fixed children first
        // Children get loose constraints on both axes (min = 0)
        let child_constraints = self.make_constraints(0.0, max_main, 0.0, max_cross);

        let mut placeables: SmallVec<[Option<cranpose_ui_layout::Placeable>; 8]> = SmallVec::new();
        placeables.resize_with(measurables.len(), || None);
        let mut fixed_main_size = 0.0_f32;
        let mut max_cross_size = 0.0_f32;

        for &idx in &fixed_children {
            let measurable = &measurables[idx];
            let placeable = measurable.measure(child_constraints);
            let main_size = self.get_main_axis_size(placeable.width(), placeable.height());
            let cross_size = self.get_cross_axis_size(placeable.width(), placeable.height());

            fixed_main_size += main_size;
            max_cross_size = max_cross_size.max(cross_size);
            placeables[idx] = Some(placeable);
        }

        // Calculate spacing
        let num_children = measurables.len();
        let total_spacing = if num_children > 1 {
            spacing * (num_children - 1) as f32
        } else {
            0.0
        };

        // Measure weighted children
        if !weighted_children.is_empty() {
            if main_axis_bounded {
                // Calculate remaining space for weighted children
                let used_main = fixed_main_size + total_spacing;
                let remaining_main = (max_main - used_main).max(0.0);

                // Calculate total weight
                let total_weight: f32 = weighted_children.iter().map(|(_, data)| data.weight).sum();

                // Measure each weighted child with its allocated space
                for &(idx, parent_data) in &weighted_children {
                    let measurable = &measurables[idx];
                    let allocated = if total_weight > 0.0 {
                        remaining_main * (parent_data.weight / total_weight)
                    } else {
                        0.0
                    };

                    let weighted_constraints = if parent_data.fill {
                        // fill=true: child gets tight constraints on main axis
                        self.make_constraints(allocated, allocated, 0.0, max_cross)
                    } else {
                        // fill=false: child gets loose constraints on main axis
                        self.make_constraints(0.0, allocated, 0.0, max_cross)
                    };

                    let placeable = measurable.measure(weighted_constraints);
                    let cross_size =
                        self.get_cross_axis_size(placeable.width(), placeable.height());
                    max_cross_size = max_cross_size.max(cross_size);
                    placeables[idx] = Some(placeable);
                }
            } else {
                // Main axis unbounded: ignore weights, measure like fixed children
                for &(idx, _) in &weighted_children {
                    let measurable = &measurables[idx];
                    let placeable = measurable.measure(child_constraints);
                    let cross_size =
                        self.get_cross_axis_size(placeable.width(), placeable.height());
                    max_cross_size = max_cross_size.max(cross_size);
                    placeables[idx] = Some(placeable);
                }
            }
        }

        // Unwrap all placeables
        let placeables: SmallVec<[cranpose_ui_layout::Placeable; 8]> = placeables
            .into_iter()
            .map(|p| p.expect("placeable missing"))
            .collect();

        // Calculate total main size
        let total_main: f32 = placeables
            .iter()
            .map(|p| self.get_main_axis_size(p.width(), p.height()))
            .sum::<f32>()
            + total_spacing;

        // Container size
        let container_main = total_main.clamp(min_main, max_main);
        let container_cross = max_cross_size.clamp(min_cross, max_cross);

        // Arrange children along main axis
        let child_main_sizes: SmallVec<[f32; 8]> = placeables
            .iter()
            .map(|p| self.get_main_axis_size(p.width(), p.height()))
            .collect();

        let mut main_positions: SmallVec<[f32; 8]> =
            SmallVec::with_capacity(child_main_sizes.len());
        main_positions.resize(child_main_sizes.len(), 0.0);

        // If we overflow, use Start arrangement to avoid negative spacing
        let arrangement = if total_main > container_main {
            LinearArrangement::Start
        } else {
            self.main_axis_arrangement
        };
        arrangement.arrange(container_main, &child_main_sizes, &mut main_positions);

        // Place children
        let mut placements: SmallVec<[Placement; 8]> = SmallVec::with_capacity(placeables.len());
        for (placeable, main_pos) in placeables.into_iter().zip(main_positions) {
            let child_cross = self.get_cross_axis_size(placeable.width(), placeable.height());
            let cross_pos = self
                .cross_axis_alignment
                .align(container_cross, child_cross);

            let (x, y) = match self.axis {
                Axis::Horizontal => (main_pos, cross_pos),
                Axis::Vertical => (cross_pos, main_pos),
            };

            placeable.place(x, y);
            placements.push(Placement::new(placeable.node_id(), x, y, 0));
        }

        // Create final size
        let (width, height) = match self.axis {
            Axis::Horizontal => (container_main, container_cross),
            Axis::Vertical => (container_cross, container_main),
        };

        MeasureResult::new(
            crate::modifier::Size { width, height },
            placements.into_vec(),
        )
    }

    fn min_intrinsic_width(&self, measurables: &[Box<dyn Measurable>], height: f32) -> f32 {
        let spacing = self.get_spacing();
        let total_spacing = if measurables.len() > 1 {
            spacing * (measurables.len() - 1) as f32
        } else {
            0.0
        };

        match self.axis {
            Axis::Horizontal => {
                // Row: sum of children's min intrinsic widths + spacing
                measurables
                    .iter()
                    .map(|m| m.min_intrinsic_width(height))
                    .sum::<f32>()
                    + total_spacing
            }
            Axis::Vertical => {
                // Column: max of children's min intrinsic widths
                measurables
                    .iter()
                    .map(|m| m.min_intrinsic_width(height))
                    .fold(0.0, f32::max)
            }
        }
    }

    fn max_intrinsic_width(&self, measurables: &[Box<dyn Measurable>], height: f32) -> f32 {
        let spacing = self.get_spacing();
        let total_spacing = if measurables.len() > 1 {
            spacing * (measurables.len() - 1) as f32
        } else {
            0.0
        };

        match self.axis {
            Axis::Horizontal => {
                // Row: sum of children's max intrinsic widths + spacing
                measurables
                    .iter()
                    .map(|m| m.max_intrinsic_width(height))
                    .sum::<f32>()
                    + total_spacing
            }
            Axis::Vertical => {
                // Column: max of children's max intrinsic widths
                measurables
                    .iter()
                    .map(|m| m.max_intrinsic_width(height))
                    .fold(0.0, f32::max)
            }
        }
    }

    fn min_intrinsic_height(&self, measurables: &[Box<dyn Measurable>], width: f32) -> f32 {
        let spacing = self.get_spacing();
        let total_spacing = if measurables.len() > 1 {
            spacing * (measurables.len() - 1) as f32
        } else {
            0.0
        };

        match self.axis {
            Axis::Horizontal => {
                // Row: max of children's min intrinsic heights
                measurables
                    .iter()
                    .map(|m| m.min_intrinsic_height(width))
                    .fold(0.0, f32::max)
            }
            Axis::Vertical => {
                // Column: sum of children's min intrinsic heights + spacing
                measurables
                    .iter()
                    .map(|m| m.min_intrinsic_height(width))
                    .sum::<f32>()
                    + total_spacing
            }
        }
    }

    fn max_intrinsic_height(&self, measurables: &[Box<dyn Measurable>], width: f32) -> f32 {
        let spacing = self.get_spacing();
        let total_spacing = if measurables.len() > 1 {
            spacing * (measurables.len() - 1) as f32
        } else {
            0.0
        };

        match self.axis {
            Axis::Horizontal => {
                // Row: max of children's max intrinsic heights
                measurables
                    .iter()
                    .map(|m| m.max_intrinsic_height(width))
                    .fold(0.0, f32::max)
            }
            Axis::Vertical => {
                // Column: sum of children's max intrinsic heights + spacing
                measurables
                    .iter()
                    .map(|m| m.max_intrinsic_height(width))
                    .sum::<f32>()
                    + total_spacing
            }
        }
    }
}

/// MeasurePolicy for leaf nodes with fixed intrinsic size (like Spacer).
/// This policy respects the provided constraints but has a preferred intrinsic size.
#[derive(Clone, Debug, PartialEq)]
pub struct LeafMeasurePolicy {
    pub intrinsic_size: crate::modifier::Size,
}

impl LeafMeasurePolicy {
    pub fn new(intrinsic_size: crate::modifier::Size) -> Self {
        Self { intrinsic_size }
    }
}

impl MeasurePolicy for LeafMeasurePolicy {
    fn measure(
        &self,
        _measurables: &[Box<dyn Measurable>],
        constraints: Constraints,
    ) -> MeasureResult {
        // Use intrinsic size but constrain to provided constraints
        let (width, height) =
            constraints.constrain(self.intrinsic_size.width, self.intrinsic_size.height);

        MeasureResult::new(
            crate::modifier::Size { width, height },
            vec![], // Leaf nodes have no children
        )
    }

    fn min_intrinsic_width(&self, _measurables: &[Box<dyn Measurable>], _height: f32) -> f32 {
        self.intrinsic_size.width
    }

    fn max_intrinsic_width(&self, _measurables: &[Box<dyn Measurable>], _height: f32) -> f32 {
        self.intrinsic_size.width
    }

    fn min_intrinsic_height(&self, _measurables: &[Box<dyn Measurable>], _width: f32) -> f32 {
        self.intrinsic_size.height
    }

    fn max_intrinsic_height(&self, _measurables: &[Box<dyn Measurable>], _width: f32) -> f32 {
        self.intrinsic_size.height
    }
}

/// EmptyMeasurePolicy that delegates all measurement to modifier nodes.
///
/// This is used when a Layout has no child layout logic - all measurement
/// is handled by modifier nodes (e.g., TextModifierNode for Text widgets).
/// Matches Jetpack Compose's EmptyMeasurePolicy pattern used in BasicText.
#[derive(Clone, Debug, PartialEq)]
pub struct EmptyMeasurePolicy;

impl EmptyMeasurePolicy {
    pub fn new() -> Self {
        Self
    }
}

impl Default for EmptyMeasurePolicy {
    fn default() -> Self {
        Self::new()
    }
}

impl MeasurePolicy for EmptyMeasurePolicy {
    fn measure(
        &self,
        _measurables: &[Box<dyn Measurable>],
        constraints: Constraints,
    ) -> MeasureResult {
        // Empty policy returns the maximum available space
        // The actual measurement is handled by modifier nodes in the chain
        let (width, height) = constraints.constrain(0.0, 0.0);

        MeasureResult::new(
            crate::modifier::Size { width, height },
            vec![], // No children
        )
    }

    fn min_intrinsic_width(&self, _measurables: &[Box<dyn Measurable>], _height: f32) -> f32 {
        0.0
    }

    fn max_intrinsic_width(&self, _measurables: &[Box<dyn Measurable>], _height: f32) -> f32 {
        0.0
    }

    fn min_intrinsic_height(&self, _measurables: &[Box<dyn Measurable>], _width: f32) -> f32 {
        0.0
    }

    fn max_intrinsic_height(&self, _measurables: &[Box<dyn Measurable>], _width: f32) -> f32 {
        0.0
    }
}

#[cfg(test)]
#[path = "tests/policies_tests.rs"]
mod tests;