mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Rename Component::compute_layout to apply_layout
And pass the expected rectangle. This is currently not used yet but will be needed when we can have repeated elements within a box layout
This commit is contained in:
parent
7d3337e1d1
commit
5face45c51
20 changed files with 69 additions and 51 deletions
|
@ -281,6 +281,7 @@ using cbindgen_private::solve_grid_layout;
|
||||||
using cbindgen_private::solve_box_layout;
|
using cbindgen_private::solve_box_layout;
|
||||||
using cbindgen_private::box_layout_info;
|
using cbindgen_private::box_layout_info;
|
||||||
using cbindgen_private::solve_path_layout;
|
using cbindgen_private::solve_path_layout;
|
||||||
|
using cbindgen_private::Rect;
|
||||||
|
|
||||||
inline LayoutInfo LayoutInfo::merge(const LayoutInfo &other) const {
|
inline LayoutInfo LayoutInfo::merge(const LayoutInfo &other) const {
|
||||||
// Note: This "logic" is duplicated from LayoutInfo::merge in layout.rs.
|
// Note: This "logic" is duplicated from LayoutInfo::merge in layout.rs.
|
||||||
|
@ -461,7 +462,7 @@ class Repeater
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// FIXME: should be private, but compute_layout uses it.
|
// FIXME: should be private, but layouting code uses it.
|
||||||
mutable std::shared_ptr<RepeaterInner> inner;
|
mutable std::shared_ptr<RepeaterInner> inner;
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
|
@ -531,12 +532,12 @@ public:
|
||||||
return { &C::component_type, x.ptr.get() };
|
return { &C::component_type, x.ptr.get() };
|
||||||
}
|
}
|
||||||
|
|
||||||
void compute_layout() const
|
void compute_layout(cbindgen_private::Rect parent_rect) const
|
||||||
{
|
{
|
||||||
if (!inner)
|
if (!inner)
|
||||||
return;
|
return;
|
||||||
for (auto &x : inner->data) {
|
for (auto &x : inner->data) {
|
||||||
x.ptr->compute_layout({ &C::component_type, x.ptr.get() });
|
x.ptr->apply_layout({ &C::component_type, x.ptr.get() }, parent_rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -473,7 +473,9 @@ fn handle_repeater(
|
||||||
i = repeater_count,
|
i = repeater_count,
|
||||||
));
|
));
|
||||||
|
|
||||||
layout_repeater_code.push(format!("self->{}.compute_layout();", repeater_id));
|
// FIXME: we should probably pass the parent element rect?
|
||||||
|
layout_repeater_code
|
||||||
|
.push(format!("self->{}.compute_layout(sixtyfps::Rect{{ }});", repeater_id,));
|
||||||
}
|
}
|
||||||
|
|
||||||
repeated_input_branch.push(format!(
|
repeated_input_branch.push(format!(
|
||||||
|
@ -755,10 +757,10 @@ fn generate_component(
|
||||||
"(float *offset_y, const sixtyfps::Property<float> *viewport_width) const -> void"
|
"(float *offset_y, const sixtyfps::Property<float> *viewport_width) const -> void"
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
statements: Some(vec![
|
statements: Some(vec![
|
||||||
"compute_layout({&component_type, const_cast<void *>(static_cast<const void *>(this))});".to_owned(),
|
|
||||||
format!("{}.set(*offset_y);", p_y),
|
|
||||||
format!("*offset_y += {}.get();", p_height),
|
|
||||||
"float vp_w = viewport_width->get();".to_owned(),
|
"float vp_w = viewport_width->get();".to_owned(),
|
||||||
|
format!("apply_layout({{&component_type, const_cast<void *>(static_cast<const void *>(this))}}, sixtyfps::Rect{{ 0, *offset_y, vp_w, {h} }});", h = "0/*FIXME: should compute the heigth somehow*/"),
|
||||||
|
format!("{}.set(*offset_y);", p_y), // FIXME: shouldn't that be handled by apply layout?
|
||||||
|
format!("*offset_y += {}.get();", p_height),
|
||||||
format!("float w = {}.get();", p_width),
|
format!("float w = {}.get();", p_width),
|
||||||
"if (vp_w < w)".to_owned(),
|
"if (vp_w < w)".to_owned(),
|
||||||
" viewport_width->set(w);".to_owned(),
|
" viewport_width->set(w);".to_owned(),
|
||||||
|
@ -1011,8 +1013,10 @@ fn generate_component(
|
||||||
component_struct.members.push((
|
component_struct.members.push((
|
||||||
Access::Public, // FIXME: we call this function from tests
|
Access::Public, // FIXME: we call this function from tests
|
||||||
Declaration::Function(Function {
|
Declaration::Function(Function {
|
||||||
name: "compute_layout".into(),
|
name: "apply_layout".into(),
|
||||||
signature: "(sixtyfps::private_api::ComponentRef component) -> void".into(),
|
signature:
|
||||||
|
"(sixtyfps::private_api::ComponentRef component, sixtyfps::Rect rect) -> void"
|
||||||
|
.into(),
|
||||||
is_static: true,
|
is_static: true,
|
||||||
statements: Some(compute_layout(component, &mut repeater_layout_code)),
|
statements: Some(compute_layout(component, &mut repeater_layout_code)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -1048,7 +1052,7 @@ fn generate_component(
|
||||||
ty: "const sixtyfps::private_api::ComponentVTable".to_owned(),
|
ty: "const sixtyfps::private_api::ComponentVTable".to_owned(),
|
||||||
name: format!("{}::component_type", component_id),
|
name: format!("{}::component_type", component_id),
|
||||||
init: Some(
|
init: Some(
|
||||||
"{ visit_children, nullptr, compute_layout, input_event, key_event, focus_event }"
|
"{ visit_children, nullptr, apply_layout, input_event, key_event, focus_event }"
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -392,10 +392,10 @@ fn generate_component(
|
||||||
viewport_width: core::pin::Pin<&sixtyfps::re_exports::Property<f32>>,
|
viewport_width: core::pin::Pin<&sixtyfps::re_exports::Property<f32>>,
|
||||||
) {
|
) {
|
||||||
use sixtyfps::re_exports::*;
|
use sixtyfps::re_exports::*;
|
||||||
self.compute_layout();
|
let vp_w = viewport_width.get();
|
||||||
|
self.apply_layout(Rect::new(Point::new(0., *offset_y), Size::new(vp_w, 0.)));
|
||||||
#p_y.set(*offset_y);
|
#p_y.set(*offset_y);
|
||||||
*offset_y += #p_height.get();
|
*offset_y += #p_height.get();
|
||||||
let vp_w = viewport_width.get();
|
|
||||||
let w = #p_width.get();
|
let w = #p_width.get();
|
||||||
if vp_w < w {
|
if vp_w < w {
|
||||||
viewport_width.set(w);
|
viewport_width.set(w);
|
||||||
|
@ -1765,7 +1765,7 @@ fn compute_layout(
|
||||||
fn layout_info(self: ::core::pin::Pin<&Self>) -> sixtyfps::re_exports::LayoutInfo {
|
fn layout_info(self: ::core::pin::Pin<&Self>) -> sixtyfps::re_exports::LayoutInfo {
|
||||||
todo!("Implement in rust.rs")
|
todo!("Implement in rust.rs")
|
||||||
}
|
}
|
||||||
fn compute_layout(self: ::core::pin::Pin<&Self>) {
|
fn apply_layout(self: ::core::pin::Pin<&Self>, _: sixtyfps::re_exports::Rect) {
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
use sixtyfps::re_exports::*;
|
use sixtyfps::re_exports::*;
|
||||||
let dummy = Property::<f32>::default();
|
let dummy = Property::<f32>::default();
|
||||||
|
|
|
@ -12,6 +12,7 @@ LICENSE END */
|
||||||
//! This module contains the basic datastructures that are exposed to the C API
|
//! This module contains the basic datastructures that are exposed to the C API
|
||||||
|
|
||||||
use crate::eventloop::ComponentWindow;
|
use crate::eventloop::ComponentWindow;
|
||||||
|
use crate::graphics::Rect;
|
||||||
use crate::input::{
|
use crate::input::{
|
||||||
FocusEvent, FocusEventResult, InputEventResult, KeyEvent, KeyEventResult, MouseEvent,
|
FocusEvent, FocusEventResult, InputEventResult, KeyEvent, KeyEventResult, MouseEvent,
|
||||||
};
|
};
|
||||||
|
@ -36,8 +37,8 @@ pub struct ComponentVTable {
|
||||||
/// Returns the layout info for this component
|
/// Returns the layout info for this component
|
||||||
pub layout_info: extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>) -> LayoutInfo,
|
pub layout_info: extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>) -> LayoutInfo,
|
||||||
|
|
||||||
/// Will compute the layout of
|
/// Apply the layout to all the items in the component, and set the geometry of the root to the given rect
|
||||||
pub compute_layout: extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>),
|
pub apply_layout: extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>, Rect),
|
||||||
|
|
||||||
/// input event
|
/// input event
|
||||||
pub input_event: extern "C" fn(
|
pub input_event: extern "C" fn(
|
||||||
|
|
|
@ -91,6 +91,9 @@ pub trait GenericWindow {
|
||||||
/// Sets the size of the window to the specified `height`. This method is typically called in response to receiving a
|
/// Sets the size of the window to the specified `height`. This method is typically called in response to receiving a
|
||||||
/// window resize event from the windowing system.
|
/// window resize event from the windowing system.
|
||||||
fn set_height(&self, height: f32);
|
fn set_height(&self, height: f32);
|
||||||
|
/// Returns the geometry of the window
|
||||||
|
fn get_geometry(&self) -> crate::graphics::Rect;
|
||||||
|
|
||||||
/// This function is called by the generated code when a component and therefore its tree of items are destroyed. The
|
/// This function is called by the generated code when a component and therefore its tree of items are destroyed. The
|
||||||
/// implementation typically uses this to free the underlying graphics resources cached via [`crate::graphics::RenderingCache`].
|
/// implementation typically uses this to free the underlying graphics resources cached via [`crate::graphics::RenderingCache`].
|
||||||
fn free_graphics_resources(
|
fn free_graphics_resources(
|
||||||
|
@ -266,9 +269,9 @@ impl EventLoop {
|
||||||
windows.borrow().get(&id).map(|weakref| weakref.upgrade())
|
windows.borrow().get(&id).map(|weakref| weakref.upgrade())
|
||||||
{
|
{
|
||||||
if layout_listener.as_ref().is_dirty() {
|
if layout_listener.as_ref().is_dirty() {
|
||||||
layout_listener
|
layout_listener.as_ref().evaluate(|| {
|
||||||
.as_ref()
|
component.as_ref().apply_layout(window.get_geometry())
|
||||||
.evaluate(|| component.as_ref().compute_layout())
|
})
|
||||||
}
|
}
|
||||||
window.draw(component);
|
window.draw(component);
|
||||||
}
|
}
|
||||||
|
|
|
@ -755,6 +755,15 @@ impl<Backend: GraphicsBackend> crate::eventloop::GenericWindow for GraphicsWindo
|
||||||
self.properties.as_ref().height.set(height);
|
self.properties.as_ref().height.set(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_geometry(&self) -> crate::graphics::Rect {
|
||||||
|
euclid::rect(
|
||||||
|
0.,
|
||||||
|
0.,
|
||||||
|
WindowProperties::FIELD_OFFSETS.width.apply_pin(self.properties.as_ref()).get(),
|
||||||
|
WindowProperties::FIELD_OFFSETS.height.apply_pin(self.properties.as_ref()).get(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fn free_graphics_resources(
|
fn free_graphics_resources(
|
||||||
self: Rc<Self>,
|
self: Rc<Self>,
|
||||||
component: core::pin::Pin<crate::component::ComponentRef>,
|
component: core::pin::Pin<crate::component::ComponentRef>,
|
||||||
|
|
|
@ -410,7 +410,7 @@ impl<C: RepeatedComponent + 'static> Repeater<C> {
|
||||||
|
|
||||||
for c in self.inner.borrow().borrow().components.iter() {
|
for c in self.inner.borrow().borrow().components.iter() {
|
||||||
c.1.as_ref().map(|x| {
|
c.1.as_ref().map(|x| {
|
||||||
x.as_ref().compute_layout();
|
x.as_ref().apply_layout(Default::default());
|
||||||
x.as_ref().visit_children_item(-1, crate::item_tree::TraversalOrder::FrontToBack, get_height_visitor.borrow_mut());
|
x.as_ref().visit_children_item(-1, crate::item_tree::TraversalOrder::FrontToBack, get_height_visitor.borrow_mut());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ impl<C: RepeatedComponent + 'static> Repeater<C> {
|
||||||
self.ensure_updated_impl(&init, &model, 1);
|
self.ensure_updated_impl(&init, &model, 1);
|
||||||
if let Some(c) = self.inner.borrow().borrow().components.get(0) {
|
if let Some(c) = self.inner.borrow().borrow().components.get(0) {
|
||||||
c.1.as_ref().map(|x| {
|
c.1.as_ref().map(|x| {
|
||||||
x.as_ref().compute_layout();
|
x.as_ref().apply_layout(Default::default());
|
||||||
x.as_ref().visit_children_item(-1, crate::item_tree::TraversalOrder::FrontToBack, get_height_visitor);
|
x.as_ref().visit_children_item(-1, crate::item_tree::TraversalOrder::FrontToBack, get_height_visitor);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -571,7 +571,7 @@ impl<C: RepeatedComponent> Repeater<C> {
|
||||||
/// Recompute the layout of each child elements
|
/// Recompute the layout of each child elements
|
||||||
pub fn compute_layout(&self) {
|
pub fn compute_layout(&self) {
|
||||||
for c in self.inner.borrow().borrow().components.iter() {
|
for c in self.inner.borrow().borrow().components.iter() {
|
||||||
c.1.as_ref().map(|x| x.as_ref().compute_layout());
|
c.1.as_ref().map(|x| x.as_ref().apply_layout(Default::default()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ impl<'id> sixtyfps_corelib::model::RepeatedComponent for ComponentBox<'id> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn listview_layout(self: Pin<&Self>, offset_y: &mut f32, viewport_width: Pin<&Property<f32>>) {
|
fn listview_layout(self: Pin<&Self>, offset_y: &mut f32, viewport_width: Pin<&Property<f32>>) {
|
||||||
self.as_ref().compute_layout();
|
self.as_ref().apply_layout(Default::default());
|
||||||
self.component_type
|
self.component_type
|
||||||
.set_property(self.borrow(), "y", eval::Value::Number(*offset_y as f64))
|
.set_property(self.borrow(), "y", eval::Value::Number(*offset_y as f64))
|
||||||
.expect("cannot set y");
|
.expect("cannot set y");
|
||||||
|
@ -199,8 +199,8 @@ impl<'id> Component for ComponentBox<'id> {
|
||||||
fn layout_info(self: ::core::pin::Pin<&Self>) -> sixtyfps_corelib::layout::LayoutInfo {
|
fn layout_info(self: ::core::pin::Pin<&Self>) -> sixtyfps_corelib::layout::LayoutInfo {
|
||||||
self.borrow().as_ref().layout_info()
|
self.borrow().as_ref().layout_info()
|
||||||
}
|
}
|
||||||
fn compute_layout(self: ::core::pin::Pin<&Self>) {
|
fn apply_layout(self: ::core::pin::Pin<&Self>, r: sixtyfps_corelib::graphics::Rect) {
|
||||||
self.borrow().as_ref().compute_layout()
|
self.borrow().as_ref().apply_layout(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +646,7 @@ fn generate_component<'id>(
|
||||||
let t = ComponentVTable {
|
let t = ComponentVTable {
|
||||||
visit_children_item,
|
visit_children_item,
|
||||||
layout_info,
|
layout_info,
|
||||||
compute_layout,
|
apply_layout,
|
||||||
input_event,
|
input_event,
|
||||||
key_event,
|
key_event,
|
||||||
focus_event,
|
focus_event,
|
||||||
|
@ -1334,7 +1334,7 @@ extern "C" fn focus_event(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn compute_layout(component: ComponentRefPin) {
|
extern "C" fn apply_layout(component: ComponentRefPin, _r: sixtyfps_corelib::graphics::Rect) {
|
||||||
generativity::make_guard!(guard);
|
generativity::make_guard!(guard);
|
||||||
// This is fine since we can only be called with a component that with our vtable which is a ComponentDescription
|
// This is fine since we can only be called with a component that with our vtable which is a ComponentDescription
|
||||||
let instance_ref = unsafe { InstanceRef::from_pin_ref(component, guard) };
|
let instance_ref = unsafe { InstanceRef::from_pin_ref(component, guard) };
|
||||||
|
|
|
@ -26,14 +26,14 @@ TestCase := Container {
|
||||||
rect1 := Rectangle {
|
rect1 := Rectangle {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
property <bool> rect1_pos_ok: rect1.x == 150phx;
|
property <bool> rect1_pos_ok: rect1.x == 150phx;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 300, 200});
|
||||||
assert(instance.get_rect1_pos_ok());
|
assert(instance.get_rect1_pos_ok());
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ assert(instance.get_rect1_pos_ok());
|
||||||
let instance = TestCase::new();
|
let instance = TestCase::new();
|
||||||
let instance = instance.as_ref();
|
let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 200.)));
|
||||||
assert!(instance.get_rect1_pos_ok());
|
assert!(instance.get_rect1_pos_ok());
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -41,7 +41,7 @@ TestCase := MegaContainer {
|
||||||
/*
|
/*
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 300, 200});
|
||||||
assert(instance.get_rect1_pos_ok());
|
assert(instance.get_rect1_pos_ok());
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ assert(instance.get_rect1_pos_ok());
|
||||||
let instance = TestCase::new();
|
let instance = TestCase::new();
|
||||||
let instance = instance.as_ref();
|
let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 200.)));
|
||||||
assert!(instance.get_rect1_pos_ok());
|
assert!(instance.get_rect1_pos_ok());
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -39,7 +39,7 @@ TestCase := Rectangle {
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 300, 300});
|
||||||
assert(instance.get_rect1_pos_ok());
|
assert(instance.get_rect1_pos_ok());
|
||||||
assert(instance.get_rect2_pos_ok());
|
assert(instance.get_rect2_pos_ok());
|
||||||
assert(instance.get_rect3_pos_ok());
|
assert(instance.get_rect3_pos_ok());
|
||||||
|
@ -51,7 +51,7 @@ assert_eq(instance.get_layout_width(), 300);
|
||||||
let instance = TestCase::new();
|
let instance = TestCase::new();
|
||||||
let instance = instance.as_ref();
|
let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 300.)));
|
||||||
assert!(instance.get_rect1_pos_ok());
|
assert!(instance.get_rect1_pos_ok());
|
||||||
assert!(instance.get_rect2_pos_ok());
|
assert!(instance.get_rect2_pos_ok());
|
||||||
assert!(instance.get_rect3_pos_ok());
|
assert!(instance.get_rect3_pos_ok());
|
||||||
|
|
|
@ -52,7 +52,7 @@ TestCase := Rectangle {
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 300, 300});
|
||||||
assert(instance.get_rect1_pos_ok());
|
assert(instance.get_rect1_pos_ok());
|
||||||
assert(instance.get_rect2_pos_ok());
|
assert(instance.get_rect2_pos_ok());
|
||||||
assert(instance.get_rect3_pos_ok());
|
assert(instance.get_rect3_pos_ok());
|
||||||
|
@ -63,7 +63,7 @@ assert(instance.get_rect3_pos_ok());
|
||||||
let instance = TestCase::new();
|
let instance = TestCase::new();
|
||||||
let instance = instance.as_ref();
|
let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 300.)));
|
||||||
assert!(instance.get_rect1_pos_ok());
|
assert!(instance.get_rect1_pos_ok());
|
||||||
assert!(instance.get_rect2_pos_ok());
|
assert!(instance.get_rect2_pos_ok());
|
||||||
assert!(instance.get_rect3_pos_ok());
|
assert!(instance.get_rect3_pos_ok());
|
||||||
|
|
|
@ -57,7 +57,7 @@ TestCase := Rectangle {
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 600, 300});
|
||||||
assert(instance.get_rect1_pos_ok());
|
assert(instance.get_rect1_pos_ok());
|
||||||
assert(instance.get_rect2_pos_ok());
|
assert(instance.get_rect2_pos_ok());
|
||||||
```
|
```
|
||||||
|
@ -67,7 +67,7 @@ assert(instance.get_rect2_pos_ok());
|
||||||
let instance = TestCase::new();
|
let instance = TestCase::new();
|
||||||
let instance = instance.as_ref();
|
let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 300.)));
|
||||||
assert!(instance.get_rect1_pos_ok());
|
assert!(instance.get_rect1_pos_ok());
|
||||||
assert!(instance.get_rect2_pos_ok());
|
assert!(instance.get_rect2_pos_ok());
|
||||||
```
|
```
|
||||||
|
|
|
@ -40,7 +40,7 @@ TestCase := Rectangle {
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
sixtyfps::testing::send_mouse_click(instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout
|
sixtyfps::testing::send_mouse_click(instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 300, 300});
|
||||||
|
|
||||||
sixtyfps::testing::send_mouse_click(instance, 190., 190.);
|
sixtyfps::testing::send_mouse_click(instance, 190., 190.);
|
||||||
assert_eq(instance.get_value(), 1+1);
|
assert_eq(instance.get_value(), 1+1);
|
||||||
|
@ -56,7 +56,7 @@ let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
sixtyfps::testing::send_mouse_click(instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout
|
sixtyfps::testing::send_mouse_click(instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout
|
||||||
|
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 300.)));
|
||||||
|
|
||||||
sixtyfps::testing::send_mouse_click(instance, 190., 190.);
|
sixtyfps::testing::send_mouse_click(instance, 190., 190.);
|
||||||
assert_eq!(instance.get_value(), 1+1);
|
assert_eq!(instance.get_value(), 1+1);
|
||||||
|
|
|
@ -64,7 +64,7 @@ TestCase := Rectangle {
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 300, 300});
|
||||||
assert(instance.get_blue_rect_ok());
|
assert(instance.get_blue_rect_ok());
|
||||||
assert(instance.get_red_rect_ok());
|
assert(instance.get_red_rect_ok());
|
||||||
assert(instance.get_green_rect_ok());
|
assert(instance.get_green_rect_ok());
|
||||||
|
@ -78,7 +78,7 @@ assert(instance.get_pink_rect_ok());
|
||||||
let instance = TestCase::new();
|
let instance = TestCase::new();
|
||||||
let instance = instance.as_ref();
|
let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 300.)));
|
||||||
assert!(instance.get_blue_rect_ok());
|
assert!(instance.get_blue_rect_ok());
|
||||||
assert!(instance.get_red_rect_ok());
|
assert!(instance.get_red_rect_ok());
|
||||||
assert!(instance.get_green_rect_ok());
|
assert!(instance.get_green_rect_ok());
|
||||||
|
|
|
@ -116,7 +116,7 @@ TestCase := Rectangle {
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 300, 300});
|
||||||
assert(instance.get_rect_blue_ok());
|
assert(instance.get_rect_blue_ok());
|
||||||
assert(instance.get_rect_orange_ok());
|
assert(instance.get_rect_orange_ok());
|
||||||
assert(instance.get_rect_red_ok());
|
assert(instance.get_rect_red_ok());
|
||||||
|
@ -131,7 +131,7 @@ assert(instance.get_rect_black2_ok());
|
||||||
let instance = TestCase::new();
|
let instance = TestCase::new();
|
||||||
let instance = instance.as_ref();
|
let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 300.)));
|
||||||
assert!(instance.get_rect_blue_ok());
|
assert!(instance.get_rect_blue_ok());
|
||||||
assert!(instance.get_rect_orange_ok());
|
assert!(instance.get_rect_orange_ok());
|
||||||
assert!(instance.get_rect_red_ok());
|
assert!(instance.get_rect_red_ok());
|
||||||
|
|
|
@ -40,7 +40,7 @@ TestCase := Rectangle {
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 300, 300});
|
||||||
assert(instance.get_rect1_pos_ok());
|
assert(instance.get_rect1_pos_ok());
|
||||||
assert(instance.get_rect2_pos_ok());
|
assert(instance.get_rect2_pos_ok());
|
||||||
assert(instance.get_rect3_pos_ok());
|
assert(instance.get_rect3_pos_ok());
|
||||||
|
@ -54,7 +54,7 @@ assert(instance.get_rect6_pos_ok());
|
||||||
let instance = TestCase::new();
|
let instance = TestCase::new();
|
||||||
let instance = instance.as_ref();
|
let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 300.)));
|
||||||
assert!(instance.get_rect1_pos_ok());
|
assert!(instance.get_rect1_pos_ok());
|
||||||
assert!(instance.get_rect2_pos_ok());
|
assert!(instance.get_rect2_pos_ok());
|
||||||
assert!(instance.get_rect3_pos_ok());
|
assert!(instance.get_rect3_pos_ok());
|
||||||
|
|
|
@ -50,7 +50,7 @@ TestCase := Rectangle {
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 300, 300});
|
||||||
assert(instance.get_rect1_pos_ok());
|
assert(instance.get_rect1_pos_ok());
|
||||||
assert(instance.get_rect2_pos_ok());
|
assert(instance.get_rect2_pos_ok());
|
||||||
assert(instance.get_rect3_pos_ok());
|
assert(instance.get_rect3_pos_ok());
|
||||||
|
@ -62,7 +62,7 @@ assert(instance.get_rect4_pos_ok());
|
||||||
let instance = TestCase::new();
|
let instance = TestCase::new();
|
||||||
let instance = instance.as_ref();
|
let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 300.)));
|
||||||
assert!(instance.get_rect1_pos_ok());
|
assert!(instance.get_rect1_pos_ok());
|
||||||
assert!(instance.get_rect2_pos_ok());
|
assert!(instance.get_rect2_pos_ok());
|
||||||
assert!(instance.get_rect3_pos_ok());
|
assert!(instance.get_rect3_pos_ok());
|
||||||
|
|
|
@ -39,7 +39,7 @@ TestCase := Rectangle {
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 300, 300});
|
||||||
assert(instance.get_rect1_pos_ok());
|
assert(instance.get_rect1_pos_ok());
|
||||||
assert(instance.get_rect2_pos_ok());
|
assert(instance.get_rect2_pos_ok());
|
||||||
```
|
```
|
||||||
|
@ -49,7 +49,7 @@ assert(instance.get_rect2_pos_ok());
|
||||||
let instance = TestCase::new();
|
let instance = TestCase::new();
|
||||||
let instance = instance.as_ref();
|
let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 300.)));
|
||||||
assert!(instance.get_rect1_pos_ok());
|
assert!(instance.get_rect1_pos_ok());
|
||||||
assert!(instance.get_rect2_pos_ok());
|
assert!(instance.get_rect2_pos_ok());
|
||||||
```
|
```
|
||||||
|
|
|
@ -84,7 +84,7 @@ TestCase := Rectangle {
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
TestCase instance;
|
TestCase instance;
|
||||||
TestCase::compute_layout({&TestCase::component_type, &instance });
|
TestCase::apply_layout({&TestCase::component_type, &instance }, sixtyfps::Rect{0, 0, 300, 300});
|
||||||
assert(instance.get_test1());
|
assert(instance.get_test1());
|
||||||
assert(instance.get_test2());
|
assert(instance.get_test2());
|
||||||
assert(instance.get_test3());
|
assert(instance.get_test3());
|
||||||
|
@ -97,7 +97,7 @@ assert(instance.get_test5());
|
||||||
let instance = TestCase::new();
|
let instance = TestCase::new();
|
||||||
let instance = instance.as_ref();
|
let instance = instance.as_ref();
|
||||||
use sixtyfps::re_exports::Component;
|
use sixtyfps::re_exports::Component;
|
||||||
instance.compute_layout();
|
instance.apply_layout(sixtyfps::re_exports::Rect::new(Default::default(), sixtyfps::re_exports::Size::new(300., 300.)));
|
||||||
assert!(instance.get_test1());
|
assert!(instance.get_test1());
|
||||||
assert!(instance.get_test2());
|
assert!(instance.get_test2());
|
||||||
assert!(instance.get_test3());
|
assert!(instance.get_test3());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue