mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 22:01:13 +00:00
Fix preferred size of the Window with a layout
A few problem: - the horizontal and vertical property were swapped - The implementation of the "preferred_xxx" property was not materialized properly because the `bindings` were borrowed in the materialize_fake_properties pass - Since the Window has a stretch factor of 0., the preferred size of the inner layout was not taken into account when merging the LayoutInfo. I believe taking the maximum preferred size is the right solution when merging them.
This commit is contained in:
parent
0a3ec534ae
commit
a0bea36e43
5 changed files with 74 additions and 42 deletions
|
@ -321,22 +321,11 @@ using cbindgen_private::sixtyfps_solve_path_layout;
|
|||
inline LayoutInfo LayoutInfo::merge(const LayoutInfo &other) const
|
||||
{
|
||||
// Note: This "logic" is duplicated from LayoutInfo::merge in layout.rs.
|
||||
const auto merge_preferred_size = [](float left_stretch, float left_size, float right_stretch,
|
||||
float right_size) -> float {
|
||||
if (left_stretch < right_stretch) {
|
||||
return left_size;
|
||||
} else if (left_stretch > right_stretch) {
|
||||
return right_size;
|
||||
} else {
|
||||
return (left_size + right_size) / 2.;
|
||||
}
|
||||
};
|
||||
return LayoutInfo { std::max(min, other.min),
|
||||
std::min(max, other.max),
|
||||
std::max(min_percent, other.min_percent),
|
||||
std::min(max_percent, other.max_percent),
|
||||
merge_preferred_size(stretch, preferred,
|
||||
other.stretch, other.preferred),
|
||||
std::max(preferred, other.preferred),
|
||||
std::min(stretch, other.stretch) };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue