diff --git a/contrib/mobile/iOS/Onelab/ModelViewController.h b/contrib/mobile/iOS/Onelab/ModelViewController.h index 603d7802f407bbe0cc8f4a6815ce889f51398b81..9c5d307e1ec252f19040f95e1973db8380c5f690 100644 --- a/contrib/mobile/iOS/Onelab/ModelViewController.h +++ b/contrib/mobile/iOS/Onelab/ModelViewController.h @@ -18,16 +18,20 @@ { @private double scaleFactor; - UIBarButtonItem *_runStopButton; + UIBarButtonItem *_runStopButton, *_playButton, *_stopButton; UIAlertView *_loadingAlert; UIErrorAlertView *_errorAlert; NSMutableArray *_errors; UIBackgroundTaskIdentifier _computeBackgroundTaskIdentifier; + NSTimer *_animation; } - (IBAction)pinch:(UIPinchGestureRecognizer *)sender; -- (IBAction)tap:(UITapGestureRecognizer *)sender; +- (IBAction)singleTap:(UITapGestureRecognizer *)sender; +- (IBAction)doubleTap:(UITapGestureRecognizer *)sender; +@property (strong, nonatomic) IBOutlet UITapGestureRecognizer *singleTap; +@property (strong, nonatomic) IBOutlet UITapGestureRecognizer *doubleTap; @property (nonatomic, retain) EAGLView *glView; @property (strong, nonatomic) id detailItem; @property (weak, nonatomic) IBOutlet UILabel *progressLabel; diff --git a/contrib/mobile/iOS/Onelab/ModelViewController.mm b/contrib/mobile/iOS/Onelab/ModelViewController.mm index 8d0c5d5e465330cb8cc12457fc3d8fde1eb1a3bb..d765ddc492cd62c0abe24c2f1312c64fd9b7bffb 100644 --- a/contrib/mobile/iOS/Onelab/ModelViewController.mm +++ b/contrib/mobile/iOS/Onelab/ModelViewController.mm @@ -9,6 +9,7 @@ #import <Social/Social.h> #import "ModelViewController.h" +#import "drawContext.h" #import "iosGModel.h" #import "Utils.h" @@ -73,7 +74,7 @@ [_progressIndicator addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleProgressIndicatorTap:)]]; [_progressLabel setHidden:YES]; [_progressIndicator setHidden:YES]; - [self.navigationController setToolbarHidden:YES animated:YES]; + [self.navigationController setToolbarHidden:YES animated:NO]; if(self.initialModel != nil){ [self.glView load:self.initialModel]; [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshParameters" object:nil]; @@ -90,10 +91,12 @@ [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self configureView]; + [_singleTap requireGestureRecognizerToFail:_doubleTap]; scaleFactor = 1.; _errors = [[NSMutableArray alloc] init]; setObjCBridge((__bridge void*) self); [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(requestRender) name:@"requestRender" object:nil]; + _runStopButton = [[UIBarButtonItem alloc] initWithTitle:@"Run" style:UIBarButtonItemStyleBordered target:self action:@selector(compute)]; UIBarButtonItem *share = [[UIBarButtonItem alloc] initWithTitle:@"Share" style:UIBarButtonItemStyleBordered target:self action:@selector(share)]; if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){ @@ -105,6 +108,14 @@ UIBarButtonItem *settings = [[UIBarButtonItem alloc] initWithTitle:@"Parameters" style:UIBarButtonItemStyleBordered target:self action:@selector(showSettings)]; [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:_runStopButton, settings, share, nil]]; } + + UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; + UIBarButtonItem *prevButton = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem: UIBarButtonSystemItemRewind target:self action:@selector(prevAnimation)]; + _stopButton = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem: UIBarButtonSystemItemPause target:self action:@selector(stopAnimation:)]; + [_stopButton setEnabled:NO]; + _playButton = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem: UIBarButtonSystemItemPlay target:self action:@selector(playAnimation:)]; + UIBarButtonItem *nextButton = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem: UIBarButtonSystemItemFastForward target:self action:@selector(nextAnimation)]; + self.toolbarItems = [[NSArray alloc] initWithObjects:flexibleSpace, prevButton, _stopButton, _playButton, nextButton, flexibleSpace, nil]; } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation @@ -113,6 +124,21 @@ _progressIndicator.frame = CGRectMake(20, self.view.frame.size.height - 25, _progressIndicator.frame.size.width, _progressIndicator.frame.size.height); } +-(void)didReceiveMemoryWarning +{ + onelab_cb("stop"); + UILocalNotification *localNotif = [[UILocalNotification alloc] init]; + if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground && localNotif) { + localNotif.alertBody = @"The computing had to stop because your device ran out of memory"; + localNotif.alertAction = @"View"; + localNotif.hasAction = true; + localNotif.soundName = UILocalNotificationDefaultSoundName; + localNotif.applicationIconBadgeNumber = 1; + [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; + } + [[UIApplication sharedApplication] endBackgroundTask: _computeBackgroundTaskIdentifier]; +} + -(void)share { NSArray *dataToShare = @[[self.glView getGLScreenshot]]; @@ -169,6 +195,21 @@ { onelab_cb("stop"); } +-(void)playAnimation:(UIBarButtonItem *)sender +{ + [_playButton setEnabled:NO]; + [_stopButton setEnabled:YES]; + _animation = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(nextAnimation) userInfo:nil repeats:YES]; +} +-(void)stopAnimation:(UIBarButtonItem *)sender +{ + [_animation invalidate]; + _animation = nil; + [_playButton setEnabled:YES]; + [_stopButton setEnabled:NO]; +} +-(void)nextAnimation { animation_next(); [self requestRender]; } +-(void)prevAnimation { animation_prev(); [self requestRender]; } -(IBAction)pinch:(UIPinchGestureRecognizer *)sender { if([sender numberOfTouches] > 2) return; @@ -205,15 +246,14 @@ glView->mContext->eventHandler(4, touchPoint.x, touchPoint.y); } -- (IBAction)tap:(UITapGestureRecognizer *)sender -{ - sender.numberOfTapsRequired = 2; - sender.numberOfTouchesRequired = 1; - if(sender.state == UIGestureRecognizerStateEnded){ - scaleFactor = 1; - glView->mContext->eventHandler(10); - [glView drawView]; - } +- (IBAction)singleTap:(UITapGestureRecognizer *)sender { + [self.navigationController setToolbarHidden:!self.navigationController.toolbarHidden animated:YES]; +} + +- (IBAction)doubleTap:(UITapGestureRecognizer *)sender { + scaleFactor = 1; + glView->mContext->eventHandler(10); + [glView drawView]; } - (void) showModelsList @@ -245,6 +285,8 @@ [self setGlView:nil]; [self setProgressLabel:nil]; [self setProgressIndicator:nil]; + [self setSingleTap:nil]; + [self setDoubleTap:nil]; [super viewDidUnload]; // Release any retained subviews of the main view. } diff --git a/contrib/mobile/iOS/Onelab/en.lproj/iPadStoryboard.storyboard b/contrib/mobile/iOS/Onelab/en.lproj/iPadStoryboard.storyboard index 8ed448893df630c732e943518375f3bc38434a94..53ab1f63973ac834a8e1e142c1dcee53b0a9a1c7 100644 --- a/contrib/mobile/iOS/Onelab/en.lproj/iPadStoryboard.storyboard +++ b/contrib/mobile/iOS/Onelab/en.lproj/iPadStoryboard.storyboard @@ -49,22 +49,30 @@ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> <simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/> <connections> - <outletCollection property="gestureRecognizers" destination="RL1-jv-cjC" appends="YES" id="y8D-yh-PkV"/> <outletCollection property="gestureRecognizers" destination="Nb5-mS-uY7" appends="YES" id="aF3-Oi-e8B"/> + <outletCollection property="gestureRecognizers" destination="Rg0-JN-2rY" appends="YES" id="Idn-LL-Eok"/> + <outletCollection property="gestureRecognizers" destination="MRc-vF-047" appends="YES" id="BU4-EW-yFf"/> </connections> </view> <toolbarItems/> <navigationItem key="navigationItem" title="ONELAB" id="53"/> <connections> + <outlet property="doubleTap" destination="MRc-vF-047" id="mdb-zu-B2d"/> <outlet property="glView" destination="26" id="i7d-I7-Zhz"/> <outlet property="progressIndicator" destination="BfX-qT-0mL" id="O9E-Bm-5zQ"/> <outlet property="progressLabel" destination="HN2-fw-mfe" id="s62-5y-B7S"/> + <outlet property="singleTap" destination="Rg0-JN-2rY" id="eXQ-Gl-MxX"/> </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="15" sceneMemberID="firstResponder"/> - <tapGestureRecognizer id="RL1-jv-cjC"> + <tapGestureRecognizer id="Rg0-JN-2rY"> <connections> - <action selector="tap:" destination="4" id="hTk-hm-dba"/> + <action selector="singleTap:" destination="4" id="E0C-NP-r4x"/> + </connections> + </tapGestureRecognizer> + <tapGestureRecognizer numberOfTapsRequired="2" id="MRc-vF-047"> + <connections> + <action selector="doubleTap:" destination="4" id="ruZ-Qr-c1X"/> </connections> </tapGestureRecognizer> <pinchGestureRecognizer id="Nb5-mS-uY7"> @@ -301,41 +309,6 @@ <point key="canvasLocation" x="336" y="340"/> </scene> </scenes> - <classes> - <class className="EAGLView" superclassName="UIView"> - <source key="sourceIdentifier" type="project" relativePath="./Classes/EAGLView.h"/> - </class> - <class className="ModelListController" superclassName="UITableViewController"> - <source key="sourceIdentifier" type="project" relativePath="./Classes/ModelListController.h"/> - </class> - <class className="ModelViewController" superclassName="UIViewController"> - <source key="sourceIdentifier" type="project" relativePath="./Classes/ModelViewController.h"/> - <relationships> - <relationship kind="action" name="pinch:" candidateClass="UIPinchGestureRecognizer"/> - <relationship kind="action" name="tap:" candidateClass="UITapGestureRecognizer"/> - <relationship kind="outlet" name="detailDescriptionLabel" candidateClass="UILabel"/> - <relationship kind="outlet" name="progressIndicator" candidateClass="UIActivityIndicatorView"/> - <relationship kind="outlet" name="progressLabel" candidateClass="UILabel"/> - </relationships> - </class> - <class className="ParametersViewController" superclassName="UITableViewController"> - <source key="sourceIdentifier" type="project" relativePath="./Classes/ParametersViewController.h"/> - </class> - <class className="PostProcessingViewController" superclassName="UIViewController"> - <source key="sourceIdentifier" type="project" relativePath="./Classes/PostProcessingViewController.h"/> - <relationships> - <relationship kind="action" name="stepperValueChanged:" candidateClass="UIStepper"/> - <relationship kind="outlet" name="Intervals" candidateClass="UITextField"/> - <relationship kind="outlet" name="IntervalsStepper" candidateClass="UIStepper"/> - <relationship kind="outlet" name="IntervalsType" candidateClass="UIPickerView"/> - <relationship kind="outlet" name="Name" candidateClass="UILabel"/> - <relationship kind="outlet" name="RaiseZ" candidateClass="UISlider"/> - </relationships> - </class> - <class className="SplitViewController" superclassName="UISplitViewController"> - <source key="sourceIdentifier" type="project" relativePath="./Classes/SplitViewController.h"/> - </class> - </classes> <simulatedMetricsContainer key="defaultSimulatedMetrics"> <simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/> <simulatedOrientationMetrics key="orientation"/> diff --git a/contrib/mobile/iOS/Onelab/en.lproj/iPhoneiPodStoryboard.storyboard b/contrib/mobile/iOS/Onelab/en.lproj/iPhoneiPodStoryboard.storyboard index 5495f60b79f732b310f2f0ed632806a3cb298571..74951164b11a56dee489172764cfa65ebacb11c0 100644 --- a/contrib/mobile/iOS/Onelab/en.lproj/iPhoneiPodStoryboard.storyboard +++ b/contrib/mobile/iOS/Onelab/en.lproj/iPhoneiPodStoryboard.storyboard @@ -69,16 +69,23 @@ </view> <navigationItem key="navigationItem" title="ONELAB" id="WX3-lU-bHf"/> <connections> + <outlet property="doubleTap" destination="mEQ-72-g58" id="xrl-dg-7EI"/> <outlet property="glView" destination="zrj-Dd-WPc" id="sIP-YC-fg2"/> <outlet property="progressIndicator" destination="Fuh-zG-zVR" id="ifr-7g-7Dv"/> <outlet property="progressLabel" destination="yT7-IR-qUJ" id="onn-gw-Mnv"/> + <outlet property="singleTap" destination="7R3-zZ-cpa" id="Xlw-Pp-Szf"/> <segue destination="0h7-h3-thM" kind="push" identifier="showSettingsSegue" id="cJz-7s-fgZ"/> </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="aSF-6U-E6q" userLabel="First Responder" sceneMemberID="firstResponder"/> <tapGestureRecognizer id="7R3-zZ-cpa"> <connections> - <action selector="tap:" destination="NyB-7w-cP0" id="Jvc-pf-zod"/> + <action selector="singleTap:" destination="NyB-7w-cP0" id="ywu-41-GBg"/> + </connections> + </tapGestureRecognizer> + <tapGestureRecognizer numberOfTapsRequired="2" id="mEQ-72-g58"> + <connections> + <action selector="doubleTap:" destination="NyB-7w-cP0" id="95f-15-F18"/> </connections> </tapGestureRecognizer> <pinchGestureRecognizer id="qCm-Ub-mO2">