Skip to content

Commit

Permalink
Update for stricter compiler settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaltaks committed Nov 22, 2012
1 parent 605f67f commit c390133
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
10 changes: 6 additions & 4 deletions Classes/MGSplitCornersView.h
Expand Up @@ -8,6 +8,8 @@

#import <UIKit/UIKit.h>

int floatsAreEqual(float a, float b);

typedef enum _MGCornersPosition {
MGCornersPositionLeadingVertical = 0, // top of screen for a left/right split.
MGCornersPositionTrailingVertical = 1, // bottom of screen for a left/right split.
Expand All @@ -17,10 +19,10 @@ typedef enum _MGCornersPosition {

@class MGSplitViewController;
@interface MGSplitCornersView : UIView {
float cornerRadius;
MGSplitViewController *splitViewController;
MGCornersPosition cornersPosition;
UIColor *cornerBackgroundColor;
float cornerRadius_;
MGSplitViewController *splitViewController_;
MGCornersPosition cornersPosition_;
UIColor *cornerBackgroundColor_;
}

@property (nonatomic, assign) float cornerRadius;
Expand Down
27 changes: 20 additions & 7 deletions Classes/MGSplitCornersView.m
Expand Up @@ -33,29 +33,41 @@ - (id)initWithFrame:(CGRect)frame

- (void)dealloc
{
self.cornerBackgroundColor = nil;

[super dealloc];
cornerBackgroundColor_ = nil;
}


#pragma mark -
#pragma mark Geometry helpers


double deg2Rad(double degrees);
double deg2Rad(double degrees)
{
// Converts degrees to radians.
return degrees * (M_PI / 180.0);
}


double rad2Deg(double radians);
double rad2Deg(double radians)
{
// Converts radians to degrees.
return radians * (180 / M_PI);
}

int floatsAreEqual(float a, float b)
{
int r = 1;
if (a - b > 0
|| a - b < 0)
{
r = 0;
}
return r;
}


#pragma mark -
#pragma mark Drawing
Expand Down Expand Up @@ -197,8 +209,9 @@ - (void)drawRect:(CGRect)rect

- (void)setCornerRadius:(float)newRadius
{
if (newRadius != cornerRadius) {
cornerRadius = newRadius;
if (!floatsAreEqual(newRadius, cornerRadius_))
{
cornerRadius_ = newRadius;
[self setNeedsDisplay];
}
}
Expand All @@ -224,9 +237,9 @@ - (void)setCornersPosition:(MGCornersPosition)posn

- (void)setCornerBackgroundColor:(UIColor *)color
{
if (color != cornerBackgroundColor) {
[cornerBackgroundColor release];
cornerBackgroundColor = [color retain];
if (color != cornerBackgroundColor_) {
[cornerBackgroundColor_ release];
cornerBackgroundColor_ = [color retain];
[self setNeedsDisplay];
}
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/MGSplitDividerView.h
Expand Up @@ -10,8 +10,8 @@

@class MGSplitViewController;
@interface MGSplitDividerView : UIView {
MGSplitViewController *splitViewController;
BOOL allowsDragging;
MGSplitViewController *splitViewController_;
BOOL allowsDragging_;
}

@property (nonatomic, assign) MGSplitViewController *splitViewController; // weak ref.
Expand Down
2 changes: 1 addition & 1 deletion Classes/MGSplitDividerView.m
Expand Up @@ -30,8 +30,8 @@ - (id)initWithFrame:(CGRect)frame

- (void)dealloc
{
self.splitViewController = nil;
[super dealloc];
splitViewController_ = nil;
}


Expand Down
9 changes: 4 additions & 5 deletions Classes/MGSplitViewController.m
Expand Up @@ -24,7 +24,7 @@
#define MG_ANIMATION_CHANGE_SUBVIEWS_ORDER @"ChangeSubviewsOrder" // Animation ID for internal use.


@interface MGSplitViewController (MGPrivateMethods)
@interface MGSplitViewController ()

- (void)setup;
- (CGSize)splitViewSizeForOrientation:(UIInterfaceOrientation)theOrientation;
Expand Down Expand Up @@ -857,7 +857,7 @@ - (void)setSplitPosition:(float)posn
// Apply default constraints if delegate doesn't wish to participate.
float minPos = MG_MIN_VIEW_WIDTH;
float maxPos = ((_vertical) ? fullSize.width : fullSize.height) - (MG_MIN_VIEW_WIDTH + _splitWidth);
constrained = (newPosn != _splitPosition && newPosn >= minPos && newPosn <= maxPos);
constrained = (!floatsAreEqual(newPosn, _splitPosition) && newPosn >= minPos && newPosn <= maxPos);
}

if (constrained) {
Expand Down Expand Up @@ -900,7 +900,7 @@ - (float)splitWidth

- (void)setSplitWidth:(float)width
{
if (width != _splitWidth && width >= 0) {
if (!floatsAreEqual(width, _splitWidth) && width >= 0) {
_splitWidth = width;
if ([self isShowingMaster]) {
[self layoutSubviews];
Expand Down Expand Up @@ -1074,9 +1074,8 @@ - (void)setDividerStyle:(MGSplitViewDividerStyle)newStyle
_dividerStyle = newStyle;

// Reconfigure general appearance and behaviour.
float cornerRadius;
float cornerRadius = MG_DEFAULT_CORNER_RADIUS;
if (_dividerStyle == MGSplitViewDividerStyleThin) {
cornerRadius = MG_DEFAULT_CORNER_RADIUS;
_splitWidth = MG_DEFAULT_SPLIT_WIDTH;
self.allowsDraggingDivider = NO;

Expand Down

0 comments on commit c390133

Please sign in to comment.