CAShapeLayerWithHitTest.m 877 B

123456789101112131415161718192021222324252627282930
  1. #import "CAShapeLayerWithHitTest.h"
  2. /*! Used by the main ShapeElement (and all subclasses) to do perfect "containsPoint" calculations via Apple's API calls
  3. This will only be called if it's the root of an SVG document and the hit was in the parent view on screen,
  4. OR if it's inside an SVGGElement that contained the hit
  5. */
  6. @implementation CAShapeLayerWithHitTest
  7. - (BOOL) containsPoint:(CGPoint)p
  8. {
  9. BOOL boundsContains = CGRectContainsPoint(self.bounds, p); // must be BOUNDS because Apple pre-converts the point to local co-ords before running the test
  10. if( boundsContains )
  11. {
  12. BOOL pathContains = CGPathContainsPoint(self.path, NULL, p, false);
  13. if( pathContains )
  14. {
  15. for( CALayer* subLayer in self.sublayers )
  16. {
  17. SVGKitLogVerbose(@"...contains point, Apple will now check sublayer: %@", subLayer);
  18. }
  19. return TRUE;
  20. }
  21. }
  22. return FALSE;
  23. }
  24. @end