Add Content variant for TextBoxSizeValue
PsichiX opened this issue · 3 comments
Right now text boxes can either fill all the available space or have exact unit size values, we need Content variant in TextBoxSizeValue that layout engine will use to make text box layout size exactly the size of text box contents.
To make that happen we would need to make an optional engine trait that will calculate exact size of the input TextBox unit. When user won't provide that engine, Content variant would report same value as Fill variant.
Would this also cover the ability to center text by using the alignment and margins from a ContentBoxItemLayout
property on the text box?
🤔 I think that should work, but I tried to do it once by just manually setting the size of the text box and for some reason I couldn't get it to line up right. I think I was doing something wrong, though, it was a while ago so I can't remember.
RAUI already has provision for setting the horizontal and vertical text alignment, but that only works if your rendering backend supports aligning the text, so that might not be the easiest solution for you if you are implementing your own backend.
To make that happen we would need to make an optional engine trait that will calculate exact size of the input TextBox unit. When user won't provide that engine, Content variant would report same value as Fill variant.
I might need this soon and I might get the chance to work on it, but I had a couple questions and wanted to make sure we're on the same track.
So the text rendering engine would need to get the following information from RAUI:
- The text
- The size of the text
- The font
- The maximum width and height of the text box. For example, if the user specified an exact width for the text box, then the text inside of it should wrap to that width, but if the user doesn't specify a width for the text box, then the text should wrap to the size of the text box if it were to
Fill
it's container.
Does that seem about right? Is there any pointers you would want to give if I were to try and implement this?