# WoopsiUI::RectCache Class Reference

`#include <rectcache.h>`

List of all members.

## Public Member Functions
| RectCache (const Gadget *gadget)
| ~RectCache ()
void | cache ()
void | invalidate ()
WoopsiArray< Rect > * | getBackgroundRegions ()
WoopsiArray< Rect > * | getForegroundRegions ()
void | splitRectangles (WoopsiArray< Rect > *invalidRectangles, WoopsiArray< Rect > *validRects, const Gadget *sender) const
void | removeOverlappedRects (WoopsiArray< Rect > *visibleRects, WoopsiArray< Rect > *invisibleRects, const Gadget *gadget) const

## Detailed Description

Maintains a list of foreground (ie. above children) and background (with child overlapped-rects removed) rectangles representing the visible portions of a gadget.

## Constructor & Destructor Documentation

WoopsiUI::RectCache::RectCache | ( | const Gadget * | gadget | ) |

Constructor.

Parameters:

  | gadget | Gadget that contains the rect cache.

WoopsiUI::RectCache::~RectCache | ( |  | ) | `[inline]`

Destructor.

## Member Function Documentation

void WoopsiUI::RectCache::cache | ( |  | ) |

Rebuild the cache if it is invalid.

WoopsiArray<Rect>* WoopsiUI::RectCache::getBackgroundRegions | ( |  | ) | `[inline]`

Return the list of background regions. These are regions that are not overlapped by child gadgets.

Returns:
  The list of background regions.

WoopsiArray<Rect>* WoopsiUI::RectCache::getForegroundRegions | ( |  | ) | `[inline]`

Return the list of foreground regions. These are regions that represent the entire visible surface of the gadget - that is, any regions not overlapped by ancestors or sublings of the gadget - including any regions that are actually overlapped by child gadgets.

Returns:
  The list of foreground regions.

void WoopsiUI::RectCache::invalidate | ( |  | ) | `[inline]`

Invalidates the cache.

void WoopsiUI::RectCache::removeOverlappedRects | ( | WoopsiArray< Rect > * | visibleRects,
|  | WoopsiArray< Rect > * | invisibleRects,
|  | const Gadget * | gadget |
| ) |  |  | const

Move any rectangles from the visibleRects list that overlap this gadget into the invisibleRects list. Used during visible region calculations.

Parameters:

  | visibleRects | A vector of regions that are not overlapped.
  | invisibleRects | A vector of regions that are overlapped.
  | gadget | The gadget that requested the lists.

See also:
  splitRectangles()

void WoopsiUI::RectCache::splitRectangles | ( | WoopsiArray< Rect > * | invalidRectangles,
|  | WoopsiArray< Rect > * | validRects,
|  | const Gadget * | sender |
| ) |  |  | const

Works out which rectangles in the invalidRectangles list overlap this gadget, then cuts the rectangles into smaller pieces. The overlapping pieces are pushed into validRects, and the non-overlapping pieces are pushed back into the invalidRects vector.

Parameters:

  | invalidRectangles | A vector of regions that need to be tested for collisions against this gadget; they represent regions that need to be redrawn.
  | validRects | A vector of regions that represents areas of the display that do not need to be redrawn.
  | sender | Pointer to the gadget that initiated the split.

The documentation for this class was generated from the following file:

- rectcache.h