Skip to content

Commit

Permalink
Add new flip style: Inward
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Pospesel committed May 16, 2012
1 parent f24c3cc commit dfacc60
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 2 deletions.
9 changes: 7 additions & 2 deletions MPFoldTransition/MPFoldTransition/MPFlipEnumerations.h
Expand Up @@ -17,20 +17,25 @@
// Horizontal = page flips right to left about a vertical spine // Horizontal = page flips right to left about a vertical spine
// Vertical = page flips bottom to top about a horizontal spine // Vertical = page flips bottom to top about a horizontal spine


// Bit 2: Perspective - Outward (unset) vs. Inward (set)
// Outward = page flips towards viewer
// Inward = page flips away from viewer

// TODO: spine position (left, mid, right // top, mid, bottom) // TODO: spine position (left, mid, right // top, mid, bottom)


enum { enum {
// current view folds away into center, next view slides in flat from top & bottom // current view folds away into center, next view slides in flat from top & bottom
MPFlipStyleDefault = 0, MPFlipStyleDefault = 0,
MPFlipStyleDirectionBackward = 1 << 0, MPFlipStyleDirectionBackward = 1 << 0,
MPFlipStyleVertical = 1 << 1 MPFlipStyleVertical = 1 << 1,
MPFlipStyleInward = 1 << 2
}; };
typedef NSUInteger MPFlipStyle; typedef NSUInteger MPFlipStyle;


#define MPFlipStyleDirectionMask MPFlipStyleDirectionBackward #define MPFlipStyleDirectionMask MPFlipStyleDirectionBackward
#define MPFlipStyleOrientationMask MPFlipStyleVertical #define MPFlipStyleOrientationMask MPFlipStyleVertical
#define MPFlipStylePerspectiveMask MPFlipStyleInward


static inline MPFlipStyle MPFlipStyleFlipDirectionBit(MPFlipStyle style) { return (style & ~MPFlipStyleDirectionMask) | ((style & MPFlipStyleDirectionMask) == MPFlipStyleDirectionBackward? 0 : MPFlipStyleDirectionBackward); } static inline MPFlipStyle MPFlipStyleFlipDirectionBit(MPFlipStyle style) { return (style & ~MPFlipStyleDirectionMask) | ((style & MPFlipStyleDirectionMask) == MPFlipStyleDirectionBackward? 0 : MPFlipStyleDirectionBackward); }



