Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RTL] Bridge the UISemanticContentAttribute property for more convenient RTL support. #60

Merged
merged 1 commit into from
Apr 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/ASDisplayNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ extern NSInteger const ASDefaultDrawingPriority;
* contentMode for your content while it's being re-rendered.
*/
@property (nonatomic, assign) UIViewContentMode contentMode; // default=UIViewContentModeScaleToFill
@property (nonatomic, assign) UISemanticContentAttribute semanticContentAttribute; // default=Unspecified

@property (nonatomic, assign, getter=isUserInteractionEnabled) BOOL userInteractionEnabled; // default=YES (NO for layer-backed nodes)
#if TARGET_OS_IOS
Expand Down
19 changes: 10 additions & 9 deletions Source/Details/UIView+ASConvenience.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ NS_ASSUME_NONNULL_BEGIN
*/
@protocol ASDisplayNodeViewProperties

@property (nonatomic, assign) BOOL clipsToBounds;
@property (nonatomic, getter=isHidden) BOOL hidden;
@property (nonatomic, assign) BOOL autoresizesSubviews;
@property (nonatomic, assign) UIViewAutoresizing autoresizingMask;
@property (nonatomic, strong, null_resettable) UIColor *tintColor;
@property (nonatomic, assign) CGFloat alpha;
@property (nonatomic, assign) CGRect bounds;
@property (nonatomic, assign) CGRect frame; // Only for use with nodes wrapping synchronous views
@property (nonatomic, assign) UIViewContentMode contentMode;
@property (nonatomic, assign) BOOL clipsToBounds;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were re-indented, because they had actually included tab characters as well as spaces (making it impossible to line up on GitHub even though it did in Xcode)

@property (nonatomic, getter=isHidden) BOOL hidden;
@property (nonatomic, assign) BOOL autoresizesSubviews;
@property (nonatomic, assign) UIViewAutoresizing autoresizingMask;
@property (nonatomic, strong, null_resettable) UIColor *tintColor;
@property (nonatomic, assign) CGFloat alpha;
@property (nonatomic, assign) CGRect bounds;
@property (nonatomic, assign) CGRect frame; // Only for use with nodes wrapping synchronous views
@property (nonatomic, assign) UIViewContentMode contentMode;
@property (nonatomic, assign) UISemanticContentAttribute semanticContentAttribute;
@property (nonatomic, assign, getter=isUserInteractionEnabled) BOOL userInteractionEnabled;
@property (nonatomic, assign, getter=isExclusiveTouch) BOOL exclusiveTouch;
@property (nonatomic, assign, getter=asyncdisplaykit_isAsyncTransactionContainer, setter = asyncdisplaykit_setAsyncTransactionContainer:) BOOL asyncdisplaykit_asyncTransactionContainer;
Expand Down
17 changes: 17 additions & 0 deletions Source/Private/ASDisplayNode+UIViewBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,23 @@ - (void)setEdgeAntialiasingMask:(unsigned int)edgeAntialiasingMask
_setToLayer(edgeAntialiasingMask, edgeAntialiasingMask);
}

- (UISemanticContentAttribute)semanticContentAttribute
{
_bridge_prologue_read;
if (AS_AT_LEAST_IOS9) {
return _getFromViewOnly(semanticContentAttribute);
}
return UISemanticContentAttributeUnspecified;
}

- (void)setSemanticContentAttribute:(UISemanticContentAttribute)semanticContentAttribute
{
_bridge_prologue_write;
if (AS_AT_LEAST_IOS9) {
_setToViewOnly(semanticContentAttribute, semanticContentAttribute);
}
}

@end


Expand Down
15 changes: 15 additions & 0 deletions Source/Private/_ASPendingState.mm
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
int setAccessibilityHeaderElements:1;
int setAccessibilityActivationPoint:1;
int setAccessibilityPath:1;
int setSemanticContentAttribute:1;
} ASPendingStateFlags;

@implementation _ASPendingState
Expand Down Expand Up @@ -118,6 +119,7 @@ @implementation _ASPendingState
NSArray *accessibilityHeaderElements;
CGPoint accessibilityActivationPoint;
UIBezierPath *accessibilityPath;
UISemanticContentAttribute semanticContentAttribute;

ASPendingStateFlags _flags;
}
Expand Down Expand Up @@ -179,6 +181,7 @@ ASDISPLAYNODE_INLINE void ASPendingStateApplyMetricsToLayer(_ASPendingState *sta
@synthesize borderWidth=borderWidth;
@synthesize borderColor=borderColor;
@synthesize asyncdisplaykit_asyncTransactionContainer=asyncTransactionContainer;
@synthesize semanticContentAttribute=semanticContentAttribute;


static CGColorRef blackColorRef = NULL;
Expand Down Expand Up @@ -259,6 +262,7 @@ - (instancetype)init
accessibilityActivationPoint = CGPointZero;
accessibilityPath = nil;
edgeAntialiasingMask = (kCALayerLeftEdge | kCALayerRightEdge | kCALayerTopEdge | kCALayerBottomEdge);
semanticContentAttribute = UISemanticContentAttributeUnspecified;

return self;
}
Expand Down Expand Up @@ -512,6 +516,11 @@ - (void)asyncdisplaykit_setAsyncTransactionContainer:(BOOL)flag
_flags.setAsyncTransactionContainer = YES;
}

- (void)setSemanticContentAttribute:(UISemanticContentAttribute)attribute {
semanticContentAttribute = attribute;
_flags.setSemanticContentAttribute = YES;
}

- (BOOL)isAccessibilityElement
{
return isAccessibilityElement;
Expand Down Expand Up @@ -904,6 +913,10 @@ - (void)applyToView:(UIView *)view withSpecialPropertiesHandling:(BOOL)specialPr
if (flags.setOpaque)
ASDisplayNodeAssert(view.layer.opaque == opaque, @"Didn't set opaque as desired");

if (flags.setSemanticContentAttribute) {
view.semanticContentAttribute = semanticContentAttribute;
}

if (flags.setIsAccessibilityElement)
view.isAccessibilityElement = isAccessibilityElement;

Expand Down Expand Up @@ -1045,6 +1058,7 @@ + (_ASPendingState *)pendingViewStateFromView:(UIView *)view
pendingState.allowsGroupOpacity = layer.allowsGroupOpacity;
pendingState.allowsEdgeAntialiasing = layer.allowsEdgeAntialiasing;
pendingState.edgeAntialiasingMask = layer.edgeAntialiasingMask;
pendingState.semanticContentAttribute = view.semanticContentAttribute;
pendingState.isAccessibilityElement = view.isAccessibilityElement;
pendingState.accessibilityLabel = view.accessibilityLabel;
pendingState.accessibilityHint = view.accessibilityHint;
Expand Down Expand Up @@ -1119,6 +1133,7 @@ - (BOOL)hasChanges
|| flags.needsLayout
|| flags.setAsyncTransactionContainer
|| flags.setOpaque
|| flags.setSemanticContentAttribute
|| flags.setIsAccessibilityElement
|| flags.setAccessibilityLabel
|| flags.setAccessibilityHint
Expand Down