Merge remote-tracking branch 'max/touches-group-use'

This commit is contained in:
Mikael Sand
2018-06-07 21:20:35 +03:00
4 changed files with 62 additions and 21 deletions
@@ -73,6 +73,24 @@ class UseShadowNode extends RenderableShadowNode {
}
}
@Override
public int hitTest(float[] src) {
if (!mInvertible) {
return -1;
}
float[] dst = new float[2];
mInvMatrix.mapPoints(dst, src);
VirtualNode template = getSvgShadowNode().getDefinedTemplate(mHref);
int hitChild = template.hitTest(dst);
if (hitChild != -1) {
return (template.isResponsible() || hitChild != template.getReactTag()) ? hitChild : getReactTag();
}
return -1;
}
@Override
protected Path getPath(Canvas canvas, Paint paint) {
// todo:
+16 -7
View File
@@ -61,6 +61,7 @@
return YES;
}];
[self setHitArea:[self getPath:context]];
[self popGlyphContext];
}
@@ -113,16 +114,19 @@
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
CGPoint transformed = CGPointApplyAffineTransform(point, self.invmatrix);
UIView *hitSelf = [super hitTest:transformed withEvent:event];
if (hitSelf) {
return hitSelf;
}
CGPathRef clip = [self getClipPath];
if (clip && !CGPathContainsPoint(clip, nil, transformed, self.clipRule == kRNSVGCGFCRuleEvenodd)) {
return nil;
}
if (!event) {
NSPredicate *const anyActive = [NSPredicate predicateWithFormat:@"active == TRUE"];
NSArray *const filtered = [self.subviews filteredArrayUsingPredicate:anyActive];
if ([filtered count] != 0) {
return filtered.firstObject;
}
}
for (RNSVGNode *node in [self.subviews reverseObjectEnumerator]) {
if (![node isKindOfClass:[RNSVGNode class]]) {
@@ -142,7 +146,12 @@
return (node.responsible || (node != hitChild)) ? hitChild : self;
}
}
UIView *hitSelf = [super hitTest:transformed withEvent:event];
if (hitSelf) {
return hitSelf;
}
return nil;
}
+16
View File
@@ -51,5 +51,21 @@
}
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
const CGPoint transformed = CGPointApplyAffineTransform(point, self.invmatrix);
RNSVGNode const* template = [self.svgView getDefinedTemplate:self.href];
if (event) {
self.active = NO;
} else if (self.active) {
return self;
}
UIView const* hitChild = [template hitTest:transformed withEvent:event];
if (hitChild) {
self.active = YES;
return self;
}
return nil;
}
@end
+12 -14
View File
@@ -264,21 +264,19 @@
{
CGPathRelease(_hitArea);
_hitArea = nil;
if (self.responsible) {
// Add path to hitArea
CGMutablePathRef hitArea = CGPathCreateMutableCopy(path);
if (self.stroke && self.strokeWidth) {
// Add stroke to hitArea
CGFloat width = [self relativeOnOther:self.strokeWidth];
CGPathRef strokePath = CGPathCreateCopyByStrokingPath(hitArea, nil, width, self.strokeLinecap, self.strokeLinejoin, self.strokeMiterlimit);
CGPathAddPath(hitArea, nil, strokePath);
CGPathRelease(strokePath);
}
_hitArea = CGPathRetain(CFAutorelease(CGPathCreateCopy(hitArea)));
CGPathRelease(hitArea);
// Add path to hitArea
CGMutablePathRef hitArea = CGPathCreateMutableCopy(path);
if (self.stroke && self.strokeWidth) {
// Add stroke to hitArea
CGFloat width = [self relativeOnOther:self.strokeWidth];
CGPathRef strokePath = CGPathCreateCopyByStrokingPath(hitArea, nil, width, self.strokeLinecap, self.strokeLinejoin, self.strokeMiterlimit);
CGPathAddPath(hitArea, nil, strokePath);
CGPathRelease(strokePath);
}
_hitArea = CGPathRetain(CFAutorelease(CGPathCreateCopy(hitArea)));
CGPathRelease(hitArea);
}