Engine API Reference
    Preparing search index...

    Class LayoutGroupComponent

    A LayoutGroupComponent enables the Entity to position and scale child ElementComponents according to configurable layout rules.

    Hierarchy (View Summary)

    Index

    Properties

    entity: Entity

    The Entity that this Component is attached to.

    The ComponentSystem used to create this Component.

    Accessors

    • get alignment(): Vec2

      Gets the horizontal and vertical alignment of child elements.

      Returns Vec2

    • set alignment(value: Vec2): void

      Sets the horizontal and vertical alignment of child elements. Values range from 0 to 1 where [0, 0] is the bottom left and [1, 1] is the top right. Defaults to [0, 1].

      Parameters

      Returns void

    • get enabled(): boolean

      Gets the enabled state of the component.

      Returns boolean

    • set enabled(arg: boolean): void

      Sets the enabled state of the component.

      Parameters

      • arg: boolean

      Returns void

    • get heightFitting(): number

      Gets the height fitting mode to be applied when positioning and scaling child elements.

      Returns number

    • set heightFitting(value: number): void

      Sets the height fitting mode to be applied when positioning and scaling child elements. Identical to LayoutGroupComponent#widthFitting but for the Y axis. Defaults to FITTING_NONE.

      Parameters

      • value: number

      Returns void

    • get orientation(): number

      Gets whether the layout should run horizontally or vertically.

      Returns number

    • set orientation(value: number): void

      Sets whether the layout should run horizontally or vertically. Can be:

      Defaults to ORIENTATION_HORIZONTAL.

      Parameters

      • value: number

      Returns void

    • get padding(): Vec4

      Gets the padding to be applied inside the container before positioning any children.

      Returns Vec4

    • set padding(value: Vec4): void

      Sets the padding to be applied inside the container before positioning any children. Specified as left, bottom, right and top values. Defaults to [0, 0, 0, 0] (no padding).

      Parameters

      Returns void

    • get reverseX(): boolean

      Gets whether to reverse the order of children along the x axis.

      Returns boolean

    • set reverseX(value: boolean): void

      Sets whether to reverse the order of children along the x axis. Defaults to false.

      Parameters

      • value: boolean

      Returns void

    • get reverseY(): boolean

      Gets whether to reverse the order of children along the y axis.

      Returns boolean

    • set reverseY(value: boolean): void

      Sets whether to reverse the order of children along the y axis. Defaults to true.

      Parameters

      • value: boolean

      Returns void

    • get spacing(): Vec2

      Gets the spacing to be applied between each child element.

      Returns Vec2

    • set spacing(value: Vec2): void

      Sets the spacing to be applied between each child element. Defaults to [0, 0] (no spacing).

      Parameters

      Returns void

    • get widthFitting(): number

      Gets the width fitting mode to be applied when positioning and scaling child elements.

      Returns number

    • set widthFitting(value: number): void

      Sets the width fitting mode to be applied when positioning and scaling child elements. Can be:

      Defaults to FITTING_NONE.

      Parameters

      • value: number

      Returns void

    • get wrap(): boolean

      Gets whether or not to wrap children onto a new row/column when the size of the container is exceeded.

      Returns boolean

    • set wrap(value: boolean): void

      Sets whether or not to wrap children onto a new row/column when the size of the container is exceeded. Defaults to false, which means that children will be be rendered in a single row (horizontal orientation) or column (vertical orientation). Note that setting wrap to true makes it impossible for the FITTING_BOTH fitting mode to operate in any logical manner. For this reason, when wrap is true, a LayoutGroupComponent#widthFitting or LayoutGroupComponent#heightFitting mode of FITTING_BOTH will be coerced to FITTING_STRETCH.

      Parameters

      • value: boolean

      Returns void

    Methods

    • Fire an event, all additional arguments are passed on to the event listener.

      Parameters

      • name: string

        Name of event to fire.

      • Optionalarg1: any

        First argument that is passed to the event handler.

      • Optionalarg2: any

        Second argument that is passed to the event handler.

      • Optionalarg3: any

        Third argument that is passed to the event handler.

      • Optionalarg4: any

        Fourth argument that is passed to the event handler.

      • Optionalarg5: any

        Fifth argument that is passed to the event handler.

      • Optionalarg6: any

        Sixth argument that is passed to the event handler.

      • Optionalarg7: any

        Seventh argument that is passed to the event handler.

      • Optionalarg8: any

        Eighth argument that is passed to the event handler.

      Returns EventHandler

      Self for chaining.

      obj.fire('test', 'This is the message');
      
    • Test if there are any handlers bound to an event name.

      Parameters

      • name: string

        The name of the event to test.

      Returns boolean

      True if the object has handlers bound to the specified event name.

      obj.on('test', () => {}); // bind an event to 'test'
      obj.hasEvent('test'); // returns true
      obj.hasEvent('hello'); // returns false
    • Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.

      Parameters

      • Optionalname: string

        Name of the event to unbind.

      • Optionalcallback: HandleEventCallback

        Function to be unbound.

      • Optionalscope: any

        Scope that was used as the this when the event is fired.

      Returns EventHandler

      Self for chaining.

      const handler = () => {};
      obj.on('test', handler);

      obj.off(); // Removes all events
      obj.off('test'); // Removes all events called 'test'
      obj.off('test', handler); // Removes all handler functions, called 'test'
      obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
    • Attach an event handler to an event.

      Parameters

      • name: string

        Name of the event to bind the callback to.

      • callback: HandleEventCallback

        Function that is called when event is fired. Note the callback is limited to 8 arguments.

      • Optionalscope: any = ...

        Object to use as 'this' when the event is fired, defaults to current this.

      Returns EventHandle

      Can be used for removing event in the future.

      obj.on('test', (a, b) => {
      console.log(a + b);
      });
      obj.fire('test', 1, 2); // prints 3 to the console
      const evt = obj.on('test', (a, b) => {
      console.log(a + b);
      });
      // some time later
      evt.off();
    • Attach an event handler to an event. This handler will be removed after being fired once.

      Parameters

      • name: string

        Name of the event to bind the callback to.

      • callback: HandleEventCallback

        Function that is called when event is fired. Note the callback is limited to 8 arguments.

      • Optionalscope: any = ...

        Object to use as 'this' when the event is fired, defaults to current this.

      Returns EventHandle

      • can be used for removing event in the future.
      obj.once('test', (a, b) => {
      console.log(a + b);
      });
      obj.fire('test', 1, 2); // prints 3 to the console
      obj.fire('test', 1, 2); // not going to get handled