Thinking some more about the last post, I’ve worked out a way of using almost the same system to greatly improve the screen drawing system. It works like this:
- Gadget to be drawn (a dragged window, for example, or a superbitmap updated by a VBL event) sends a draw request to the screen.
- The screen locates the window in the stack, gets its dimensions, and sends the rectangle to all windows higher up the stack than the current window.
- Each higher window checks for collisions with the rectangle, and removes itself from the rectangle (here we need to do the vector of rectangles thing again).
- Once each higher window has been processed, the screen sends the rectangle vector back to the original window.
- The window uses the same clipping techniques as in the refresh algorithm to draw the visible parts of itself to the screen.
This will mean I won’t need to make the active window the top window, and Pong won’t overlap the calculator demo any more.