()
| 1598 | #[rustfmt::skip] |
| 1599 | #[test] |
| 1600 | fn test_floating() { |
| 1601 | let mut ply = Ply::<()>::new_headless(Dimensions::new(1000.0, 1000.0)); |
| 1602 | |
| 1603 | let mut ui = ply.begin(); |
| 1604 | |
| 1605 | ui.set_measure_text_function(|_, _| { |
| 1606 | Dimensions::new(100.0, 24.0) |
| 1607 | }); |
| 1608 | |
| 1609 | ui.element().width(fixed!(20.0)).height(fixed!(20.0)) |
| 1610 | .layout(|l| l.align(crate::align::AlignX::CenterX, crate::align::AlignY::CenterY)) |
| 1611 | .floating(|f| f |
| 1612 | .attach_root() |
| 1613 | .anchor((crate::align::AlignX::CenterX, crate::align::AlignY::CenterY), (crate::align::AlignX::Left, crate::align::AlignY::Top)) |
| 1614 | .offset((100.0, 150.0)) |
| 1615 | .passthrough() |
| 1616 | .z_index(110) |
| 1617 | ) |
| 1618 | .corner_radius(10.0) |
| 1619 | .background_color(0x4488DD) |
| 1620 | .children(|ui| { |
| 1621 | ui.text("Re", |t| t |
| 1622 | .font_size(6) |
| 1623 | .color(0xFFFFFF) |
| 1624 | ); |
| 1625 | }); |
| 1626 | |
| 1627 | let items = ui.eval(); |
| 1628 | |
| 1629 | for item in &items { |
| 1630 | println!( |
| 1631 | "id: {}\nbbox: {:?}\nconfig: {:?}", |
| 1632 | item.id, item.bounding_box, item.config, |
| 1633 | ); |
| 1634 | } |
| 1635 | |
| 1636 | assert_eq!(items.len(), 2); |
| 1637 | |
| 1638 | assert_eq!(items[0].bounding_box.x, 90.0); |
| 1639 | assert_eq!(items[0].bounding_box.y, 140.0); |
| 1640 | assert_eq!(items[0].bounding_box.width, 20.0); |
| 1641 | assert_eq!(items[0].bounding_box.height, 20.0); |
| 1642 | match &items[0].config { |
| 1643 | render_commands::RenderCommandConfig::Rectangle(rect) => { |
| 1644 | assert_eq!(rect.color.r, 68.0); |
| 1645 | assert_eq!(rect.color.g, 136.0); |
| 1646 | assert_eq!(rect.color.b, 221.0); |
| 1647 | assert_eq!(rect.color.a, 255.0); |
| 1648 | assert_eq!(rect.corner_radii.top_left, 10.0); |
| 1649 | assert_eq!(rect.corner_radii.top_right, 10.0); |
| 1650 | assert_eq!(rect.corner_radii.bottom_left, 10.0); |
| 1651 | assert_eq!(rect.corner_radii.bottom_right, 10.0); |
| 1652 | } |
| 1653 | _ => panic!("Expected Rectangle config for item 0"), |
| 1654 | } |
| 1655 | |
| 1656 | assert_eq!(items[1].bounding_box.x, 50.0); |
| 1657 | assert_eq!(items[1].bounding_box.y, 138.0); |
nothing calls this directly
no test coverage detected