clipPathId => clipPathRef

This commit is contained in:
Horcrux
2016-07-19 09:34:27 +08:00
parent efa7363b6f
commit d610729208
10 changed files with 34 additions and 34 deletions

View File

@@ -87,16 +87,16 @@ public class RNSVGSvgViewShadowNode extends LayoutShadowNode {
return viewTag; return viewTag;
} }
public void defineClipPath(Path clipPath, String clipPathId) { public void defineClipPath(Path clipPath, String clipPathRef) {
mDefinedClipPaths.put(clipPathId, clipPath); mDefinedClipPaths.put(clipPathRef, clipPath);
} }
// TODO: remove unmounted clipPath // TODO: remove unmounted clipPath
public void removeClipPath(String clipPathId) { public void removeClipPath(String clipPathRef) {
mDefinedClipPaths.remove(clipPathId); mDefinedClipPaths.remove(clipPathRef);
} }
public Path getDefinedClipPath(String clipPathId) { public Path getDefinedClipPath(String clipPathRef) {
return mDefinedClipPaths.get(clipPathId); return mDefinedClipPaths.get(clipPathRef);
} }
} }

View File

@@ -111,9 +111,9 @@ public abstract class RNSVGVirtualNode extends LayoutShadowNode {
markUpdated(); markUpdated();
} }
@ReactProp(name = "clipPathId") @ReactProp(name = "clipPathRef")
public void setClipPathId(String clipPathId) { public void setClipPathId(String clipPathRef) {
mClipPathId = clipPathId; mClipPathId = clipPathRef;
markUpdated(); markUpdated();
} }

View File

@@ -12,7 +12,7 @@
- (void)renderLayerTo:(CGContextRef)context - (void)renderLayerTo:(CGContextRef)context
{ {
[[self getSvgView] defineClipPath:[self getPath:context] clipPathId:self.name]; [[self getSvgView] defineClipPath:[self getPath:context] clipPathRef:self.name];
} }
// hitTest delagate // hitTest delagate

View File

@@ -17,10 +17,10 @@
/** /**
* define <ClipPath></ClipPath> content as clipPath template. * define <ClipPath></ClipPath> content as clipPath template.
*/ */
- (void)defineClipPath:(CGPathRef)clipPath clipPathId:(NSString *)clipPathId; - (void)defineClipPath:(CGPathRef)clipPath clipPathRef:(NSString *)clipPathId;
- (void)removeClipPath:(NSString *)clipPathId; - (void)removeClipPath:(NSString *)clipPathRef;
- (CGPathRef)getDefinedClipPath:(NSString *)clipPathId; - (CGPathRef)getDefinedClipPath:(NSString *)clipPathRef;
@end @end

View File

@@ -62,24 +62,24 @@
return self.responsible ? [super hitTest:point withEvent:event] : nil; return self.responsible ? [super hitTest:point withEvent:event] : nil;
} }
- (void)defineClipPath:(CGPathRef)clipPath clipPathId:(NSString *)clipPathId - (void)defineClipPath:(CGPathRef)clipPath clipPathRef:(NSString *)clipPathRef
{ {
if (clipPaths == NULL) { if (clipPaths == NULL) {
clipPaths = [[NSMutableDictionary alloc] init]; clipPaths = [[NSMutableDictionary alloc] init];
} }
[clipPaths setValue:[NSValue valueWithPointer:clipPath] forKey:clipPathId]; [clipPaths setValue:[NSValue valueWithPointer:clipPath] forKey:clipPathRef];
} }
- (void)removeClipPath:(NSString *)clipPathId - (void)removeClipPath:(NSString *)clipPathRef
{ {
if (clipPaths != NULL) { if (clipPaths != NULL) {
[clipPaths removeObjectForKey:clipPathId]; [clipPaths removeObjectForKey:clipPathRef];
} }
} }
- (CGPathRef)getDefinedClipPath:(NSString *)clipPathId - (CGPathRef)getDefinedClipPath:(NSString *)clipPathRef
{ {
return [[clipPaths valueForKey:clipPathId] pointerValue]; return [[clipPaths valueForKey:clipPathRef] pointerValue];
} }
@end @end

View File

@@ -22,7 +22,7 @@
@property (nonatomic, assign) CGFloat opacity; @property (nonatomic, assign) CGFloat opacity;
@property (nonatomic, assign) RNSVGCGFCRule clipRule; @property (nonatomic, assign) RNSVGCGFCRule clipRule;
@property (nonatomic, assign) CGPathRef clipPath; // convert clipPath="M0,0 L0,10 L10,10z" into path @property (nonatomic, assign) CGPathRef clipPath; // convert clipPath="M0,0 L0,10 L10,10z" into path
@property (nonatomic, strong) NSString *clipPathId; // use clipPath="url(#clip)" as ClipPath @property (nonatomic, strong) NSString *clipPathRef; // use clipPath="url(#clip)" as ClipPath
@property (nonatomic, assign) BOOL responsible; @property (nonatomic, assign) BOOL responsible;
- (void)invalidate; - (void)invalidate;

View File

@@ -100,8 +100,8 @@
if (self.clipPath) { if (self.clipPath) {
clipPath = self.clipPath; clipPath = self.clipPath;
} else if (self.clipPathId) { } else if (self.clipPathRef) {
clipPath = [[self getSvgView] getDefinedClipPath:self.clipPathId]; clipPath = [[self getSvgView] getDefinedClipPath:self.clipPathRef];
} }
return clipPath; return clipPath;

View File

@@ -31,7 +31,7 @@ RCT_EXPORT_MODULE()
RCT_EXPORT_VIEW_PROPERTY(opacity, CGFloat) RCT_EXPORT_VIEW_PROPERTY(opacity, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(trans, CGAffineTransform) RCT_EXPORT_VIEW_PROPERTY(trans, CGAffineTransform)
RCT_EXPORT_VIEW_PROPERTY(clipPathId, NSString) RCT_EXPORT_VIEW_PROPERTY(clipPathRef, NSString)
RCT_EXPORT_VIEW_PROPERTY(responsible, BOOL) RCT_EXPORT_VIEW_PROPERTY(responsible, BOOL)
@end @end

View File

@@ -46,7 +46,7 @@ const NodeAttributes = {
diff: arrayDiffer diff: arrayDiffer
}, },
opacity: true, opacity: true,
clipPathId: true, clipPathRef: true,
responsible: true responsible: true
}; };

View File

@@ -29,7 +29,7 @@ export default function (props) {
let patternName = `${matched[1]}:${props.svgId}`; let patternName = `${matched[1]}:${props.svgId}`;
let pattern = clipPatterns[patternName]; let pattern = clipPatterns[patternName];
if (pattern) { if (pattern) {
clippingProps.clipPathId = pattern; clippingProps.clipPathRef = pattern;
} else { } else {
clippingProps = null; clippingProps = null;
// TODO: warn // TODO: warn