Skip to content

Commit 2a144e7

Browse files
authored
Merge pull request #3005 from iced-rs/feature/markdown-quotes
Quotes for `markdown` widget
2 parents 9ef2c46 + 946e2a7 commit 2a144e7

27 files changed

+190
-48
lines changed

core/src/layout/flex.rs

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,24 @@ where
137137
//
138138
// We use the maximum cross length obtained in the first pass as the maximum
139139
// cross limit.
140+
//
141+
// We can defer the layout of any elements that have a fixed size in the main axis,
142+
// allowing them to use the cross calculations of the next pass.
140143
if cross_compress && some_fill_cross {
141144
for (i, (child, tree)) in items.iter().zip(trees.iter_mut()).enumerate()
142145
{
143-
let (fill_main_factor, fill_cross_factor) = {
146+
let (main_size, cross_size) = {
144147
let size = child.as_widget().size();
145148

146-
axis.pack(size.width.fill_factor(), size.height.fill_factor())
149+
axis.pack(size.width, size.height)
147150
};
148151

149-
if fill_main_factor == 0 && fill_cross_factor != 0 {
152+
if main_size.fill_factor() == 0 && cross_size.fill_factor() != 0 {
153+
if let Length::Fixed(main) = main_size {
154+
available -= main;
155+
continue;
156+
}
157+
150158
let (max_width, max_height) = axis.pack(available, cross);
151159

152160
let child_limits =
@@ -176,9 +184,9 @@ where
176184
};
177185

178186
// THIRD PASS
179-
// We only have the elements that are fluid in the main axis left.
187+
// We lay out the elements that are fluid in the main axis.
180188
// We use the remaining space to evenly allocate space based on fill factors.
181-
for (i, (child, tree)) in items.iter().zip(trees).enumerate() {
189+
for (i, (child, tree)) in items.iter().zip(trees.iter_mut()).enumerate() {
182190
let (fill_main_factor, fill_cross_factor) = {
183191
let size = child.as_widget().size();
184192

@@ -224,10 +232,43 @@ where
224232
}
225233
}
226234

235+
// FOURTH PASS (conditional)
236+
// We lay out any elements that were deferred in the second pass.
237+
// These are elements that must be compressed in their cross axis and have
238+
// a fixed length in the main axis.
239+
if cross_compress && some_fill_cross {
240+
for (i, (child, tree)) in items.iter().zip(trees).enumerate() {
241+
let (main_size, cross_size) = {
242+
let size = child.as_widget().size();
243+
244+
axis.pack(size.width, size.height)
245+
};
246+
247+
if cross_size.fill_factor() != 0 {
248+
let Length::Fixed(main) = main_size else {
249+
continue;
250+
};
251+
252+
let (max_width, max_height) = axis.pack(main, cross);
253+
254+
let child_limits =
255+
Limits::new(Size::ZERO, Size::new(max_width, max_height));
256+
257+
let layout =
258+
child.as_widget().layout(tree, renderer, &child_limits);
259+
let size = layout.size();
260+
261+
cross = cross.max(axis.cross(size));
262+
263+
nodes[i] = layout;
264+
}
265+
}
266+
}
267+
227268
let pad = axis.pack(padding.left, padding.top);
228269
let mut main = pad.0;
229270

230-
// FOURTH PASS
271+
// FIFTH PASS
231272
// We align all the laid out nodes in the cross axis, if needed.
232273
for (i, node) in nodes.iter_mut().enumerate() {
233274
if i > 0 {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12ba47a34ed415825a23f8ef377a2d52950d2f8614a66bf46c0ec28d0cf15c85
1+
30570747bb062e9f7730cdd58be961c84bcf4711a6983185bff6d903e8d29e9c
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fa00d7e0ff95b366945d409712d7fe4ce44fff22425236cb56b8b96a88815ee6
1+
039a950d09d34df222606eaf2166e65f86d5536f8abfaff0e295219c974d54c0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4e594cfec775d51f7f836646c59bf4a2de07252721d66ddddea69c17e9112bae
1+
30e523961db89a3ee97ad1eac09e727ecb3dec485faa362534a9f5ad083b32dd
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2ab665b51387c61086ae0199c29e291105bfe4583bd4c4daa652e30917f10bd6
1+
bce5427d5105f68e1d7fa18a34fcc551cb78c2fefd9a583ba44686331133436d
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
61c9ee377b33ffa800f512877e45ad5f41fbac36f5d3f06d1b62d6af6ee9d7b2
1+
c8a7edbd5a8bbf559134b84253e14e65340f4ffe3e22c272b21c8438e47ffaf7
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
75f2fb12c9090a256708515de01a25e78905f71e134b7cda79f4fe44b2434052
1+
63d646b22d3dffbb56dac2e3f345090bd26625a388dd6cc142359f2a7ac9c8df
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b4a1b42d2e21b2a493605745e6beb8e1f28cbeb01b73336e1e8d9061249a8311
1+
d26f55674cbd96bc3b534ffdd098a13199718ef9c5ffe8ece0882ddab714b776
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
eb52921b3ee23e1814268701c935d0dff387e7eb741c50443f75a7ab902b5e44
1+
482c44c13d4ff3de19e71f3dddf93bbee170e54e2d353e818811069de28e18ed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bf6c4cbd6eeed0167d28509e37292f5ce26ed1d58bb156bedb861d0619a1945b
1+
6738cc4fc6eb8a5d406c613a4b0f08c0e8dcd2c1a5444445eebd3888f9303841

0 commit comments

Comments
 (0)