minimal redraw with scrollPoint
minimal redraw with scrollPoint
- Subject: minimal redraw with scrollPoint
- From: "Simon Strandgaard" <email@hidden>
- Date: Fri, 20 Oct 2006 12:31:44 +0200
I have a grab-mode in my program, where the user can hold
down the SHIFT-modifier and scroll by doing click-drag-release.
If I scroll diagonally then getRectsBeingDrawn tells me that
everything is changed. However scrolling either only-horizontally
or only-vertically then getRectsBeingDrawn gives me the delta-changes.
I have made an adhoc solution for scrolling diagonally with
minimal redraw:
At odd times I scroll horizontally.
At even times I scroll vertically.
Is there something better around?
float dx = [event deltaX];
float dy = [event deltaY];
NSClipView *cv = (NSClipView*)[self superview];
NSPoint orig = [cv bounds].origin;
if(scroll_x_if_odd & 1) {
NSPoint new_orig = NSMakePoint(
round(orig.x - dx - accum_x),
orig.y
);
[self scrollPoint: new_orig];
accum_y += dy;
accum_x = 0;
} else {
NSPoint new_orig = NSMakePoint(
orig.x,
round(orig.y - dy - accum_y)
);
[self scrollPoint: new_orig];
accum_x += dx;
accum_y = 0;
}
scroll_x_if_odd++;
--
Simon Strandgaard
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden