Skip to content

Commit

Permalink
Close button on description.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeradesign committed Feb 1, 2013
1 parent c192c45 commit f29cf4f
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 32 deletions.
4 changes: 4 additions & 0 deletions CVFunhouse.xcodeproj/project.pbxproj
Expand Up @@ -12,6 +12,7 @@
4209534715C0BEB200C37CD8 /* CVFMotionTemplates.m in Sources */ = {isa = PBXBuildFile; fileRef = 4209534615C0BEB200C37CD8 /* CVFMotionTemplates.m */; };
420A3F8515BC6724004804EF /* CVFPassThru.m in Sources */ = {isa = PBXBuildFile; fileRef = 420A3F8415BC6724004804EF /* CVFPassThru.m */; };
42171D1215BA6C19008BEA68 /* opencv2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42171D1115BA6C19008BEA68 /* opencv2.framework */; };
421897E616BC879900AC716C /* CloseButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 421897E516BC879900AC716C /* CloseButton.png */; };
423FA83715DB1AD3001D30AC /* SwitchCameraIcon44.png in Resources */ = {isa = PBXBuildFile; fileRef = 423FA83515DB1AD3001D30AC /* SwitchCameraIcon44.png */; };
423FA83815DB1AD3001D30AC /* SwitchCameraIcon44@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 423FA83615DB1AD3001D30AC /* SwitchCameraIcon44@2x.png */; };
423FA83B15DB264B001D30AC /* iButton30.png in Resources */ = {isa = PBXBuildFile; fileRef = 423FA83915DB264B001D30AC /* iButton30.png */; };
Expand Down Expand Up @@ -58,6 +59,7 @@
420A3F8315BC6724004804EF /* CVFPassThru.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CVFPassThru.h; path = CVFunhouse/CVFPassThru.h; sourceTree = "<group>"; };
420A3F8415BC6724004804EF /* CVFPassThru.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CVFPassThru.m; path = CVFunhouse/CVFPassThru.m; sourceTree = "<group>"; };
42171D1115BA6C19008BEA68 /* opencv2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = opencv2.framework; sourceTree = "<group>"; };
421897E516BC879900AC716C /* CloseButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseButton.png; sourceTree = "<group>"; };
423FA83515DB1AD3001D30AC /* SwitchCameraIcon44.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SwitchCameraIcon44.png; sourceTree = "<group>"; };
423FA83615DB1AD3001D30AC /* SwitchCameraIcon44@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "SwitchCameraIcon44@2x.png"; sourceTree = "<group>"; };
423FA83915DB264B001D30AC /* iButton30.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = iButton30.png; sourceTree = "<group>"; };
Expand Down Expand Up @@ -155,6 +157,7 @@
4285252915BF6CDF00622EE8 /* Resources */ = {
isa = PBXGroup;
children = (
421897E516BC879900AC716C /* CloseButton.png */,
428D978216A275450073329A /* CVFFaceDetect.html */,
428D978316A275450073329A /* CVFCannyDemo.html */,
423FA83915DB264B001D30AC /* iButton30.png */,
Expand Down Expand Up @@ -310,6 +313,7 @@
428D978516A275450073329A /* CVFCannyDemo.html in Resources */,
42E60DB416BB52E500F9712B /* Demos.plist in Resources */,
426B881416BC6BE30093D62F /* NoDescription.html in Resources */,
421897E616BC879900AC716C /* CloseButton.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 2 additions & 0 deletions CVFunhouse/CVFMainViewController.h
Expand Up @@ -25,10 +25,12 @@
@property (weak, nonatomic) IBOutlet UILabel *fpsLabel;
@property (weak, nonatomic) IBOutlet UIButton *flipCameraButton;
@property (weak, nonatomic) IBOutlet UIWebView *descriptionView;
@property (weak, nonatomic) IBOutlet UIView *descriptionContainer;


- (IBAction)flipAction:(id)sender;
- (IBAction)swipeUpAction:(id)sender;
- (IBAction)swipeDownAction:(id)sender;
- (IBAction)closeDescription:(id)sender;

@end
36 changes: 22 additions & 14 deletions CVFunhouse/CVFMainViewController.m
Expand Up @@ -111,17 +111,17 @@ - (void)showHideFPS {
}

- (void)initializeDescription {
self.descriptionView.layer.borderColor = [UIColor blackColor].CGColor;
self.descriptionView.layer.borderWidth = 1.0;
self.descriptionContainer.layer.borderColor = [UIColor blackColor].CGColor;
self.descriptionContainer.layer.borderWidth = 1.0;

_descriptionOnScreenCenter = self.descriptionView.center;
_descriptionOffScreenCenter = self.descriptionView.center;
int descriptionTopY = self.descriptionView.center.y -
self.descriptionView.bounds.size.height / 2;
_descriptionOnScreenCenter = self.descriptionContainer.center;
_descriptionOffScreenCenter = self.descriptionContainer.center;
int descriptionTopY = self.descriptionContainer.center.y -
self.descriptionContainer.bounds.size.height / 2;
_descriptionOffScreenCenter.y += self.view.bounds.size.height - descriptionTopY;

bool showDescription = [[NSUserDefaults standardUserDefaults] boolForKey:@"showDescription"];
self.descriptionView.hidden = !showDescription;
self.descriptionContainer.hidden = !showDescription;
if (showDescription) {
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
Expand All @@ -133,21 +133,21 @@ - (void)initializeDescription {

- (void)showHideDescription {
bool showDescription = [[NSUserDefaults standardUserDefaults] boolForKey:@"showDescription"];
if (showDescription && self.descriptionView.isHidden) {
self.descriptionView.center = _descriptionOffScreenCenter;
[self.descriptionView setHidden:false];
if (showDescription && self.descriptionContainer.isHidden) {
self.descriptionContainer.center = _descriptionOffScreenCenter;
[self.descriptionContainer setHidden:false];
[UIView animateWithDuration:0.5 animations:^{
self.descriptionView.center = _descriptionOnScreenCenter;
self.descriptionContainer.center = _descriptionOnScreenCenter;
} completion:^(BOOL finished) {
#pragma unused(finished)
[self.descriptionView.scrollView flashScrollIndicators];
}];
} else if (!showDescription && !self.descriptionView.isHidden) {
} else if (!showDescription && !self.descriptionContainer.isHidden) {
[UIView animateWithDuration:0.5 animations:^{
self.descriptionView.center = _descriptionOffScreenCenter;
self.descriptionContainer.center = _descriptionOffScreenCenter;
} completion:^(BOOL finished) {
#pragma unused(finished)
self.descriptionView.hidden = true;
self.descriptionContainer.hidden = true;
}];
}
}
Expand All @@ -173,6 +173,7 @@ - (void)viewDidUnload
[self setFpsLabel:nil];
[self setFlipCameraButton:nil];
[self setDescriptionView:nil];
[self setDescriptionContainer:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
Expand Down Expand Up @@ -276,6 +277,13 @@ - (IBAction)swipeDownAction:(id)sender {
[[NSNotificationCenter defaultCenter] postNotificationName:@"showDescription" object:nil];
}

- (IBAction)closeDescription:(id)sender {
#pragma unused(sender)
[[NSUserDefaults standardUserDefaults] setBool:false forKey:@"showDescription"];
[[NSUserDefaults standardUserDefaults] synchronize];
[[NSNotificationCenter defaultCenter] postNotificationName:@"showDescription" object:nil];
}

#pragma mark - CVFImageProcessorDelegate

-(void)imageProcessor:(CVFImageProcessor*)imageProcessor didCreateImage:(UIImage*)image
Expand Down
38 changes: 32 additions & 6 deletions CVFunhouse/en.lproj/MainStoryboard_iPad.storyboard
Expand Up @@ -54,14 +54,36 @@
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<webView contentMode="scaleToFill" id="hPX-KJ-ZGW">
<view contentMode="scaleToFill" id="PAM-VT-1N3">
<rect key="frame" x="20" y="682" width="728" height="342"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<outlet property="delegate" destination="2" id="M35-nC-p1g"/>
</connections>
</webView>
<subviews>
<webView contentMode="scaleToFill" id="hPX-KJ-ZGW">
<rect key="frame" x="0.0" y="0.0" width="728" height="342"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<outlet property="delegate" destination="2" id="M35-nC-p1g"/>
</connections>
</webView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="ltt-cb-8eG">
<rect key="frame" x="690" y="15.5" width="25" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="Close" image="CloseButton.png">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="closeDescription:" destination="2" eventType="touchUpInside" id="fAJ-C1-dhv"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" white="0.25" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<gestureRecognizers/>
Expand All @@ -71,6 +93,7 @@
</connections>
</view>
<connections>
<outlet property="descriptionContainer" destination="PAM-VT-1N3" id="sMS-oX-Tbi"/>
<outlet property="descriptionView" destination="hPX-KJ-ZGW" id="Eev-Nz-X35"/>
<outlet property="flipCameraButton" destination="7u2-8o-3p8" id="FQA-hU-wEE"/>
<outlet property="fpsLabel" destination="8Qh-6U-N8N" id="p7r-5Y-fzc"/>
Expand Down Expand Up @@ -147,6 +170,7 @@
</scene>
</scenes>
<resources>
<image name="CloseButton.png" width="100" height="100"/>
<image name="SwitchCameraIcon44.png" width="44" height="25"/>
<image name="iButton30.png" width="30" height="30"/>
</resources>
Expand All @@ -162,9 +186,11 @@
<class className="CVFMainViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/CVFMainViewController.h"/>
<relationships>
<relationship kind="action" name="closeDescription:"/>
<relationship kind="action" name="flipAction:"/>
<relationship kind="action" name="swipeDownAction:"/>
<relationship kind="action" name="swipeUpAction:"/>
<relationship kind="outlet" name="descriptionContainer" candidateClass="UIView"/>
<relationship kind="outlet" name="descriptionView" candidateClass="UIWebView"/>
<relationship kind="outlet" name="flipCameraButton" candidateClass="UIButton"/>
<relationship kind="outlet" name="fpsLabel" candidateClass="UILabel"/>
Expand Down
42 changes: 34 additions & 8 deletions CVFunhouse/en.lproj/MainStoryboard_iPhone.storyboard
Expand Up @@ -16,14 +16,6 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
<webView contentMode="scaleToFill" id="TVS-vQ-ZgI">
<rect key="frame" x="0.0" y="238" width="320" height="177"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<outlet property="delegate" destination="2" id="Ad1-fd-nXq"/>
</connections>
</webView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" alpha="0.75" contentMode="left" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="dX3-k0-41q">
<rect key="frame" x="113" y="434" width="95" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
Expand Down Expand Up @@ -62,6 +54,36 @@
<segue destination="6" kind="modal" identifier="showAlternate" modalTransitionStyle="flipHorizontal" id="11"/>
</connections>
</button>
<view contentMode="scaleToFill" id="fnl-NY-TTY">
<rect key="frame" x="0.0" y="238" width="320" height="177"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<subviews>
<webView contentMode="scaleToFill" id="TVS-vQ-ZgI">
<rect key="frame" x="0.0" y="0.0" width="320" height="177"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<outlet property="delegate" destination="2" id="Ad1-fd-nXq"/>
</connections>
</webView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="RlS-1Z-PKE">
<rect key="frame" x="286.5" y="9.5" width="20" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" image="CloseButton.png">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="closeDescription:" destination="2" eventType="touchUpInside" id="xnA-mm-soM"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" white="0.25" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<gestureRecognizers/>
Expand All @@ -72,6 +94,7 @@
</view>
<nil key="simulatedStatusBarMetrics"/>
<connections>
<outlet property="descriptionContainer" destination="fnl-NY-TTY" id="z6k-Kb-5eT"/>
<outlet property="descriptionView" destination="TVS-vQ-ZgI" id="EpH-vs-i3P"/>
<outlet property="flipCameraButton" destination="lKb-tT-4x6" id="CMq-0W-Cdx"/>
<outlet property="fpsLabel" destination="dX3-k0-41q" id="sT8-Ia-RYD"/>
Expand Down Expand Up @@ -150,6 +173,7 @@
</scene>
</scenes>
<resources>
<image name="CloseButton.png" width="100" height="100"/>
<image name="SwitchCameraIcon44.png" width="44" height="25"/>
<image name="iButton30.png" width="30" height="30"/>
</resources>
Expand All @@ -165,9 +189,11 @@
<class className="CVFMainViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/CVFMainViewController.h"/>
<relationships>
<relationship kind="action" name="closeDescription:"/>
<relationship kind="action" name="flipAction:"/>
<relationship kind="action" name="swipeDownAction:"/>
<relationship kind="action" name="swipeUpAction:"/>
<relationship kind="outlet" name="descriptionContainer" candidateClass="UIView"/>
<relationship kind="outlet" name="descriptionView" candidateClass="UIWebView"/>
<relationship kind="outlet" name="flipCameraButton" candidateClass="UIButton"/>
<relationship kind="outlet" name="fpsLabel" candidateClass="UILabel"/>
Expand Down
Binary file added CloseButton.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f29cf4f

Please sign in to comment.