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

Fix some warnings for iOS 7. #25

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions Brushes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@
6BF9986815A67C7100AFBB3A /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 6BF9986615A67C7000AFBB3A /* [email protected] */; };
6BF9986F15A776EC00AFBB3A /* WDCellSelectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF9986E15A776EC00AFBB3A /* WDCellSelectionView.m */; };
6BFA802C1249CEDB00D1749C /* WDLayerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BFA802B1249CEDB00D1749C /* WDLayerCell.m */; };
AE815F8E19231421003D7056 /* NSString+Drawing.m in Sources */ = {isa = PBXBuildFile; fileRef = AE815F8D19231421003D7056 /* NSString+Drawing.m */; };
C01FCF5008A9545400542486 /* WDSynchronizer.m in Sources */ = {isa = PBXBuildFile; fileRef = C01FCF5008A9545400542485 /* WDSynchronizer.m */; };
C01FCF5008A954540054248D /* WDAddLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = C01FCF5008A954540054248C /* WDAddLayer.m */; };
C01FCF5008A9545400542490 /* WDDeleteLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = C01FCF5008A954540054248F /* WDDeleteLayer.m */; };
Expand Down Expand Up @@ -972,6 +973,8 @@
6BF9986E15A776EC00AFBB3A /* WDCellSelectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WDCellSelectionView.m; sourceTree = "<group>"; };
6BFA802A1249CEDB00D1749C /* WDLayerCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WDLayerCell.h; sourceTree = "<group>"; };
6BFA802B1249CEDB00D1749C /* WDLayerCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WDLayerCell.m; sourceTree = "<group>"; };
AE815F8C19231421003D7056 /* NSString+Drawing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Drawing.h"; sourceTree = "<group>"; };
AE815F8D19231421003D7056 /* NSString+Drawing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Drawing.m"; sourceTree = "<group>"; };
C01FCF5008A9545400542484 /* WDSynchronizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WDSynchronizer.h; sourceTree = "<group>"; };
C01FCF5008A9545400542485 /* WDSynchronizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WDSynchronizer.m; sourceTree = "<group>"; };
C01FCF5008A9545400542487 /* WDDocumentChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WDDocumentChange.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1591,6 +1594,8 @@
6BCD535F1240001D002FCB27 /* Additions */ = {
isa = PBXGroup;
children = (
AE815F8C19231421003D7056 /* NSString+Drawing.h */,
AE815F8D19231421003D7056 /* NSString+Drawing.m */,
5D1CF74B138C7BAB008979B3 /* DBMetadata+Additions.h */,
5D1CF74C138C7BAB008979B3 /* DBMetadata+Additions.m */,
6B40CD92181FCFFE00004FB2 /* NSArray+Additions.h */,
Expand Down Expand Up @@ -2354,6 +2359,7 @@
6B40CE3E181FD10F00004FB2 /* WDStampGenerator.m in Sources */,
6B5F0F5C1600289A00E44FB8 /* WDStylusController.m in Sources */,
6B5F0F611600447B00E44FB8 /* WDStylusManager.m in Sources */,
AE815F8E19231421003D7056 /* NSString+Drawing.m in Sources */,
6B966406160BF35700B9734A /* WDStylusTableCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -2383,7 +2389,6 @@
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)",
/Users/sprang/Development/Brushes,
);
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -2417,7 +2422,6 @@
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)",
/Users/sprang/Development/Brushes,
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Brushes_Prefix.pch;
Expand Down Expand Up @@ -2470,7 +2474,6 @@
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)",
/Users/sprang/Development/Brushes,
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Brushes_Prefix.pch;
Expand Down Expand Up @@ -2527,7 +2530,6 @@
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)",
/Users/sprang/Development/Brushes,
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Brushes_Prefix.pch;
Expand Down
14 changes: 14 additions & 0 deletions Brushes_Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,17 @@
#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>
#endif

#ifdef __IPHONE_7_0
#define contentSizeForViewInPopover preferredContentSize
#endif

#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1
#define kImageAlphaNone (CGBitmapInfo)kCGImageAlphaNone
#define kImageAlphaPremultipliedFirst (CGBitmapInfo)kCGImageAlphaPremultipliedFirst
#define kImageAlphaPremultipliedLast (CGBitmapInfo)kCGImageAlphaPremultipliedLast
#else
#define kImageAlphaNone kCGImageAlphaNone
#define kImageAlphaPremultipliedFirst kCGImageAlphaPremultipliedFirst
#define kImageAlphaPremultipliedLast kCGImageAlphaPremultipliedLast
#endif
21 changes: 21 additions & 0 deletions Classes/NSString+Drawing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// NSString+Drawing.h
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2014 Zhang Yungui <github.com/rhcad>
//

#ifndef __IPHONE_7_0
#import <Foundation/Foundation.h>

@interface NSString (NSStringDrawing)

- (CGSize)sizeWithAttributes:(NSDictionary *)attrs;
- (void)drawAtPoint:(CGPoint)point withAttributes:(NSDictionary *)attrs;
- (void)drawInRect:(CGRect)rect withAttributes:(NSDictionary *)attrs;

@end
#endif
33 changes: 33 additions & 0 deletions Classes/NSString+Drawing.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// NSString+Drawing.m
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2014 Zhang Yungui <github.com/rhcad>
//

#ifndef __IPHONE_7_0
#import "NSString+Drawing.h"

@implementation NSString (NSStringDrawing)

- (CGSize)sizeWithAttributes:(NSDictionary *)attrs {
return [self sizeWithFont:attrs[NSFontAttributeName]];
}

- (void)drawAtPoint:(CGPoint)point withAttributes:(NSDictionary *)attrs {
[self drawAtPoint:point withFont:attrs[NSFontAttributeName]];
}

- (void)drawInRect:(CGRect)rect withAttributes:(NSDictionary *)attrs {
NSParagraphStyle *paraStyle = attrs[NSParagraphStyleAttributeName];

[self drawInRect:rect withFont:attrs[NSFontAttributeName]
lineBreakMode:paraStyle.lineBreakMode
alignment:paraStyle.alignment];
}

@end
#endif
2 changes: 1 addition & 1 deletion Classes/UIImage+Additions.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ - (BOOL) reallyHasAlpha
UInt8 *data = malloc(height * rowByteSize);

CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(data, width, height, 8, rowByteSize, colorSpaceRef, kCGImageAlphaPremultipliedLast);
CGContextRef context = CGBitmapContextCreate(data, width, height, 8, rowByteSize, colorSpaceRef, kImageAlphaPremultipliedLast);
CGContextSetBlendMode(context, kCGBlendModeCopy);
CGContextDrawImage(context, CGRectMake(0, 0, width, height), image);
CGContextRelease(context);
Expand Down
4 changes: 2 additions & 2 deletions Classes/WDActionNameView.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ - (id)initWithFrame:(CGRect)frame
frame.size.height /= 2;
self.titleLabel = [[UILabel alloc] initWithFrame:frame];
titleLabel.font = [UIFont boldSystemFontOfSize:20.0f];
titleLabel.textAlignment = UITextAlignmentCenter;
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.backgroundColor = nil;
titleLabel.opaque = NO;
titleLabel.textColor = [UIColor whiteColor];
Expand All @@ -52,7 +52,7 @@ - (id)initWithFrame:(CGRect)frame
frame = CGRectOffset(frame, 0, CGRectGetHeight(frame));
self.messageLabel = [[UILabel alloc] initWithFrame:frame];
messageLabel.font = [UIFont systemFontOfSize:17.0f];
messageLabel.textAlignment = UITextAlignmentCenter;
messageLabel.textAlignment = NSTextAlignmentCenter;
messageLabel.backgroundColor = nil;
messageLabel.opaque = NO;
messageLabel.textColor = [UIColor whiteColor];
Expand Down
13 changes: 7 additions & 6 deletions Classes/WDBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#import "WDBar.h"
#import "WDUtilities.h"
#import "NSString+Drawing.h"

const NSUInteger kWDDefaultBarHeight = 44;
const NSUInteger kWDLandscapePhoneBarHeight = 32;
Expand Down Expand Up @@ -128,7 +129,7 @@ + (UIImage *) backImageWithTitle:(NSString *)string landscape:(BOOL)landscape

if (WDUseModernAppearance()) {
UIFont *font = [UIFont systemFontOfSize:17];
CGSize textSize = [string sizeWithFont:font];
CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:font}];
CGSize size = textSize;
float arrowSize = 9, arrowInset = 4;

Expand All @@ -142,7 +143,7 @@ + (UIImage *) backImageWithTitle:(NSString *)string landscape:(BOOL)landscape
CGPoint origin;
origin.x = (size.width - textSize.width); // align right
origin.y = (size.height - textSize.height) / 2.0f; // center vertically
[string drawAtPoint:origin withFont:font];
[string drawAtPoint:origin withAttributes:@{NSFontAttributeName:font}];

// draw back arrow
CGContextMoveToPoint(ctx, arrowInset + arrowSize, size.height / 2 - arrowSize);
Expand All @@ -157,7 +158,7 @@ + (UIImage *) backImageWithTitle:(NSString *)string landscape:(BOOL)landscape
UIGraphicsEndImageContext();
} else {
UIFont *font = [UIFont boldSystemFontOfSize:(landscape ? 12 : 13)];
CGSize textSize = [string sizeWithFont:font];
CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:font}];
CGSize size = textSize;

UIImage *backImage = landscape ? [UIImage imageNamed:@"backButtonLandscape.png"] : [UIImage imageNamed:@"backButton.png"];
Expand All @@ -176,7 +177,7 @@ + (UIImage *) backImageWithTitle:(NSString *)string landscape:(BOOL)landscape
CGPoint origin;
origin.x = (size.width - textSize.width) / 2.0f + 2.0f;
origin.y = (size.height - textSize.height) / 2.0f;
[string drawAtPoint:origin withFont:font];
[string drawAtPoint:origin withAttributes:@{NSFontAttributeName:font}];

result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Expand Down Expand Up @@ -500,8 +501,8 @@ - (void) setTitle:(NSString *)title
label.backgroundColor = nil;
label.opaque = NO;
label.textColor = [UIColor whiteColor];
label.textAlignment = UITextAlignmentCenter;
label.lineBreakMode = UILineBreakModeMiddleTruncation;
label.textAlignment = NSTextAlignmentCenter;
label.lineBreakMode = NSLineBreakByTruncatingMiddle;
label.font = [self portraitFont];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth;

Expand Down
2 changes: 1 addition & 1 deletion Classes/WDBarSlider.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ - (id) initWithFrame:(CGRect)frame
label.opaque = NO;
label.backgroundColor = nil;
label.font = [UIFont boldSystemFontOfSize:13];
label.textAlignment = UITextAlignmentCenter;
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor whiteColor];

CALayer *layer = self.layer;
Expand Down
6 changes: 4 additions & 2 deletions Classes/WDBlendModePicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import "WDBlendModePicker.h"
#import "WDScrollView.h"
#import "WDUtilities.h"
#import "NSString+Drawing.h"

const float kScrollViewHeight = 41;
const float kIndicatorBaseHeight = 48;
Expand Down Expand Up @@ -232,9 +233,10 @@ - (void) buildTitleButtons
{
// iterate through the strings and find the longest one
float width, totalWidth = 0.0f;
NSDictionary *attrs = @{NSFontAttributeName:self.font};

for (NSString *title in self.titles) {
width = [title sizeWithFont:self.font].width;
width = [title sizeWithAttributes:attrs].width;
totalWidth += width + (kButtonOutset * 2);
}

Expand All @@ -249,7 +251,7 @@ - (void) buildTitleButtons

for (NSString *title in self.titles) {
button = [UIButton buttonWithType:UIButtonTypeCustom];
buttonFrame.size.width = [title sizeWithFont:self.font].width + (kButtonOutset * 2);
buttonFrame.size.width = [title sizeWithAttributes:attrs].width + (kButtonOutset * 2);
button.frame = buttonFrame;
button.titleLabel.font = self.font;
button.tag = index++;
Expand Down
2 changes: 1 addition & 1 deletion Classes/WDBrushPreview.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ - (void) setup:(CGSize)size

CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
cgContext = CGBitmapContextCreate(pixels, backingWidth, backingHeight, 8, backingWidth * 4,
colorSpaceRef, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast);
colorSpaceRef, kCGBitmapByteOrderDefault | kImageAlphaPremultipliedLast);
CGColorSpaceRelease(colorSpaceRef);

if (self.path) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/WDBrushSizeOverlay.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ - (void) configureTitle
label.opaque = NO;
label.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:19.0f];
label.textColor = [UIColor whiteColor];
label.textAlignment = UITextAlignmentCenter;
label.textAlignment = NSTextAlignmentCenter;
label.text = @"512 px";
label.shadowColor = [UIColor blackColor];
label.shadowOffset = CGSizeMake(0, 1);
Expand Down
2 changes: 2 additions & 0 deletions Classes/WDBrushesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
return self;
}

- (void) dismissViewController:(UIViewController *)viewController {} // for delegate

- (void) done:(id)sender
{
if (self.delegate && [self.delegate respondsToSelector:@selector(dismissViewController:)]) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/WDCanvas.m
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ - (void) showMessage:(NSString *)message autoHide:(BOOL)autoHide position:(CGPoi
messageLabel_ = [[WDLabel alloc] initWithFrame:CGRectInset(CGRectMake(0,0,100,40), -8, -8)];
messageLabel_.textColor = [UIColor whiteColor];
messageLabel_.font = [UIFont boldSystemFontOfSize:24.0f];
messageLabel_.textAlignment = UITextAlignmentCenter;
messageLabel_.textAlignment = NSTextAlignmentCenter;
messageLabel_.opaque = NO;
messageLabel_.backgroundColor = nil;
messageLabel_.alpha = 0;
Expand Down
12 changes: 9 additions & 3 deletions Classes/WDCanvasController.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#import "WDUndoChange.h"
#import "WDUtilities.h"
#import "WDUnlockView.h"
#import "NSString+Drawing.h"

#define RESCALE_REPLAY 0
#define kNavBarFixedWidth 20
Expand Down Expand Up @@ -80,7 +81,9 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
return nil;
}

#ifndef __IPHONE_7_0
[self setWantsFullScreenLayout:YES];
#endif

return self;
}
Expand Down Expand Up @@ -871,10 +874,13 @@ - (UIImage *) layerImage

NSString *label = [NSString stringWithFormat:@"%lu", (unsigned long)index];

NSMutableParagraphStyle *paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paraStyle.lineBreakMode = NSLineBreakByClipping;
paraStyle.alignment = NSTextAlignmentCenter;

[label drawInRect:CGRectOffset(layerBox, 0, 1)
withFont:[UIFont boldSystemFontOfSize:13]
lineBreakMode:UILineBreakModeClip
alignment:UITextAlignmentCenter];
withAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:13],
NSParagraphStyleAttributeName:paraStyle}];
}

UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
Expand Down
2 changes: 1 addition & 1 deletion Classes/WDColorAdjustmentController.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// WDColorBalanceController.h
// WDColorAdjustmentController.h
// Brushes
//
// This Source Code Form is subject to the terms of the Mozilla Public
Expand Down
2 changes: 1 addition & 1 deletion Classes/WDColorAdjustmentController.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// WDColorBalanceController.m
// WDColorAdjustmentController.m
// Brushes
//
// This Source Code Form is subject to the terms of the Mozilla Public
Expand Down
2 changes: 2 additions & 0 deletions Classes/WDColorPickerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ @implementation WDColorPickerController
@synthesize secondCell;
@synthesize matrix;

- (void) dismissViewController:(UIViewController *)viewController {} // for delegate

- (IBAction)dismiss:(id)sender
{
[[self presentingViewController] dismissViewControllerAnimated:NO completion:nil];
Expand Down
2 changes: 1 addition & 1 deletion Classes/WDColorSlider.m
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ - (void) p_buildHueImage
}

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(data, width, height, 8, bpr, colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextRef ctx = CGBitmapContextCreate(data, width, height, 8, bpr, colorSpace, kImageAlphaPremultipliedFirst);
CGColorSpaceRelease(colorSpace);

hueImage_ = CGBitmapContextCreateImage(ctx);
Expand Down
2 changes: 1 addition & 1 deletion Classes/WDColorWheel.m
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ - (void) p_buildWheelImage
}

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(data, diameter, diameter, 8, bpr, colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextRef ctx = CGBitmapContextCreate(data, diameter, diameter, 8, bpr, colorSpace, kImageAlphaPremultipliedFirst);
CGColorSpaceRelease(colorSpace);

wheelImage_ = CGBitmapContextCreateImage(ctx);
Expand Down
2 changes: 2 additions & 0 deletions Classes/WDDictionaryDecoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ - (id) initWithDictionary:(NSDictionary *)dict progress:(WDCodingProgress *)prog

- (void) dealloc
{
#ifndef OS_OBJECT_USE_OBJC
if (dispatchQueue_) {
dispatch_release(dispatchQueue_);
}

if (dispatchGroup_) {
dispatch_release(dispatchGroup_);
}
#endif
}

- (WDCodingProgress *) progress
Expand Down
2 changes: 1 addition & 1 deletion Classes/WDHueShifter.m
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ - (void) p_buildHueImage
}

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(data, width, height, 8, bpr, colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextRef ctx = CGBitmapContextCreate(data, width, height, 8, bpr, colorSpace, kImageAlphaPremultipliedFirst);
CGColorSpaceRelease(colorSpace);

hueImage_ = CGBitmapContextCreateImage(ctx);
Expand Down
Loading