Interface SyWindowViewportAccumulatorType

All Known Implementing Classes:
SyWindowViewportAccumulator

public interface SyWindowViewportAccumulatorType

The type of accumulators that calculate viewports for sets of components.

Whilst traversing a tree of components, a given component can only be rendered within the bounds of its parent component. The positions of components are given relative to their parents. Therefore, it's necessary to calculate the effective viewport for a component based on the values of its ancestors when performing bounds checks.

The viewport accumulator can be thought of as an implicit stack of viewports where each new position and size has the effect of trimming off a portion of the current viewport.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accumulate(com.io7m.jregions.core.parameterized.areas.PAreaI<SySpaceParentRelativeType> box)
    Calculate a new viewport based on the given bounds.
    int
     
    int
     
    int
     
    int
     
    void
    reset(int width, int height)
    Reset the accumulator to the given base size.
    void
    Restore the viewport that was calculated before the most recent call to accumulate(PAreaI).
  • Method Details

    • reset

      void reset(int width, int height)

      Reset the accumulator to the given base size. This is typically the width and height of a containing window. The width and height must be greater than or equal to 0.

      This will clear the internal accumulator stack.

      Parameters:
      width - The width
      height - The height
    • accumulate

      void accumulate(com.io7m.jregions.core.parameterized.areas.PAreaI<SySpaceParentRelativeType> box)

      Calculate a new viewport based on the given bounds.

      The calculated viewport will always be less than or equal to the previous viewport in size.

      Parameters:
      box - The bounds
    • minimumX

      int minimumX()
      Returns:
      The leftmost edge of the effective viewport
    • minimumY

      int minimumY()
      Returns:
      The top edge of the effective viewport
    • maximumX

      int maximumX()
      Returns:
      The rightmost edge of the effective viewport
    • maximumY

      int maximumY()
      Returns:
      The bottomost edge of the effective viewport
    • restore

      void restore()

      Restore the viewport that was calculated before the most recent call to accumulate(PAreaI).

      If more restore calls have been made than accumulate calls, the viewport position is reset to (0, 0) and the size is reset to the most recent values given to reset(int, int) (or (0,0) if none exist).