diff options
author | 2020-11-23 17:19:21 +0000 | |
---|---|---|
committer | 2021-06-01 19:05:39 +0700 | |
commit | fe0a27c56d9d75fb521e69352259f1d737402a20 (patch) | |
tree | f7f77430b63983717036a81e734276123d139ca6 /native/src/layout/flex.rs | |
parent | a9eb591628017caaf7aa9af505d1206f7a143a9a (diff) | |
download | iced-fe0a27c56d9d75fb521e69352259f1d737402a20.tar.gz iced-fe0a27c56d9d75fb521e69352259f1d737402a20.tar.bz2 iced-fe0a27c56d9d75fb521e69352259f1d737402a20.zip |
Add support for asymmetrical padding
Diffstat (limited to '')
-rw-r--r-- | native/src/layout/flex.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/native/src/layout/flex.rs b/native/src/layout/flex.rs index 4f6523fb..3d3ff82c 100644 --- a/native/src/layout/flex.rs +++ b/native/src/layout/flex.rs @@ -16,9 +16,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + use crate::{ layout::{Limits, Node}, - Align, Element, Point, Size, + Align, Element, Padding, Point, Size, }; /// The main axis of a flex layout. @@ -62,7 +63,7 @@ pub fn resolve<Message, Renderer>( axis: Axis, renderer: &Renderer, limits: &Limits, - padding: f32, + padding: Padding, spacing: f32, align_items: Align, items: &[Element<'_, Message, Renderer>], @@ -141,14 +142,15 @@ where } } - let mut main = padding; + let pad = axis.pack(padding.left as f32, padding.top as f32); + let mut main = pad.0; for (i, node) in nodes.iter_mut().enumerate() { if i > 0 { main += spacing; } - let (x, y) = axis.pack(main, padding); + let (x, y) = axis.pack(main, pad.1); node.move_to(Point::new(x, y)); @@ -166,7 +168,7 @@ where main += axis.main(size); } - let (width, height) = axis.pack(main - padding, cross); + let (width, height) = axis.pack(main - pad.0, cross); let size = limits.resolve(Size::new(width, height)); Node::with_children(size.pad(padding), nodes) |