Skip to content

Commit

Permalink
modernized ivar naming
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Aug 29, 2012
1 parent d67dab4 commit b9b8289
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Core/Source/DTAttributedTextContentView.h
Expand Up @@ -100,7 +100,7 @@
NSAttributedString *_attributedString;
DTCoreTextLayoutFrame *_layoutFrame;

UIEdgeInsets edgeInsets;
UIEdgeInsets _edgeInsets;

NSMutableDictionary *customViewsForAttachmentsIndex;
}
Expand Down
58 changes: 31 additions & 27 deletions Core/Source/DTAttributedTextContentView.m
Expand Up @@ -20,10 +20,10 @@

@interface DTAttributedTextContentView ()
{
BOOL drawDebugFrames;
BOOL shouldDrawImages;
BOOL _drawDebugFrames;
BOOL _shouldDrawImages;
BOOL _shouldDrawLinks;
BOOL shouldLayoutCustomSubviews;
BOOL _shouldLayoutCustomSubviews;

NSMutableSet *customViews;
NSMutableDictionary *customViewsForLinksIndex;
Expand Down Expand Up @@ -85,11 +85,15 @@ @implementation DTAttributedTextContentView
- (void)setup
{
self.contentMode = UIViewContentModeTopLeft; // to avoid bitmap scaling effect on resize
shouldLayoutCustomSubviews = YES;
_shouldLayoutCustomSubviews = YES;

// by default we draw images, if custom views are supported (by setting delegate) this is disabled
// if you still want images to be drawn together with text then set it back to YES after setting delegate
shouldDrawImages = YES;
_shouldDrawImages = YES;

// by default we draw links. If you don't want that because you want to highlight the text in
// DTLinkButton set this property to NO and create a highlighted version of the attributed string
_shouldDrawLinks = YES;

// possibly already set in NIB
if (!self.backgroundColor)
Expand Down Expand Up @@ -365,7 +369,7 @@ - (void)layoutSubviews
{
[super layoutSubviews];

if (shouldLayoutCustomSubviews)
if (_shouldLayoutCustomSubviews)
{
[self layoutSubviewsInRect:CGRectInfinite];
}
Expand Down Expand Up @@ -396,7 +400,7 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
// need to prevent updating of string and drawing at the same time
SYNCHRONIZE_START(selfLock)
{
[theLayoutFrame drawInContext:ctx drawImages:shouldDrawImages drawLinks:_shouldDrawLinks];
[theLayoutFrame drawInContext:ctx drawImages:_shouldDrawImages drawLinks:_shouldDrawLinks];

if (_delegateFlags.delegateSupportsNotificationAfterDrawing)
{
Expand All @@ -419,7 +423,7 @@ - (CGSize)sizeThatFits:(CGSize)size
size.width = self.bounds.size.width;
}

CGSize neededSize = CGSizeMake(size.width, CGRectGetMaxY(self.layoutFrame.frame) + edgeInsets.bottom);
CGSize neededSize = CGSizeMake(size.width, CGRectGetMaxY(self.layoutFrame.frame) + _edgeInsets.bottom);

return neededSize;
}
Expand All @@ -431,10 +435,10 @@ - (CGSize)suggestedFrameSizeToFitEntireStringConstraintedToWidth:(CGFloat)width
width = self.bounds.size.width;
}

CGSize neededSize = [self.layouter suggestedFrameSizeToFitEntireStringConstraintedToWidth:width-edgeInsets.left-edgeInsets.right];
CGSize neededSize = [self.layouter suggestedFrameSizeToFitEntireStringConstraintedToWidth:width-_edgeInsets.left-_edgeInsets.right];

// add vertical insets
neededSize.height += edgeInsets.top + edgeInsets.bottom;
neededSize.height += _edgeInsets.top + _edgeInsets.bottom;

return neededSize;
}
Expand All @@ -447,7 +451,7 @@ - (CGSize)attributedStringSizeThatFits:(CGFloat)width
}

