raui icon indicating copy to clipboard operation
raui copied to clipboard

Add Content variant for TextBoxSizeValue

Open PsichiX opened this issue 4 years ago • 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.

PsichiX avatar May 09 '21 18:05 PsichiX

Would this also cover the ability to center text by using the alignment and margins from a ContentBoxItemLayout property on the text box?

temportalflux avatar Jun 03 '21 16:06 temportalflux

:thinking: 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.

zicklag avatar Jun 03 '21 16:06 zicklag

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?

zicklag avatar Jun 14 '21 16:06 zicklag