• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CALayers Lost After Switching Window's ContentView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CALayers Lost After Switching Window's ContentView


  • Subject: Re: CALayers Lost After Switching Window's ContentView
  • From: Timothy Wood <email@hidden>
  • Date: Tue, 17 Feb 2009 09:53:44 -0800


On Feb 16, 2009, at 12:45 PM, David Duncan wrote:
The simplest solution, if you can mange it, is to set the view's layer to your own layer, at which point AppKit will take a hands off approach and allow you to determine when the layer should go away.

We are also mixing hosting & backing a bit, but only barely. The problem we've run into with setting our own layer on the view is that then all the super-seekrit compositing & resizing NSView does for its layers doesn't happen. In particular, since we want our own layers _and_ we want a field editor _and_ we want a flipped coordinate system in the view, the only solution we've found to work was to let the view host its layer (which nothing ever gets drawn into), put our content in our own layers in a flipped layer (using sublayerTransform) and add the field editor with addSubview: (as a peer, atop our layers). Other approaches end up not resizing correctly, or drawing the field editor upside down. Radar #6503347 has some details of what we've tried.


To me it seems that life would be vastly easier if NSView would just set sublayerTransform to a flipping transform if -isFlipped returned YES. Instead, NSView seems to maintain a non-flipped fiction for its coordinate system and then has private code on the compositing and resizing paths to adjust the coordinates.

The alternative, which is primarily for use if you need AppKit to continue to draw to the view's layer, is to override -setLayer: to do any required setup for your layer tree. So what you would do is check if the incoming layer is non-nil, and if it is, make any changes to that layer (including adding sublayers) at that point.

This is the approach we settled on after some trial and error and it is mostly working pretty well, though we still have a few glitches to fix up.


-tim

_______________________________________________

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


References: 
 >CALayers Lost After Switching Window's ContentView (From: Bridger Maxwell <email@hidden>)
 >Re: CALayers Lost After Switching Window's ContentView (From: "E. Wing" <email@hidden>)
 >Re: CALayers Lost After Switching Window's ContentView (From: David Duncan <email@hidden>)

  • Prev by Date: serialPortSample... hang on "read" function
  • Next by Date: Re: serialPortSample... hang on "read" function
  • Previous by thread: Re: CALayers Lost After Switching Window's ContentView
  • Next by thread: Raw keyboard events under Cocoa
  • Index(es):
    • Date
    • Thread