(Problems) Scaling NSViews with scaleUnitSquareToSize
(Problems) Scaling NSViews with scaleUnitSquareToSize
- Subject: (Problems) Scaling NSViews with scaleUnitSquareToSize
- From: Eric Wing <email@hidden>
- Date: Wed, 28 Sep 2011 00:08:55 -0700
I am working on a code base that happens to be using
scaleUnitSquareToSize. I think the intent is to actually scale the
view to various scale factors like 2 and .5. I have been in the
process of making said view layer-backed (Core Animation) and adding
subviews to it.
I have been seeing a lot of rendering glitches with the subviews I add
to it when I change the scale factor away from 1.0 on the host view.
It seems to be scaling the subview with it which is not necessarily
what I originally wanted (but am not totally opposed to the idea if it
actually worked correctly).
For example, if I scale NSTextField up, the clickable area and focus
ring seem to be stuck at the orignal 1.0 size, but the white
background actually scales. This looks really bad and is confusing
since the clickable area doesn't line up.
At first, I thought the problem was because I use layer-backed views,
but I found somebody on Bill Dudney's forums complaining about the
same issue for NSButtons.
http://forums.pragprog.com/forums/57/topics/3306
They complained their problems were in layer backed mode, and they
posted their code.
But I swapped out the buttons for NSTextField, NSTextView, and WebView
and I see all sorts of problems in both non-layer-backed mode and
layer-backed mode. The layer-backed is usually worse, but the
non-layer backed is still bad.
NSTextField (not layer backed)
https://picasaweb.google.com/lh/photo/gZwK3pxU6jQbGvM7rUmRYg?feat=directlink
NSTextView (layer backed)
https://picasaweb.google.com/lh/photo/MQu-ThL8WwoRjE-MVpzldA?feat=directlink
WebView (not-layer-backed on left, layer-backed on right)
https://picasaweb.google.com/lh/photo/VyU9BtrrSaCmBLJS5KlB6Q?feat=directlink
Anyway, I was wondering if somebody could give me the low-down on
scaleUnitSquareToSize and if this is actually its intended purpose.
And are there work-arounds for these rendering problems?
For context, I'm working on an OpenGL based application. We are trying
to get native Cocoa widgets on top of the view via Core Animation. For
various reasons, we support scaling our view to different factors.
This is fairly straight-forward in OpenGL but obviously presents
different challenges for native Cocoa widgets. My original plan was to
simply resize the frame to fit within the host view bounds and not
worry about scaling the content, but I had not thought of using
scaleUnitSquareToSize and did not know it was actually already being
invoked in the codebase I'm working on.
Thanks,
Eric
--
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden