Skip to content

Does a component know its constrained size before Render()? #423

Answered by ArthurSonzogni
jsholmes asked this question in Q&A
Discussion options

You must be logged in to vote

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.

  • component/
  • element/
  • screen/

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…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ArthurSonzogni
Comment options

@jsholmes
Comment options

Answer selected by ArthurSonzogni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants