Interface SyWindowViewportAccumulatorType
- All Known Implementing Classes:
SyWindowViewportAccumulator
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 TypeMethodDescriptionvoidaccumulate(com.io7m.jregions.core.parameterized.areas.PAreaI<SySpaceParentRelativeType> box) Calculate a new viewport based on the given bounds.intmaximumX()intmaximumY()intminimumX()intminimumY()voidreset(int width, int height) Reset the accumulator to the given base size.voidrestore()Restore the viewport that was calculated before the most recent call toaccumulate(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 widthheight- The height
-
accumulate
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
restorecalls have been made thanaccumulatecalls, the viewport position is reset to(0, 0)and the size is reset to the most recent values given toreset(int, int)(or(0,0)if none exist).
-