November Engine Features (Part 2): TCastleUserInterface (borders, culling, clipping, events…)

Posted on

Fight in "The Unholy Society" ( unholy-society.com )
Castle Game Engine Editor - design with borders and scene manager

A lot of work to improve our main user interface class TCastleUserInterface (formerly called TUIControl), from which all other UI controls descend:

  1. Border and BorderColor allow to draw borders around any UI control. Transparent borders are also incredibly useful, to add space around the control, or to reserve free space for sibling controls. For example, this allows to set one control to have height equal to 100 pixels, and the other control to just “fill the rest of the parent”.

    Borders work reliably in all circumstances. Including when you adjust size using AutoSizeToChildren, or FullSize, or WidthFraction or HeightFraction.

  2. To adjust size to a given percent of the parent, WidthFraction and HeightFraction are now available.

    The EffectiveRect documentation summarizes various sizing options.

  3. To better control the AutoSizeToChildren effects, we added new AutoSizeToChildrenPaddingRight and AutoSizeToChildrenPaddingTop.

  4. Any control can now clip overflowing children by using ClipChildren.

  5. Turn on Culling to optimize the case when a resource-intensive control is often off-screen (and thus doesn’t need to be rendered or process other events).

    This also matters if the control is outside of the parent scrollable view (TCastleScrollView) or other parent with ClipChildren. This is very useful when creating a large number of children inside TCastleScrollView.

  6. We have optimized and improved internal measuring of the control. It now uses an internal (protected) PreferredSize method, and is cached for some brief moments (during rendering), and is secured from recursive loop (in case the parent’s size depends on the child, but the child’s size depends on the parent).

  7. A number of events are now available: OnPress, OnRelease, OnMotion, OnUpdate, OnRender. These allow to react to UI events without creating new descendants of each UI class.

  8. SetTransient allows to mark the component as internal. This is useful for internal components of TCastleCheckbox or TCastleDesign.

Leave a Reply

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