Layout refactoring: C++ part

This commit is contained in:
Olivier Goffart 2021-05-06 14:17:24 +02:00 committed by Olivier Goffart
parent 539a78e807
commit ba1aff84d0
8 changed files with 334 additions and 608 deletions

View file

@ -309,7 +309,6 @@ using cbindgen_private::LayoutAlignment;
using cbindgen_private::LayoutInfo;
using cbindgen_private::Padding;
using cbindgen_private::PathLayoutData;
using cbindgen_private::PathLayoutItemData;
using cbindgen_private::Rect;
using cbindgen_private::sixtyfps_box_layout_info;
using cbindgen_private::sixtyfps_grid_layout_info;
@ -346,6 +345,29 @@ inline LayoutInfo LayoutInfo::merge(const LayoutInfo &other) const
std::min(vertical_stretch, other.vertical_stretch) };
}
/// FIXME! this should be done by cbindgen
namespace cbindgen_private {
inline bool operator==(const LayoutInfo &a, const LayoutInfo &b)
{
return a.min_width == b.min_width &&
a.max_width == b.max_width &&
a.min_height == b.min_height &&
a.max_height == b.max_height &&
a.min_width_percent == b.min_width_percent &&
a.max_width_percent == b.max_width_percent &&
a.min_height_percent == b.min_height_percent &&
a.max_height_percent == b.max_height_percent &&
a.preferred_width == b.preferred_width &&
a.preferred_height == b.preferred_height &&
a.horizontal_stretch == b.horizontal_stretch &&
a.vertical_stretch == b.vertical_stretch;
}
inline bool operator!=(const LayoutInfo &a, const LayoutInfo &b)
{
return !(a == b);
}
}
// models
struct AbstractRepeaterView
{

View file

@ -133,7 +133,7 @@ public:
return a.inner == b.inner;
}
friend bool operator!=(const VRc &a, const VRc &b) {
return a.inner == b.inner;
return a.inner != b.inner;
}
};
@ -169,6 +169,13 @@ public:
}
VWeak<VTable, Dyn> into_dyn() const { return *reinterpret_cast<const VWeak<VTable, Dyn> *>(this); }
friend bool operator==(const VWeak &a, const VWeak &b) {
return a.inner == b.inner;
}
friend bool operator!=(const VWeak &a, const VWeak &b) {
return a.inner != b.inner;
}
};