Class BuiltInComposite<T extends org.inspirenxe.strata.api.component.Component<T>>

java.lang.Object
org.inspirenxe.strata.core.node.BuiltInComponent<T>
org.inspirenxe.strata.core.node.BuiltInComposite<T>
Type Parameters:
T - the type callers see the component as
All Implemented Interfaces:
org.inspirenxe.strata.api.component.Component<T>, org.inspirenxe.strata.api.component.Enableable<T>, org.inspirenxe.strata.api.event.EventTarget<T>
Direct Known Subclasses:
BuiltInContainer, ColorPickerImpl, ExpanderImpl, FlyoutImpl, GridViewImpl, InfoBarImpl, ListViewImpl, MessageBoxImpl, NavigationViewImpl, PasswordTextBoxImpl, SpinnerImpl, SplitPaneImpl, TabBarImpl, TableViewImpl, TreeViewImpl

public abstract class BuiltInComposite<T extends org.inspirenxe.strata.api.component.Component<T>> extends BuiltInComponent<T>
Base class of Strata's own controls that are built from private parts, the counterpart of the public CustomComposite. Its node is a ContainerNode whose children callers cannot reach. Control events of a part added with addChild(Component) stop here; those of content added with addContent(Component) pass on. BuiltInContainer extends it and makes the children public.

In BuiltInComponent.measure(MeasureContext, float, float) measure every child and in arrange(ArrangeContext, Rect) give every child a slot, hidden ones included, as CustomComposite requires.

  • Constructor Details

    • BuiltInComposite

      protected BuiltInComposite(ComponentFactoryImpl factory)
      Creates the component and its node, whose children are private parts.
      Parameters:
      factory - the factory of the host that will show this component
  • Method Details

    • node

      protected final ContainerNode node()
      Returns the container node behind this component.
      Overrides:
      node in class BuiltInComponent<T extends org.inspirenxe.strata.api.component.Component<T>>
      Returns:
      the node
    • arrange

      protected abstract void arrange(org.inspirenxe.strata.api.extension.ArrangeContext context, org.inspirenxe.strata.api.geometry.Rect bounds)
      Gives every child its slot. Called after BuiltInComponent.measure(MeasureContext, float, float), with the component's final bounds, and again with the same bounds after invalidateArrangement().
      Parameters:
      context - child sizes and slot assignment
      bounds - the component's bounds
    • onChildRemoved

      protected void onChildRemoved(org.inspirenxe.strata.api.component.Component<?> child)
      Called after a child is removed, to drop any data kept about it. The default does nothing.
      Parameters:
      child - the removed child
    • childClip

      protected org.inspirenxe.strata.api.geometry.Rect childClip()
      Returns the rectangle children are clipped to and hit-tested against, unless setChildClipping(boolean) turned clipping off. Called during painting and hit testing. The default is the bounds.
      Returns:
      the clip, in the host's coordinates
    • paintOverChildren

      protected void paintOverChildren(org.inspirenxe.strata.api.extension.Painter painter, org.inspirenxe.strata.api.geometry.Rect bounds)
      Draws after the children, on top of them and outside their clip. The default draws nothing.
      Parameters:
      painter - what to draw with; valid only during this call
      bounds - the component's bounds
    • onDescendantFocused

      protected void onDescendantFocused(org.inspirenxe.strata.api.component.Component<?> descendant)
      Called after focus moves to a component inside this one, on every ancestor of it, innermost first. The default does nothing.
      Parameters:
      descendant - the component that gained focus
    • invalidateArrangement

      protected final void invalidateArrangement()
      Asks for this component to be arranged again in its last bounds before the next frame, without measuring anything.
    • childList

      protected final List<org.inspirenxe.strata.api.component.Component<?>> childList()
      Returns the children in layout order, the order focus and Tab follow. They are drawn by z index and then in the order they were added, raised or lowered; later ones draw on top and are hit first.
      Returns:
      a live, unmodifiable view
    • addChild

      protected final void addChild(org.inspirenxe.strata.api.component.Component<?> child)
      Adds a private part at the end. Its control events, and those of anything inside it, stop at this component.
      Parameters:
      child - the child
      Throws:
      IllegalArgumentException - if the child already has a parent, is a host's content, would create a cycle, or was made by another factory
    • insertChild

      protected final void insertChild(int index, org.inspirenxe.strata.api.component.Component<?> child)
      Adds a private part at a place in the layout order, which is also the tree order Tab follows. It is drawn over the existing children with the same z index, as a part added at the end is.
      Parameters:
      index - where the child goes: 0 for the first, the number of children for the last
      child - the child
      Throws:
      IndexOutOfBoundsException - if the index is negative or greater than the number of children
      IllegalArgumentException - if the child already has a parent, this component included, is a host's content, would create a cycle, or was made by another factory
    • addContent

      protected final void addContent(org.inspirenxe.strata.api.component.Component<?> child)
      Adds a child that is content shown for the user, such as a cell from the user's cell factory. Its control events, and those of anything inside it, pass this component and every composite above it.
      Parameters:
      child - the child
      Throws:
      IllegalArgumentException - if the child already has a parent, is a host's content, would create a cycle, or was made by another factory
    • insertContent

      protected final void insertContent(int index, org.inspirenxe.strata.api.component.Component<?> child)
      Adds content, as addContent(Component) does, at a place in the layout order, which is also the tree order Tab follows. Only core can do this.
      Parameters:
      index - where the child goes: 0 for the first, the number of children for the last
      child - the child
      Throws:
      IndexOutOfBoundsException - if the index is negative or greater than the number of children
      IllegalArgumentException - if the child already has a parent, is a host's content, would create a cycle, or was made by another factory
    • moveChild

      protected final void moveChild(org.inspirenxe.strata.api.component.Component<?> child, int index)
      Moves a child to another place in the layout order. The child stays attached, keeps focus, hover and press state, and fires no events of leaving or joining the tree. Layout runs again; where the child is drawn does not change.
      Parameters:
      child - the child
      index - the place it ends up at, from 0 to the number of children minus one
      Throws:
      IllegalArgumentException - if the component is not a child of this component
      IndexOutOfBoundsException - if the index is negative or not less than the number of children
    • raiseChild

      protected final void raiseChild(org.inspirenxe.strata.api.component.Component<?> child)
      Draws a child over its siblings with the same z index, and lets the pointer hit it first among them. Nothing is laid out again.
      Parameters:
      child - the child
      Throws:
      IllegalArgumentException - if the component is not a child of this component
    • lowerChild

      protected final void lowerChild(org.inspirenxe.strata.api.component.Component<?> child)
      Draws a child under its siblings with the same z index, so the pointer hits it last among them. Nothing is laid out again.
      Parameters:
      child - the child
      Throws:
      IllegalArgumentException - if the component is not a child of this component
    • removeChild

      protected final void removeChild(org.inspirenxe.strata.api.component.Component<?> child)
      Removes a child. Does nothing if it is not a child of this component.
      Parameters:
      child - the child
    • clearChildren

      protected final void clearChildren()
      Removes every child.
    • setChildClipping

      protected final void setChildClipping(boolean clip)
      Sets whether children are clipped to childClip(). Children are clipped by default. A BuiltInContainer reports the setting through its public clipsChildren().
      Parameters:
      clip - false to let children draw and be hit outside it