// attributedStringSizeThatFits: returns an unreliable measure prior to 4.2 for very long documents.
CGSize neededSize = [self.layouter suggestedFrameSizeToFitEntireStringConstraintedToWidth:width-edgeInsets.left-edgeInsets.right];
CGSize neededSize = [self.layouter suggestedFrameSizeToFitEntireStringConstraintedToWidth:width-_edgeInsets.left-_edgeInsets.right];
return neededSize;
}

Expand Down Expand Up @@ -537,11 +541,11 @@ - (void)removeSubviewsOutsideRect:(CGRect)rect
}

#pragma mark Properties
- (void)setEdgeInsets:(UIEdgeInsets)newEdgeInsets
- (void)setEdgeInsets:(UIEdgeInsets)edgeInsets
{
if (!UIEdgeInsetsEqualToEdgeInsets(newEdgeInsets, edgeInsets))
if (!UIEdgeInsetsEqualToEdgeInsets(edgeInsets, _edgeInsets))
{
edgeInsets = newEdgeInsets;
_edgeInsets = edgeInsets;

[self relayoutText];
}
Expand Down Expand Up @@ -587,21 +591,21 @@ - (void)setFrame:(CGRect)frame //relayoutText:(BOOL)relayoutText
// [self setFrame:frame relayoutText:_relayoutTextOnFrameChange];
//}

- (void)setDrawDebugFrames:(BOOL)newSetting
- (void)setDrawDebugFrames:(BOOL)drawDebugFrames
{
if (drawDebugFrames != newSetting)
if (_drawDebugFrames != drawDebugFrames)
{
drawDebugFrames = newSetting;
_drawDebugFrames = drawDebugFrames;

[self setNeedsDisplay];
}
}

- (void)setShouldDrawImages:(BOOL)newSetting
- (void)setShouldDrawImages:(BOOL)shouldDrawImages
{
if (shouldDrawImages != newSetting)
if (_shouldDrawImages != shouldDrawImages)
{
shouldDrawImages = newSetting;
_shouldDrawImages = shouldDrawImages;

[self setNeedsDisplay];
}
Expand Down Expand Up @@ -666,7 +670,7 @@ - (DTCoreTextLayoutFrame *)layoutFrame
// we can only layout if we have our own layouter
if (theLayouter)
{
CGRect rect = UIEdgeInsetsInsetRect(self.bounds, edgeInsets);
CGRect rect = UIEdgeInsetsInsetRect(self.bounds, _edgeInsets);
rect.size.height = CGFLOAT_OPEN_HEIGHT; // necessary height set as soon as we know it.

_layoutFrame = [theLayouter layoutFrameWithRect:rect range:NSMakeRange(0, 0)];
Expand Down Expand Up @@ -762,11 +766,11 @@ - (void)setDelegate:(id<DTAttributedTextContentViewDelegate>)delegate
// if you want images to be drawn even though you use custom views, set it back to YES after setting delegate
if (_delegateFlags.delegateSupportsGenericCustomViews || _delegateFlags.delegateSupportsCustomViewsForAttachments)
{
shouldDrawImages = NO;
_shouldDrawImages = NO;
}
else
{
shouldDrawImages = YES;
_shouldDrawImages = YES;
}
}

Expand All @@ -786,11 +790,11 @@ - (dispatch_semaphore_t)selfLock
@synthesize layoutFrame = _layoutFrame;
@synthesize attributedString = _attributedString;
@synthesize delegate = _delegate;
@synthesize edgeInsets;
@synthesize drawDebugFrames;
@synthesize shouldDrawImages;
@synthesize edgeInsets = _edgeInsets;
@synthesize drawDebugFrames = _drawDebugFrames;
@synthesize shouldDrawImages = _shouldDrawImages;
@synthesize shouldDrawLinks = _shouldDrawLinks;
@synthesize shouldLayoutCustomSubviews;
@synthesize shouldLayoutCustomSubviews = _shouldLayoutCustomSubviews;
@synthesize layoutOffset = _layoutOffset;
@synthesize backgroundOffset = _backgroundOffset;

Expand Down

0 comments on commit b9b8289

Please sign in to comment.