Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update for stricter compiler settings.

  • Loading branch information...
commit 9ed55edf02900a27ff805d0db825464b348d1ce9 1 parent 605f67f
@mbaltaks authored
View
10 Classes/MGSplitCornersView.h
@@ -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.
@@ -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;
View
29 Classes/MGSplitCornersView.m
@@ -33,8 +33,8 @@ - (id)initWithFrame:(CGRect)frame
- (void)dealloc
{
- self.cornerBackgroundColor = nil;
-
+ self.cornerBackgroundColor_ = nil;
+
[super dealloc];
}
@@ -42,7 +42,7 @@ - (void)dealloc
#pragma mark -
#pragma mark Geometry helpers
-
+double deg2Rad(double degrees);
double deg2Rad(double degrees)
{
// Converts degrees to radians.
@@ -50,12 +50,24 @@ - (void)dealloc
}
+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
@@ -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];
}
}
@@ -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];
}
}
View
4 Classes/MGSplitDividerView.h
@@ -10,8 +10,8 @@
@class MGSplitViewController;
@interface MGSplitDividerView : UIView {
- MGSplitViewController *splitViewController;
- BOOL allowsDragging;
+ MGSplitViewController *splitViewController_;
+ BOOL allowsDragging_;
}
@property (nonatomic, assign) MGSplitViewController *splitViewController; // weak ref.
View
3  Classes/MGSplitDividerView.m
@@ -30,7 +30,8 @@ - (id)initWithFrame:(CGRect)frame
- (void)dealloc
{
- self.splitViewController = nil;
+ self.splitViewController_ = nil;
+
[super dealloc];
}
View
9 Classes/MGSplitViewController.m
@@ -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;
@@ -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) {
@@ -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];
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.