discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scaling, rotating, flipping subview


From: David Chisnall
Subject: Re: scaling, rotating, flipping subview
Date: Mon, 9 Dec 2019 09:22:04 +0000
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0

Hi,

The problem that you identify (input and output coordinate spaces are different) is also a problem with CoreAnimation and with X11's XRENDER extension: in both you can apply an affine transform to the output, but input coordinates are not transformed.

This is something that you can work around by modifying the responder chain. NSView is an NSResponder and is responsible for transforming input events into the child view's coordinate space before delegating them. You can apply the inverse of the affine transform to the coordinates of the event (after determining which view actually handles them).

David

On 08/12/2019 19:17, H. Nikolaus Schaller wrote:
Hi,
I am currently working on some CAD tool for GNUstep/mySTEP
and for that I would need a NSView class that can become
the documentView of a NSClipView, embedded in some
NSScrollView. And the view class I am looking for should
allow to rotate, flip and scale a subview (where I do the
drawing).

There is no standard class which can do that in Cocoa or OpenSTEP.

I have experimented a little on Cocoa and got scaling work
(by setting the bounds of the drawing view scaled relative to
its frame) but flipping and rotation is difficult to achieve.

It partially works with setBoundsRotation or scaleUnitSquareToSize,
but as a side-effect that breaks operation of the scrollers of
the NSScrollView.

Scroller size and position seems to assume that the frame and
bounds are not rotated so that changing the bounds origin can
simply move around the view under the NSClipView.

The standard recommendation is to set a transform matrix in
drawRect: and by that I could make drawing work, but coordinate
transforms for mouse clicks do not take this into account.
And scrollers do not adjust for different scaling.

Finally, this is not a general approach which can rotate,
flip and scale an arbitrary subview.

Before I invest more time in this topic, I'd like to ask
if someone knows an open source implementation of such a
general NSView subclass.

Thanks,
Nikolaus





reply via email to

[Prev in Thread] Current Thread [Next in Thread]