Engine improvements: User-interface – horizontal/vertical layout groups, on-screen keyboard and FreeType on Android, better UI scaling

Posted on

"The Unholy Society" fight UI, implemented with UI scaling and TCastleHorizontal/VerticalGroup layouts
"The Unholy Society" fight configuration UI (internal), using TCastleHorizontal/VerticalGroup layouts inside a scroll view
  1. We include new classes TCastleHorizontalGroup, TCastleVerticalGroup to easily layout your controls horizontally or vertically.

  2. FreeType library on Android (thanks to Benedikt Magnus!).

  3. TCastleEdit.AutoOnScreenKeyboard (also thanks to Benedikt Magnus!). Note that the keys from the on-screen keyboard are not yet automatically passed to your applications — we’re working on it.

  4. Many parts of the user-interface (TUIControl descendants) are now calculated using floating-point values, and can even be specified using floating-point values. E.g. you can now use FloatWidth instead of Width, CalculatedFloatWidth instead of CalculatedWidth, ScreenFloatRect instead of ScreenRect and so on. Some of the public properties have also just changed to be floats (like padding, margins, anchors deltas), which may break compatibility in rare cases.

    The primary reason for this change is that when using UI scaling, it doesn’t really make sense to limit sizes or positions to integers. They do not hit the exact pixel boundaries anyway (in case some UI scaling is applied), instead they should be rounded to pixels only at the very bottom of the rendering code. So anchors and such should be calculated using floats, otherwise a Round() in the middle of an operation (before we work in the “final” resolution) would needlessly make UI controls “snap” to an invisible grid.

    A minor reason is also that this is more friendly to animations. Although animations could be done earlier too (having an “animation driver” remember position as float). But it’s easier now, you can just animate existing float properties, like

    Control.AnchorHorizontalDelta := Control.AnchorHorizontalDelta + UpdateSeconds;

    in your OnUpdate event.

  5. Improvements to VisibleChange to help with implementing controls that react to children changes.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.