Re: View with Subviews + Drawing on top of everything
Re: View with Subviews + Drawing on top of everything
- Subject: Re: View with Subviews + Drawing on top of everything
- From: rajesh <email@hidden>
- Date: Tue, 24 Feb 2009 13:52:43 +0100
Yes indeed , but I chose such approach is that these subViews have lot
of stuff to draw within itself and not to mention the animations with
which they appear,disappear,move etc., is pretty much achievable.
I don't know if the said things can be done the way you suggested then
I better start make changes :)
It is something like one of the apple example codes
( SimpleLayoutView ) has , it has sample with NSBox... I don't think
its any different If I use NSView instead.
On Feb 24, 2009, at 1:27 PM, Graham Cox wrote:
On 24/02/2009, at 11:15 PM, rajesh wrote:
Need help with drawing (I have done some basic drawings in Cocoa)
Problem:
I have a View which in-turn has subviews(elements) e.g.,
chocolates ,balloons,roses , etc.,
These elements have complex drawings and are subclasses of NSView.
I place these elements on to the view with some gaps/space in
between (exposed part of main view), so far good , but I am really
stuck at a point where I have to draw a line/lines which connect
all the like elements or something like that.
When I attempt to draw a line joining the elements , line is drawn
then subViews are placed over it , but I want the other way around.
There should be something fundamental flaw or I am missing the big
picture.
I know that drawRect: is called first and the subViews are placed.
How should make my code to work as Intended
Subviews are drawn "on top" because conceptually they are in front.
My advice is general: don't (ab)use NSViews like this. I've seen
quite a few people doing this lately, or trying to, and it's
actually one of the first things that Apple advise against in the
drawing guide. Using an entire NSView to act as a moveable graphic
within a larger view is using a sledgehammer to crack a nut. It's
very unscalable and will quickly suffer from performance issues.
It's much easier to create lightweight drawing objects that are
drawn within one view. Apart from being much faster, you can overlay
lines or other things on top as you wish - it gives you much more
control.
--Graham
_______________________________________________
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