-
I'm making a grid widget for Iced using Taffy. In my API I let users supply a vector of columns widths and I'm now trying to figure out how to pass these to Taffy. I see there's a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Firstly, you probably want taffy.set_style(node, Style {
grid_template_columns: vec![auto(), length(10.0), percent(10.0), fr()],
..
}); The different types of column size are:
See also the runnable example in the example directory of the repo: https://github.com/DioxusLabs/taffy/blob/main/examples/grid_holy_grail.rs Note that caching is super important for performance when using Taffy (because without it time complexity is exponential with respect to the depth of the tree - in the worst case: if you don't use any of the content based column sizes you might be able to avoid this), so you'll likely want to make sure that you are caching results. I did submit a PR to Iced to help with performance (iced-rs/iced#1722) on the back of which I was planning to make a first-party integration with Iced (see https://github.com/nicoburns/iced_taffy). But unfortunately that PR was rejected. |
Beta Was this translation helpful? Give feedback.
Firstly, you probably want
grid_template_columns
rather thangrid_auto_columns
.grid_auto_columns
is for determining the size of columns that are not declared up front as part of the "explicit grid" but created implicitly when a child is placed in row/column that is outside of the bounds of that grid. The easiest way to set each column's size is using the helper functions in thestyle_helpers
module (https://docs.rs/taffy/latest/taffy/style_helpers/index.html). An example would be:The different types of column size are:
length(f32)
- a fixed pixel column sizepercent(f32)
…