Skip to content

Commit

Permalink
make intrinsic size func public
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloamed committed Nov 4, 2024
1 parent f87941b commit 456112a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/vaev-layout/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static Math::Radii<Px> _computeRadii(Tree &tree, Box &box, Vec2Px size) {
return res;
}

static Vec2Px _computeIntrinsicSize(Tree &tree, Box &box, IntrinsicSize intrinsic, Vec2Px containingBlock) {
Vec2Px computeIntrinsicSize(Tree &tree, Box &box, IntrinsicSize intrinsic, Vec2Px containingBlock) {
if (intrinsic == IntrinsicSize::AUTO) {
panic("bad argument");
}
Expand All @@ -121,15 +121,15 @@ static Vec2Px _computeIntrinsicSize(Tree &tree, Box &box, IntrinsicSize intrinsi

static Opt<Px> _computeSpecifiedSize(Tree &tree, Box &box, Size size, Vec2Px containingBlock, bool isWidth) {
if (size == Size::MIN_CONTENT) {
auto intrinsicSize = _computeIntrinsicSize(tree, box, IntrinsicSize::MIN_CONTENT, containingBlock);
auto intrinsicSize = computeIntrinsicSize(tree, box, IntrinsicSize::MIN_CONTENT, containingBlock);
return isWidth ? intrinsicSize.x : intrinsicSize.y;
} else if (size == Size::MAX_CONTENT) {
auto intrinsicSize = _computeIntrinsicSize(tree, box, IntrinsicSize::MAX_CONTENT, containingBlock);
auto intrinsicSize = computeIntrinsicSize(tree, box, IntrinsicSize::MAX_CONTENT, containingBlock);
return isWidth ? intrinsicSize.x : intrinsicSize.y;
} else if (size == Size::FIT_CONTENT) {
auto minIntrinsicSize = _computeIntrinsicSize(tree, box, IntrinsicSize::MIN_CONTENT, containingBlock);
auto maxIntrinsicSize = _computeIntrinsicSize(tree, box, IntrinsicSize::MAX_CONTENT, containingBlock);
auto stretchIntrinsicSize = _computeIntrinsicSize(tree, box, IntrinsicSize::STRETCH_TO_FIT, containingBlock);
auto minIntrinsicSize = computeIntrinsicSize(tree, box, IntrinsicSize::MIN_CONTENT, containingBlock);
auto maxIntrinsicSize = computeIntrinsicSize(tree, box, IntrinsicSize::MAX_CONTENT, containingBlock);
auto stretchIntrinsicSize = computeIntrinsicSize(tree, box, IntrinsicSize::STRETCH_TO_FIT, containingBlock);

if (isWidth)
return clamp(stretchIntrinsicSize.x, minIntrinsicSize.x, maxIntrinsicSize.x);
Expand Down
2 changes: 2 additions & 0 deletions src/vaev-layout/layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ InsetsPx computeMargins(Tree &tree, Box &box, Input input);

InsetsPx computeBorders(Tree &tree, Box &box);

Vec2Px computeIntrinsicSize(Tree &tree, Box &box, IntrinsicSize intrinsic, Vec2Px containingBlock);

Output layout(Tree &tree, Box &box, Input input);

} // namespace Vaev::Layout

0 comments on commit 456112a

Please sign in to comment.