Summary: NSClipView should redraw when bounds change
Submitted by: Deek
Submitted on: Mon 02 Dec 2013 11:07:18 AM EST
Severity: 3 - Normal
Item Group: Bug
Assigned to: None
Discussion Lock: Any
When changing zoom factor, TextEdit just changes the clipview's bounds, on the
assumption that the clipview will automatically mark itself as needing
display. GNUstep's doesn't, so the display is messed up until the user
When doing the patch, the very first thing I tried was marking only the
document view as needing display, but the document view does not have to fill
Because of this fact, there may be quite a lot of area that /was/ covered by
the document view that no longer is.
If you have a 1000x1000 documentview and scale or otherwise resize it to
100x100, telling the documentview to redraw will only redraw the 100x100 area
the documentview now fills, leaving the rest of the clipview unchanged (even
though it's still full of the clipview's former contents).
That's why the clipview (_and_ the documentview inside it, but that's handled
anyway) needs to be redrawn.
Could you please try the code and see if the problem you are expecting really
I would like to have the code in setBounds: and setBoundsSize: in line with
the code in the method setBoundsOrigin: and there we only set the
_documentView as needing redisplay. This may be wrong, but we never had a bug
report on this and that code has been in GNUstep for a long time. For this
reason I would only like to change this, if there is a proven problem with
I moved this bug report back to open to make it easier to find for others
Yes, I'm sure. In the attached screenshot, I set the zoom factor to 200%
(which redrew to fill the window, as it should), then set it back to zero,
which then resulted in a redrawing of the document view...leaving the portions
of the clip view not covered by the document view unchanged.
If the new bounds are not a superset of the old bounds, then the clipview
itself must be redrawn. Only if the new bounds are strictly greater than the
old ones can you get away with not redrawing the clipview itself.
Your original proposal is still wrong though, there you use the
documentVisibleRect to invalidate self, which is missing two different
coordinate systems. Converting documentVisibleRect back to self gives _bounds,
which is the same as calling [self setNeedsDisplay: YES]. And I prefer to use
I am not happy with that change, but in the end we might end up with adding
that call in NSView setBounds: anyway. Why not start doing it here.
Indeed, -documentVisibleRect is in the document view's coordinate system, I
failed to notice that when I replaced [self setNeedsDisplay: YES] with it, and
it still /seemed to/ work correctly, so I left it alone.
If you want to only redraw the whole clip view when the document view shrinks,
then one could do