Skip to content

Commit c5e61ee

Browse files
committed
Use includedSubviews in wrapContent(_:padding:_:)
1 parent 88dac6e commit c5e61ee

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Sources/PinLayout+WrapContent.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ import AppKit
2525

2626
extension PinLayout {
2727
/**
28-
Adjust the view's width & height to wrap all its subviews. The method also adjust subviews position to create a tight wrap.
28+
Adjust the view's width & height to wrap all its subviews that are included in the size calculation. The method also adjust subviews position to create a tight wrap.
2929
*/
3030
@discardableResult
3131
public func wrapContent() -> PinLayout {
3232
return wrapContent(.all, padding: PEdgeInsets(top: 0, left: 0, bottom: 0, right: 0), { return "wrapContent()" })
3333
}
3434

3535
/**
36-
Adjust the view's width & height to wrap all its subviews. The method also adds a padding around all subviews.
36+
Adjust the view's width & height to wrap all its subviews that are included in the size calculation. The method also adds a padding around all subviews.
3737

3838
- Parameters:
3939
- padding: Specify a padding value.
@@ -45,7 +45,7 @@ extension PinLayout {
4545

4646
/**
4747
The method...
48-
- Adjust the view's width and height to wrap all its subviews.
48+
- Adjust the view's width and height to wrap all its subviews that are included in the size calculation.
4949
- Adjust subviews's position to create a tight wrap.
5050
- Apply padding around all subviews.
5151

@@ -59,7 +59,7 @@ extension PinLayout {
5959

6060
/**
6161
The method...
62-
- Adjust the view's width and height to wrap all its subviews.
62+
- Adjust the view's width and height to wrap all its subviews that are included in the size calculation.
6363
- Adjust subviews's position to create a tight wrap.
6464

6565
- Parameters:
@@ -72,7 +72,7 @@ extension PinLayout {
7272

7373
/**
7474
The method...
75-
- Adjust the view's width and height to wrap all its subviews.
75+
- Adjust the view's width and height to wrap all its subviews that are included in the size calculation.
7676
- Adjust subviews's position to create a tight wrap.
7777
- Apply padding around all subviews.
7878

@@ -87,7 +87,7 @@ extension PinLayout {
8787

8888
/**
8989
The method...
90-
- Adjust the view's width and height to wrap all its subviews.
90+
- Adjust the view's width and height to wrap all its subviews that are included in the size calculation.
9191
- Adjust subviews's position to create a tight wrap.
9292
- Apply padding around all subviews.
9393

@@ -101,11 +101,11 @@ extension PinLayout {
101101
}
102102

103103
private func wrapContent(_ type: WrapType, padding: PEdgeInsets, _ context: Context) -> PinLayout {
104-
let subviews = view.subviews
105-
guard !subviews.isEmpty else { return self }
104+
let includedSubviews = view.subviewsIncludedInSizeCalculation
105+
guard !includedSubviews.isEmpty else { return self }
106106

107-
let firstViewRect = subviews[0].getRect(keepTransform: keepTransform)
108-
let boundingRect = subviews.reduce(firstViewRect, { (result, view) in
107+
let firstViewRect = includedSubviews[0].getRect(keepTransform: keepTransform)
108+
let boundingRect = includedSubviews.reduce(firstViewRect, { (result, view) in
109109
result.union(view.getRect(keepTransform: keepTransform))
110110
})
111111

@@ -131,7 +131,7 @@ extension PinLayout {
131131
}
132132

133133
if offsetDx != 0 || offsetDy != 0 {
134-
subviews.forEach { (view) in
134+
includedSubviews.forEach { (view) in
135135
let viewRect = view.getRect(keepTransform: keepTransform)
136136
let newRect = viewRect.offsetBy(dx: offsetDx, dy: offsetDy)
137137
view.setRect(newRect, keepTransform: keepTransform)

0 commit comments

Comments
 (0)