Skip to content
Snippets Groups Projects
Commit 105bd79e authored by Maxime Graulich's avatar Maxime Graulich
Browse files

iOS: UI more intuitive

parent 36d18a7e
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
@property (nonatomic, retain) EAGLView *glView;
@property (strong, nonatomic) id detailItem;
@property (weak, nonatomic) IBOutlet UIButton *runStopButton;
@property (weak, nonatomic) IBOutlet UILabel *detailDescriptionLabel;
......
......@@ -43,11 +43,21 @@
}
}
-(void)viewWillAppear:(BOOL)animated
{
_runStopButton.frame = CGRectMake(self.view.frame.size.width - _runStopButton.frame.size.width - 7, 50, _runStopButton.frame.size.width, _runStopButton.frame.size.height );
}
-(void)viewDidAppear:(BOOL)animated
{
if(self.initialModel != nil) [self.glView load:self.initialModel];
if(self.initialModel != nil){
UIAlertView* progressAlert = [[UIAlertView alloc] initWithTitle:@"Please wait..." message: @"The model is loading" delegate: self cancelButtonTitle: nil otherButtonTitles: nil];
[progressAlert show];
[self.glView load:self.initialModel];
//[self.initialModel release];
self.initialModel = nil;
[progressAlert dismissWithClickedButtonIndex:-1 animated:YES];
}
}
- (void)viewDidLoad
......@@ -59,16 +69,48 @@
setObjCBridge((__bridge void*) self);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(requestRender) name:@"requestRender" object:nil];
if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){
UIBarButtonItem *model = [[UIBarButtonItem alloc] initWithTitle:@"Models list" style:UIBarButtonItemStyleBordered target:self action:@selector(showModelsList)];
UIBarButtonItem *model = [[UIBarButtonItem alloc] initWithTitle:@"Model list" style:UIBarButtonItemStyleBordered target:self action:@selector(showModelsList)];
[self.navigationItem setRightBarButtonItem:model];
}
else
{
UIBarButtonItem *settings = [[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStyleBordered target:self action:@selector(showSettings)];
UIBarButtonItem *settings = [[UIBarButtonItem alloc] initWithTitle:@"Parameters" style:UIBarButtonItemStyleBordered target:self action:@selector(showSettings)];
[self.navigationItem setRightBarButtonItem:settings];
}
[_runStopButton addTarget:self action:@selector(compute) forControlEvents:UIControlEventTouchDown];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
_runStopButton.frame = CGRectMake(self.view.frame.size.width - _runStopButton.frame.size.width - 7, 50, _runStopButton.frame.size.width, _runStopButton.frame.size.height );
}
- (void)compute
{
[_runStopButton addTarget:self action:@selector(stop) forControlEvents:UIControlEventTouchDown];
[_runStopButton setTitle:@"Stop" forState:UIControlStateNormal];
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate->compute = YES;
onelab_cb("compute");
[self performSelectorOnMainThread:@selector(didStopCompute:) withObject:nil waitUntilDone:YES];
appDelegate->compute = NO;
});
}
- (void)didStopCompute:(id)sender
{
[self performSelectorOnMainThread:@selector(didStopCompute) withObject:nil waitUntilDone:NO];
}
- (void)didStopCompute
{
[_runStopButton addTarget:self action:@selector(compute) forControlEvents:UIControlEventTouchDown];
[_runStopButton setTitle:@"Run" forState:UIControlStateNormal];
}
- (void)stop
{
onelab_cb("stop");
}
- (IBAction)pinch:(UIPinchGestureRecognizer *)sender
{
if([sender numberOfTouches] > 2) return;
......@@ -150,6 +192,7 @@
- (void)viewDidUnload
{
[self setGlView:nil];
[self setRunStopButton:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
......@@ -168,7 +211,7 @@
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem.title = NSLocalizedString(@"Settings", @"Settings");
barButtonItem.title = NSLocalizedString(@"Parameters", @"Parameters");
[self.navigationItem setLeftBarButtonItem:barButtonItem];
self.masterPopoverController = popoverController;
}
......
......@@ -9,6 +9,7 @@
#import "OptionsViewController.h"
#import "ParametersViewController.h"
#import "PostProcessingViewController.h"
#import "ModelViewController.h"
#include <gmsh/Context.h>
#include <gmsh/PView.h>
......@@ -38,15 +39,17 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshOptions:) name:@"refreshParameters" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshOptions:) name:@"resetParameters" object:nil];
self.navigationItem.title = @"Views Options";
self.navigationItem.title = @"Display";
[self.navigationController setToolbarHidden:NO];
control = [[UISegmentedControl alloc] initWithItems:[[NSArray alloc] initWithObjects:@"Model's Parmeters", @"Views Options", nil]];
control = [[UISegmentedControl alloc] initWithItems:[[NSArray alloc] initWithObjects:@"Model", @"Display", nil]];
control.segmentedControlStyle = UISegmentedControlStyleBar;
UIBarButtonItem *controlBtn = [[UIBarButtonItem alloc] initWithCustomView:control];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
self.toolbarItems = [[NSArray alloc] initWithObjects:flexibleSpace, controlBtn, flexibleSpace, nil];
[control addTarget:self action:@selector(indexDidChangeForSegmentedControl:) forControlEvents:UIControlEventValueChanged];
if(![[UIDevice currentDevice].model isEqualToString:@"iPad"] && ![[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"])
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed:)];
}
- (void)viewWillAppear:(BOOL)animated
{
......@@ -54,9 +57,14 @@
[super viewWillAppear:animated];
}
-(void)backButtonPressed:(id)sender
{
for(UIViewController *v in [self.navigationController viewControllers])
if([v isKindOfClass:[ModelViewController class]]) [self.navigationController popToViewController:v animated:YES];
}
- (void)indexDidChangeForSegmentedControl:(id)sender
{
//[self.navigationController setViewControllers:[[NSArray alloc] initWithObjects:_prevViewController, nil] animated:NO];
[self.navigationController popViewControllerAnimated:YES];
}
......
......@@ -36,31 +36,20 @@
self.navigationItem.title = @"Model";
if(((AppDelegate *)[UIApplication sharedApplication].delegate)->compute){ // Only on iPhone/iPod
runButton = [[UIBarButtonItem alloc] initWithTitle:@"Stop" style:UIBarButtonItemStyleBordered target:self action:@selector(stopRunning)];
[runButton setTitle:@"Stop"];
}
else {
runButton = [[UIBarButtonItem alloc] initWithTitle:@"Run" style:UIBarButtonItemStyleBordered target:self action:@selector(runWithNewParameter:)];
[runButton setTitle:@"Run"];
}
runButton.possibleTitles = [NSSet setWithObjects:@"Run", @"Stop", nil];
if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"])
self.navigationItem.leftBarButtonItem = runButton;
else
self.navigationItem.rightBarButtonItem = runButton;
_sections = [[NSMutableArray alloc] init];
_sectionstitle = [[NSMutableArray alloc] init];
[self.navigationController setToolbarHidden:NO];
control = [[UISegmentedControl alloc] initWithItems:[[NSArray alloc] initWithObjects:@"Model's Parmeters", @"Views Options", nil]];
control = [[UISegmentedControl alloc] initWithItems:[[NSArray alloc] initWithObjects:@"Model", @"Display", nil]];
control.segmentedControlStyle = UISegmentedControlStyleBar;
UIBarButtonItem *controlBtn = [[UIBarButtonItem alloc] initWithCustomView:control];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
self.toolbarItems = [[NSArray alloc] initWithObjects:flexibleSpace, controlBtn, flexibleSpace, nil];
[control addTarget:self action:@selector(indexDidChangeForSegmentedControl:) forControlEvents:UIControlEventValueChanged];
if(![[UIDevice currentDevice].model isEqualToString:@"iPad"] && ![[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed:)];
}
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Reset" style:UIBarButtonItemStyleBordered target:self action:@selector(resetParameters:)];
}
- (void)viewWillAppear:(BOOL)animated
{
......@@ -69,11 +58,14 @@
[super viewWillAppear:animated];
}
-(void)backButtonPressed:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
- (void)indexDidChangeForSegmentedControl:(id)sender
{
OptionsViewController *optionsViewController = [[OptionsViewController alloc] init];
//[self.navigationController setViewControllers:[[NSArray alloc] initWithObjects:postProViewController, nil] animated:NO];
[optionsViewController.navigationItem setHidesBackButton:YES];
[self.navigationController pushViewController:optionsViewController animated:YES];
}
- (void)addParameterNumber:(onelab::number)p atIndexPath:(NSIndexPath*)indexPath
......@@ -218,6 +210,12 @@
}
- (void)resetParameters:(id)sender
{
if(((AppDelegate *)[UIApplication sharedApplication].delegate)->compute) {
UIAlertView *alert;
alert = [[UIAlertView alloc] initWithTitle:@"Can't reset model's parameters" message:@"The compute have to be finished before you can reset model's parameters." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
return;
}
onelab_cb("reset");
[_sections removeAllObjects];
[_sectionstitle removeAllObjects];
......@@ -227,38 +225,6 @@
[[NSNotificationCenter defaultCenter] postNotificationName:@"requestRender" object:nil];
}
- (void)finishCompute
{
[runButton setTitle:@"Run"];
[runButton setAction:@selector(runWithNewParameter:)];
}
- (void)runWithNewParameter:(UIBarButtonItem *)sender
{
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate->compute = YES;
[sender setTitle:@"Stop"];
[sender setAction:@selector(stopRunning)];
self.navigationItem.rightBarButtonItem.enabled = NO;
onelab_cb("compute");
if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){
[self performSelectorOnMainThread:@selector(finishCompute) withObject:nil waitUntilDone:YES];
self.navigationItem.rightBarButtonItem.enabled = YES;
}
appDelegate->compute = NO;
});
if(![[UIDevice currentDevice].model isEqualToString:@"iPad"] && ![[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"])
[self.navigationController popViewControllerAnimated:YES];
}
- (void)stopRunning
{
onelab_cb("stop");
if(![[UIDevice currentDevice].model isEqualToString:@"iPad"] && ![[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"])
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - Table View
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment