clip_rect coordinates

Darren V Hart <[email protected]> Thu, 25 Sep 2003 18:29:47 -0600
Newsgroups gmane.comp.embedded.stk.gui.devel
Message-ID <1064536187.30104.31.camel@brain>
Team,

The problem with test_app drawing the wrong portion of the parrots image
was a result of the viewport calling container::draw(surface, rect()). 
Instead of rect() it should use:

container::draw(surface, clip_rect.empty() ? rect() : clip_rect);

This passes either the clip_rect passed in (which is in the proper
coords or rect() which is still the wrong coords).

So it is still broken if clip_rect is .empty().  This reflects a problem
in the entire drawing mechanism!  All widgets set the clip rect with
that tertiary statement, so whenever a clip_rect isn't passed, it
breaks!  This would fix it:

rectangle t_rect = rect();
t_rect.position(point(0,0));
...surface, clip_rect.empty() ? t_rect : clip_rect...

That way the clip_rect passed to the surface and to children draw
routines is always in the widget's respective local coords (with upper
left being 0,0).  This is ugly though.  I think that the clip_rect could
be set by containers and that leaf widgets should never have to worry
about it.  Perhaps we can remove the surface->clip_rect(...) statement
can removed from every leaf widget and have the container::draw_child()
routine take of it?  Any objections there?

Darren