Single vs. multiple NSView (solved)
Single vs. multiple NSView (solved)
- Subject: Single vs. multiple NSView (solved)
- From: Ricky Sharp <email@hidden>
- Date: Tue, 27 Jul 2004 12:31:31 -0500
Thanks again for all the feedback on both this thread and others I have posted; they really have helped in getting me ramped up to Cocoa.
I'm finally out of the experimentation stage and about to write some real code. I thought though that I'd share the approach in case it could help others.
While recently I planned on using a single NSView which would simply render a single NSImage, I'm actually going the multiple NSView route. More specifically, custom NSControls and NSCells.
However, I still plan to use a single NSImage that will provide a working space (more below).
The main reason to go with custom controls is that, among other things, I really want to use IB to do my layouts and get things such as section 508 compliance (e.g. full keyboard access). I was really taken by the ClockControl sample code. I was amazed at how simple it was to not only create custom controls, but to create IB palettes. Furthermore, the sample app behaves as expected with full keyboard access. It also allowed me to customize the focus ring (which I really needed since my controls are all custom themselves).
So here's the current plan:
I'll still have one and only one window ever. Its contents are made up of custom NSControls/Cells. Among other things, each control/cell will maintain an NSImage that will contain the rasterized form to display on-screen. The original sources of the image will mostly be PDF, but could also be 300dpi bitmaps. Those will be cached in case the NSImage needs to ever be re-computed.
While most of the custom controls need to composite their content into lower controls/views, this will be a performance problem. Thus, all my controls will be marked as being opaque. What I plan to do is this:
(1) When the window is awoken, I build up my worker NSImage. The contents of the image becomes the background color (or image) of the application.
(2) When controls are awoken, I use a cookie cutter and cut out the portion of the worker NSImage and that get's rendered to the controls' NSImage member. I then load in any other graphics or perform drawing commands. The end result is that the control now has an "opaque" image. For controls with multiple appearance (e.g. buttons), multiple NSImages will be created.
In summary, I plan to basically push all compositing work at the load time of the controls. Drawing will always be very fast non-compositing blits into opaque views. And of course be clipped to only what needs to be drawn.
Rick Sharp
Instant Interactive(tm)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.