#endif #endif
3 changes: 3 additions & 0 deletions MPFoldTransition/MPFoldTransition/MPFlipTransition.m
Expand Up @@ -82,6 +82,7 @@ - (void)perform:(void (^)(BOOL finished))completion
{ {
BOOL forwards = ([self style] & MPFlipStyleDirectionMask) != MPFlipStyleDirectionBackward; BOOL forwards = ([self style] & MPFlipStyleDirectionMask) != MPFlipStyleDirectionBackward;
BOOL vertical = ([self style] & MPFlipStyleOrientationMask) == MPFlipStyleVertical; BOOL vertical = ([self style] & MPFlipStyleOrientationMask) == MPFlipStyleVertical;
BOOL inward = ([self style] & MPFlipStylePerspectiveMask) == MPFlipStyleInward;


CGRect bounds = self.rect; CGRect bounds = self.rect;
CGFloat scale = [[UIScreen mainScreen] scale]; CGFloat scale = [[UIScreen mainScreen] scale];
Expand Down Expand Up @@ -249,6 +250,8 @@ - (void)perform:(void (^)(BOOL finished))completion
transform.m34 = -1.0/(height * 4.6666667); transform.m34 = -1.0/(height * 4.6666667);
else else
transform.m34 = [self m34]; transform.m34 = [self m34];
if (inward)
transform.m34 = -transform.m34; // flip perspective around
mainView.layer.sublayerTransform = transform; mainView.layer.sublayerTransform = transform;


NSString *rotationKey = vertical? @"transform.rotation.x" : @"transform.rotation.y"; NSString *rotationKey = vertical? @"transform.rotation.x" : @"transform.rotation.y";
Expand Down
71 changes: 71 additions & 0 deletions MPFoldTransition/en.lproj/MainStoryboard_iPad.storyboard
Expand Up @@ -254,6 +254,46 @@
</tableViewCell> </tableViewCell>
</cells> </cells>
</tableViewSection> </tableViewSection>
<tableViewSection headerTitle="Perspective" id="37w-ml-eDR">
<cells>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="NLU-7W-yLV" style="IBUITableViewCellStyleDefault" id="Wnh-TL-D3z">
<rect key="frame" x="0.0" y="242" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Outward" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="NLU-7W-yLV">
<rect key="frame" x="10" y="0.0" width="300" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="oWZ-ZT-wLL" style="IBUITableViewCellStyleDefault" id="uTf-lO-sEM">
<rect key="frame" x="0.0" y="286" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Inward" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="oWZ-ZT-wLL">
<rect key="frame" x="10" y="0.0" width="300" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</tableViewCell>
</cells>
</tableViewSection>
</sections> </sections>
<connections> <connections>
<outlet property="dataSource" destination="iUX-9O-Kqh" id="ERy-44-cYQ"/> <outlet property="dataSource" destination="iUX-9O-Kqh" id="ERy-44-cYQ"/>
Expand Down Expand Up @@ -499,6 +539,37 @@
<point key="canvasLocation" x="751" y="747"/> <point key="canvasLocation" x="751" y="747"/>
</scene> </scene>
</scenes> </scenes>
<classes>
<class className="AboutViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/AboutViewController.h"/>
<relationships>
<relationship kind="action" name="donePressed:"/>
</relationships>
</class>
<class className="DetailsViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/DetailsViewController.h"/>
<relationships>
<relationship kind="action" name="popPressed:"/>
</relationships>
</class>
<class className="StyleTable" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/StyleTable.h"/>
<relationships>
<relationship kind="action" name="donePressed:"/>
</relationships>
</class>
<class className="ViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/ViewController.h"/>
<relationships>
<relationship kind="action" name="detailPressed:"/>
<relationship kind="action" name="infoPressed:"/>
<relationship kind="action" name="modeValueChanged:"/>
<relationship kind="action" name="stepperValueChanged:"/>
<relationship kind="action" name="stylePressed:" candidateClass="UIBarButtonItem"/>
<relationship kind="outlet" name="contentView" candidateClass="UIView"/>
</relationships>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics"> <simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/> <simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/>
<simulatedOrientationMetrics key="orientation"/> <simulatedOrientationMetrics key="orientation"/>
Expand Down
40 changes: 40 additions & 0 deletions MPFoldTransition/en.lproj/MainStoryboard_iPhone.storyboard
Expand Up @@ -346,6 +346,46 @@
</tableViewCell> </tableViewCell>
</cells> </cells>
</tableViewSection> </tableViewSection>
<tableViewSection headerTitle="Perspective" id="9JZ-VR-Eaa">
<cells>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="slD-Y3-cVq" style="IBUITableViewCellStyleDefault" id="FwA-9A-LWv">
<rect key="frame" x="0.0" y="242" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Outward" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="slD-Y3-cVq">
<rect key="frame" x="10" y="0.0" width="300" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="HTl-hg-zDL" style="IBUITableViewCellStyleDefault" id="4c3-5d-dCN">
<rect key="frame" x="0.0" y="286" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Inward" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="HTl-hg-zDL">
<rect key="frame" x="10" y="0.0" width="300" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</tableViewCell>
</cells>
</tableViewSection>
</sections> </sections>
<connections> <connections>
<outlet property="dataSource" destination="pmA-wI-nyX" id="V2z-jO-3HX"/> <outlet property="dataSource" destination="pmA-wI-nyX" id="V2z-jO-3HX"/>
Expand Down

0 comments on commit dfacc60

Please sign in to comment.