Does a component know its constrained size before Render()? #423
-
I have a view into a very large datagrid that I'm writing and it would be nice if it knew how large of a viewport it has to use. What's the best way to get this to happen? The main container is giving it a size() constraint like But I don't see how the component knows that constraint when it renders. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello! A component is responsible for creating the DOM (aka element) via Render(). Then the element is responsible for drawing on the screen Hence the following modules of FTXUI.
So a component can't know the size of a element it created, before drawing it on the screen However, you can know the size of an element after it has been drawn, using the Box box;
auto wrapped = element | reflect(&box); Note that box will be populated after the |
Beta Was this translation helpful? Give feedback.
Hello!
A component is responsible for creating the DOM (aka element) via Render(). Then the element is responsible for drawing on the screen
Hence the following modules of FTXUI.
So a component can't know the size of a element it created, before drawing it on the screen
However, you can know the size of an element after it has been drawn, using the
reflect
decorator.https://arthursonzogni.github.io/FTXUI/namespaceftxui.html#aaff8245861617a3d9e846e99de582a63
Box box; auto wrapped = element | reflect(&box);
Note that box will be populated after the
wrapped
has been rendered on the screen.So you will be able to use the information of the previous frame to buil…