# HG changeset patch # User Robert Tubb # Date 1358446908 0 # Node ID fb2ef16dd013c90e65b82b3b86b88a26d4eefca1 # Parent e45c3e631d20ffe3d88754e3810459239bc9bbba Split alert views. Settled on using portrait mode. diff -r e45c3e631d20 -r fb2ef16dd013 PresetAlertViewController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PresetAlertViewController.h Thu Jan 17 18:21:48 2013 +0000 @@ -0,0 +1,18 @@ +// +// iViewController.h +// oscSenderExample +// +// Created by Robert Tubb on 07/01/2013. +// +// + +#import + + + +@interface PresetAlertViewController : NSObject + +- (void)showPresetNamePrompt; + +@end + diff -r e45c3e631d20 -r fb2ef16dd013 PresetAlertViewController.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PresetAlertViewController.mm Thu Jan 17 18:21:48 2013 +0000 @@ -0,0 +1,58 @@ +// +// iViewController.m +// oscSenderExample +// +// Created by Robert Tubb on 07/01/2013. +// +// +#include "presetManager.h" + +#import "PresetAlertViewController.h" + + +extern PresetManager presetManager; +@implementation PresetAlertViewController + +- (void)showPresetNamePrompt{ + UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Save" + message:@"Enter preset name:" + delegate:self + cancelButtonTitle:@"Cancel" + otherButtonTitles:@"Enter",nil]; + alert.alertViewStyle = UIAlertViewStylePlainTextInput; + UITextField * alertTextField = [alert textFieldAtIndex:0]; + alertTextField.keyboardType = UIKeyboardTypeDefault; + alertTextField.placeholder = @"Preset Name"; + [alert show]; + [alert release]; +} + +- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ + + NSLog(@"Preset save "); + if(buttonIndex == 0){ + // cancel + NSLog(@"preset save was cancelled"); + }else{ + // save it + presetManager.addPreset([[[alertView textFieldAtIndex:0] text] cStringUsingEncoding:NSASCIIStringEncoding]); + } +} + + +- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView +{ + UITextField *textField = [alertView textFieldAtIndex:0]; + if ([textField.text length] == 0) + { + return NO; + } + return YES; +} + + +@end + + +// global? again. +PresetAlertViewController *presetAlertViewController = [[PresetAlertViewController alloc] init]; diff -r e45c3e631d20 -r fb2ef16dd013 QuestionnaireViewController.h --- a/QuestionnaireViewController.h Thu Jan 17 13:01:19 2013 +0000 +++ b/QuestionnaireViewController.h Thu Jan 17 18:21:48 2013 +0000 @@ -12,15 +12,21 @@ @property (retain, nonatomic) IBOutlet UILabel *questionText; @property (retain, nonatomic) IBOutlet UILabel *titleText; +@property (retain, nonatomic) IBOutlet UIButton *finishButton; +@property (retain, nonatomic) IBOutlet UIButton *nextButton; +@property (retain, nonatomic) IBOutlet UISegmentedControl *segControl; //---------------------------------------------------------------- -(IBAction)hide:(id)sender; -//---------------------------------------------------------------- -(IBAction)show:(id)sender; -//---------------------------------------------------------------- - (IBAction)nextQuestionPressed:(id)sender; - (IBAction)previousQuestionPressed:(id)sender; - --(void)populateQuestionArray; +- (IBAction)answerSelected:(id)sender; +//---------------------------------------------------------------- +- (void)setAppRef:(id)theOFApp; +- (void)populateQuestionArray; +- (void)populateAnswerArray; +- (void)loadQuestion:(NSInteger)questionIndex; +//---------------------------------------------------------------- @end diff -r e45c3e631d20 -r fb2ef16dd013 QuestionnaireViewController.m --- a/QuestionnaireViewController.m Thu Jan 17 13:01:19 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,158 +0,0 @@ -// -// QuestionnaireViewController.m -// oscSenderExample -// -// Created by Robert Tubb on 16/01/2013. -// -// - -#import "QuestionnaireViewController.h" - -@interface QuestionnaireViewController () - // the "model" is an array of questions -@property (strong, nonatomic) NSArray * questionArray; -@property (strong, nonatomic) NSArray * answerArray; -@property (nonatomic) NSInteger currentQuestionIndex; -/* - - -*/ - -@end - -@implementation QuestionnaireViewController - -//---------------------------------------------------------------- -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - // Custom initialization - - [self populateQuestionArray ]; - - - } - return self; -} -//---------------------------------------------------------------- -- (void)viewDidLoad -{ - [super viewDidLoad]; - // Do any additional setup after loading the view from its nib. - self.currentQuestionIndex = 0; - // load question 1 - [self loadQuestion:self.currentQuestionIndex]; -} -//---------------------------------------------------------------- -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} -//---------------------------------------------------------------- -- (void)dealloc { - - [_questionText release]; - [_titleText release]; - [super dealloc]; -} -//---------------------------------------------------------------- -- (void)viewDidUnload { - [self setAnswerPressed:nil]; - [self setQuestionText:nil]; - [self setTitleText:nil]; - [super viewDidUnload]; -} -//---------------------------------------------------------------- -- (IBAction)answerWasSelected:(id)sender { - // look at property? - -} - -//---------------------------------------------------------------- --(IBAction)hide:(id)sender{ - self.view.hidden = YES; -} -//---------------------------------------------------------------- --(IBAction)show:(id)sender{ - self.view.hidden = NO; -} -//---------------------------------------------------------------- - -- (IBAction)nextQuestionPressed:(id)sender { - // save answer ? no button did that hopefully - - // if last question show thanks - // else go to next - self.currentQuestionIndex++; - if(self.currentQuestionIndex >= [self.questionArray count]){ - [self showThanks]; - }else{ - [self loadQuestion:self.currentQuestionIndex]; - - } -} - -- (IBAction)previousQuestionPressed:(id)sender { - self.currentQuestionIndex--; - if(self.currentQuestionIndex < 0){ - // nothing - self.currentQuestionIndex = 0; - }else{ - [self loadQuestion:self.currentQuestionIndex]; - } -} -//---------------------------------------------------------------- - -- (void)showThanks{ - // hide next question button - // hide selector - self.titleText.text = @"Thank you!"; - - self.questionText.text = @"Thanks for helping science help you. Visit the study website to keep abreast of exciting events."; -} -/* -- (IBAction)previousQuestionPressed:(id)sender { - self.currentQuestionIndex--; - if(self.currentQuestionIndex > [self.questionArray count]){ - [self showThanks]; - } - [self loadQuestion:self.currentQuestionIndex]; -} - */ -//---------------------------------------------------------------- -- (void)loadQuestion:(NSInteger)questionIndex { - // populate text fields with question - NSString *qtitle; - qtitle = [@"Question " stringByAppendingFormat:@"%d",questionIndex+1]; - self.titleText.text = qtitle; - - self.questionText.text = [self.questionArray objectAtIndex:questionIndex]; - - // if question already answered show that -} -//---------------------------------------------------------------- -- (void)populateQuestionArray{ - self.questionArray = [[NSArray alloc] initWithObjects: - @"I am familiar with music software and synthesisers.", - @"The best way to get a feel for the possibilities of the synth was with:", - @"Interesting sounds could be discovered more quickly as a result of using:", - @"A sound could be fine tuned more easily using:", - @"The correspondence between the sliders and the grid was understandable.", - @"The interface that felt more familiar was:", - @"Scrolling a greater distance the zoom grid seemed to correspond to larger difference in the sound.", - @"The ability to see other presets on the grid was useful.", - @"The range of sounds was too limited to be able to judge the eventual usefulness of the interface.", - @"The interface better for generating new ideas was", - @"The interface better for live performance would be:", - @"A specific type of sound could be found more quickly using:", - @"I felt more in control when using:", - @"The Zoomer was an improvement on just using a randomiser.", - @"The combination of Zoomer and Sliders was more useful than either individually.", - @"Overall, I preferred using:", - nil]; -} -//---------------------------------------------------------------- - -@end // end implementation \ No newline at end of file diff -r e45c3e631d20 -r fb2ef16dd013 QuestionnaireViewController.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QuestionnaireViewController.mm Thu Jan 17 18:21:48 2013 +0000 @@ -0,0 +1,195 @@ +// +// QuestionnaireViewController.m +// oscSenderExample +// +// Created by Robert Tubb on 16/01/2013. +// +// + +#import "QuestionnaireViewController.h" + +#include "testApp.h" +@interface QuestionnaireViewController () + // the "model" is an array of questions and a bunch of answers +@property (strong, nonatomic) NSArray * questionArray; +@property (strong, nonatomic) NSMutableArray * answerArray; +@property (nonatomic) NSInteger currentQuestionIndex; +@property (nonatomic) id theOFAppRef; +/* + + +*/ + +@end + +@implementation QuestionnaireViewController + +@synthesize nextButton = _nextButton; +@synthesize segControl = _segControl; + +//---------------------------------------------------------------- +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + + [self populateQuestionArray ]; + [self populateAnswerArray]; + + } + return self; +} +- (void)setAppRef:(id)theOFApp{ + self.theOFAppRef = theOFApp; + +} +//---------------------------------------------------------------- +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. + self.currentQuestionIndex = 0; + // load question 1 + [self loadQuestion:self.currentQuestionIndex]; +} +//---------------------------------------------------------------- +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} +//---------------------------------------------------------------- +- (void)dealloc { + + [_questionText release]; + [_titleText release]; + [_finishButton release]; + [_nextButton release]; + [_segControl release]; + [super dealloc]; +} +//---------------------------------------------------------------- +- (void)viewDidUnload { + [self setQuestionText:nil]; + [self setTitleText:nil]; + [self setFinishButton:nil]; + [self setNextButton:nil]; + [self setSegControl:nil]; + [super viewDidUnload]; +} +//---------------------------------------------------------------- +- (IBAction)answerWasSelected:(id)sender { + // look at property? + +} + +//---------------------------------------------------------------- +-(IBAction)hide:(id)sender{ + // c++ call with NSArray argument?? + ((testApp *)self.theOFAppRef)->questionnaireHidden(self.answerArray); + self.view.hidden = YES; +} +//---------------------------------------------------------------- +-(IBAction)show:(id)sender{ + self.view.hidden = NO; +} +//---------------------------------------------------------------- + +- (IBAction)nextQuestionPressed:(id)sender { + // save answer ? no button did that hopefully + + // if last question show thanks + // else go to next + self.currentQuestionIndex++; + if(self.currentQuestionIndex >= [self.questionArray count]){ + [self showThanks]; + }else{ + [self loadQuestion:self.currentQuestionIndex]; + + } +} +//---------------------------------------------------------------- +- (IBAction)previousQuestionPressed:(id)sender { + self.currentQuestionIndex--; + if(self.currentQuestionIndex < 0){ + // nothing + self.currentQuestionIndex = 0; + }else{ + [self loadQuestion:self.currentQuestionIndex]; + } +} + +- (IBAction)answerSelected:(id)sender { + // nice short lines of code. + + [self.answerArray replaceObjectAtIndex:self.currentQuestionIndex withObject:[NSNumber numberWithInteger:self.segControl.selectedSegmentIndex]]; + + // chek wot we just rote + // DUZZNT WERK + NSLog(@"%@",[self.answerArray objectAtIndex:self.currentQuestionIndex]); + + +} +//---------------------------------------------------------------- + +- (void)showThanks{ + // hide next question button + self.nextButton.hidden = YES; + // hide selector + self.segControl.hidden = YES; + + + self.titleText.text = @"Thank you!"; + + self.questionText.text = @"Thanks for helping science help you. Visit the study website to keep abreast of exciting events."; +} + +//---------------------------------------------------------------- +- (void)loadQuestion:(NSInteger)questionIndex { + // populate text fields with question + NSString *qtitle; + qtitle = [@"Question " stringByAppendingFormat:@"%d",questionIndex+1]; + self.titleText.text = qtitle; + + self.questionText.text = [self.questionArray objectAtIndex:questionIndex]; + + // if question already answered show that + self.segControl.selectedSegmentIndex = (NSInteger)[self.answerArray objectAtIndex:self.currentQuestionIndex]; +} +//---------------------------------------------------------------- +- (void)populateQuestionArray{ + self.questionArray = [[NSArray alloc] initWithObjects: + @"I am familiar with music software and synthesisers.", + @"The best way to get a feel for the possibilities of the synth was with:", + @"Interesting sounds could be discovered more quickly as a result of using:", + @"A sound could be fine tuned more easily using:", + @"The correspondence between the sliders and the grid was understandable.", + @"The interface that felt more familiar was:", + @"Scrolling a greater distance the zoom grid seemed to correspond to larger difference in the sound.", + @"The ability to see other presets on the grid was useful.", + @"The range of sounds was too limited to be able to judge the eventual usefulness of the interface.", + @"The interface better for generating new ideas was", + @"The interface better for live performance would be:", + @"A specific type of sound could be found more quickly using:", + @"I felt more in control when using:", + @"The Zoomer was an improvement on just using a randomiser.", + @"The combination of Zoomer and Sliders was more useful than either individually.", + @"Overall, I preferred using:", + nil]; +} +//---------------------------------------------------------------- +- (void)populateAnswerArray{ + int N = [self.questionArray count]; + + //[self.answerArray initWithCapacity:N]; // necessary? + self.answerArray = [[NSMutableArray alloc] initWithCapacity:N]; + // set the number to what? + for(int i=0;i 292 + + + 292 + {{530, 649}, {121, 44}} + + + + _NS:9 + NO + IBIPadFramework + 0 + 0 + 1 + Finish + + 3 + MQA + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + 2 + 15 + + + Helvetica-Bold + 15 + 16 + + 292 - {{118, 96}, {137, 53}} + {{118, 96}, {212, 53}} @@ -117,27 +153,14 @@ 0 1 Next Question - - 3 - MQA - + 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - - 3 - MC41AA - - - 2 - 15 - - - Helvetica-Bold - 15 - 16 - + + + @@ -160,7 +183,7 @@ - + @@ -210,28 +233,6 @@ - - - 292 - {{530, 897}, {121, 44}} - - - _NS:9 - NO - IBIPadFramework - 0 - 0 - 1 - Finish - - - 1 - MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - - - - - 292 @@ -246,10 +247,9 @@ NO IBIPadFramework Strongly disagree - + 1 - MCAwIDAAA - darkTextColor + MCAwLjkwNTk5MDg0MjggMQA 0 @@ -280,8 +280,8 @@ 7 NO IBIPadFramework - Strongly disagree - + Disagree + 0 2 @@ -304,8 +304,8 @@ 7 NO IBIPadFramework - Strongly disagree - + Neither + 0 2 @@ -328,8 +328,8 @@ 7 NO IBIPadFramework - Strongly disagree - + Agree + 0 2 @@ -352,8 +352,8 @@ 7 NO IBIPadFramework - Strongly disagree - + Strongly agree + 0 2 @@ -364,7 +364,7 @@ 106 - {1024, 768} + {768, 1024} @@ -374,10 +374,6 @@ NO NO - - 3 - 3 - IBUIScreenMetrics @@ -425,6 +421,30 @@ 42 + + finishButton + + + + 51 + + + + nextButton + + + + 52 + + + + segControl + + + + 53 + + nextQuestionPressed: @@ -444,6 +464,15 @@ + answerSelected: + + + 13 + + 54 + + + hide: @@ -480,11 +509,11 @@ - + @@ -572,7 +601,7 @@ - 50 + 54 @@ -580,12 +609,17 @@ QuestionnaireViewController UIViewController + id id id id id + + answerSelected: + id + hide: id @@ -604,14 +638,29 @@ + UIButton + UIButton UILabel + UISegmentedControl UILabel + + finishButton + UIButton + + + nextButton + UIButton + questionText UILabel + + segControl + UISegmentedControl + titleText UILabel diff -r e45c3e631d20 -r fb2ef16dd013 UsernameAlertViewController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UsernameAlertViewController.h Thu Jan 17 18:21:48 2013 +0000 @@ -0,0 +1,15 @@ +// +// iViewController.h +// oscSenderExample +// +// Created by Robert Tubb on 07/01/2013. +// +// + +#import + +@interface UsernameAlertViewController : NSObject + +-(void)showUserNamePrompt; +@end + diff -r e45c3e631d20 -r fb2ef16dd013 UsernameAlertViewController.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UsernameAlertViewController.mm Thu Jan 17 18:21:48 2013 +0000 @@ -0,0 +1,65 @@ +// +// iViewController.m +// oscSenderExample +// +// Created by Robert Tubb on 07/01/2013. +// +// +#include "eventLogger.h" + +#import "usernameAlertViewController.h" + + +extern EventLogger eventLogger; + +@implementation UsernameAlertViewController + +-(void)showUserNamePrompt{ + + + UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Hello!" + message:@"Please enter your name:" + delegate:self + cancelButtonTitle:@"Continue" + otherButtonTitles:nil]; + alert.alertViewStyle = UIAlertViewStylePlainTextInput; + UITextField * alertTextField = [alert textFieldAtIndex:0]; + alertTextField.keyboardType = UIKeyboardTypeDefault; + alertTextField.placeholder = @"Username"; + [alert show]; + [alert release]; + + +} + + +- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ + + NSLog(@"Entered: %@",[[alertView textFieldAtIndex:0] text]); + NSString *userName = [[alertView textFieldAtIndex:0] text]; + if ([userName isEqualToString:@""]){ + [self showUserNamePrompt]; + return; + } + eventLogger.setUsername([userName cStringUsingEncoding:NSASCIIStringEncoding]); + + +} + + +- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView +{ + UITextField *textField = [alertView textFieldAtIndex:0]; + if ([textField.text length] == 0) + { + return NO; + } + return YES; +} + + +@end + + +// global. again. +UsernameAlertViewController *usernameAlertViewController = [[UsernameAlertViewController alloc] init]; diff -r e45c3e631d20 -r fb2ef16dd013 eventLogger.h --- a/eventLogger.h Thu Jan 17 13:01:19 2013 +0000 +++ b/eventLogger.h Thu Jan 17 18:21:48 2013 +0000 @@ -24,8 +24,8 @@ #include "2dvector.h" #include "json.h" -#import "iViewController.h" -#import "QuestionnaireViewController.h" +#import "usernameAlertViewController.h" + // can add but don't change ordering - this will invalidate logs enum leventType {SAVE_PRESET, @@ -130,7 +130,7 @@ vector theEvents; - QuestionnaireViewController * questionnaireViewController; + // values applicable to all events unsigned int nextUploadQty; diff -r e45c3e631d20 -r fb2ef16dd013 eventLogger.mm --- a/eventLogger.mm Thu Jan 17 13:01:19 2013 +0000 +++ b/eventLogger.mm Thu Jan 17 18:21:48 2013 +0000 @@ -11,15 +11,11 @@ EventLogger eventLogger; -extern IViewController *iViewController; +extern UsernameAlertViewController *usernameAlertViewController; //--------------------------------------------------------------------------- EventLogger::EventLogger(){ //QuestionnaireViewController * questionnaireViewController; - - questionnaireViewController = [[QuestionnaireViewController alloc] initWithNibName:@"QuestionnaireViewController" bundle:nil]; - - loggingEnabled = true; @@ -34,7 +30,7 @@ testConnection(); - [ofxiPhoneGetGLParentView() addSubview:questionnaireViewController.view]; + } //--------------------------------------------------------------------------- bool EventLogger::testConnection(){ @@ -114,13 +110,7 @@ cout << "Total interaction time: " << totalInteractionTime << '\n'; if(totalInteractionTime > 0){ - // questionnaireViewController.show; - [questionnaireViewController show:(id)this]; - - //IF THE VIEW IS HIDDEN LETS BRING IT BACK! - if( questionnaireViewController.view.hidden ){ - questionnaireViewController.view.hidden = NO; - } + // testApp.showQuestionnaire(); } // is there logged stuff that hasn't been uploaded yet? @@ -183,7 +173,7 @@ deviceID = ofGetSystemTimeMicros(); totalInteractionTime = 0; - [iViewController showUserNamePrompt]; + [usernameAlertViewController showUserNamePrompt]; // then we get userName via setUsername, called from button delegate } diff -r e45c3e631d20 -r fb2ef16dd013 grid.mm --- a/grid.mm Thu Jan 17 13:01:19 2013 +0000 +++ b/grid.mm Thu Jan 17 18:21:48 2013 +0000 @@ -182,6 +182,7 @@ void Grid::draw(){ // draw lines // TODO too friggin long + pixSize.setCoord(ofGetWidth(), ofGetHeight()); // incase of rotation? //scale++; // nice loopy thing int power = 0; diff -r e45c3e631d20 -r fb2ef16dd013 iViewController.h --- a/iViewController.h Thu Jan 17 13:01:19 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -// -// iViewController.h -// oscSenderExample -// -// Created by Robert Tubb on 07/01/2013. -// -// - -#import - -#include "eventLogger.h" -#include "presetManager.h" - -@interface IViewController : NSObject - -//@property (weak, nonatomic) NSString * aString; - - --(void)showUserNamePrompt; -- (void)showPresetNamePrompt; -//- (void)showQuestionPrompt:(NSString *)question; -@end - diff -r e45c3e631d20 -r fb2ef16dd013 iViewController.mm --- a/iViewController.mm Thu Jan 17 13:01:19 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -// -// iViewController.m -// oscSenderExample -// -// Created by Robert Tubb on 07/01/2013. -// -// - -#import "iViewController.h" - -extern EventLogger eventLogger; -extern PresetManager presetManager; -@implementation IViewController - --(void)showUserNamePrompt{ - - - UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Hello!" - message:@"Please enter your name:" - delegate:self - cancelButtonTitle:@"Continue" - otherButtonTitles:nil]; - alert.alertViewStyle = UIAlertViewStylePlainTextInput; - UITextField * alertTextField = [alert textFieldAtIndex:0]; - alertTextField.keyboardType = UIKeyboardTypeDefault; - alertTextField.placeholder = @"Username"; - [alert show]; - [alert release]; - - -} - - -- (void)showPresetNamePrompt{ - UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Save" - message:@"Enter preset name:" - delegate:self - cancelButtonTitle:@"Cancel" - otherButtonTitles:@"Enter",nil]; - alert.alertViewStyle = UIAlertViewStylePlainTextInput; - UITextField * alertTextField = [alert textFieldAtIndex:0]; - alertTextField.keyboardType = UIKeyboardTypeDefault; - alertTextField.placeholder = @"Preset Name"; - [alert show]; - [alert release]; -} -/* -- (void)showQuestionPrompt:(NSString *)question{ - UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Save" - message:@"Are you mad?" - delegate:self - cancelButtonTitle:@"Next" - otherButtonTitles:@"Hell No",nil]; - alert.alertViewStyle = UIAlertViewStyleDefault; - [alert show]; - [alert release]; -} - */ - -// shheet - only one delegate fnc -// we're actually overriding alertViews function here? - -- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ - NSLog(@"Button: %d",buttonIndex); - - NSLog(@"Dialog title: %@",[alertView title]); // check right title! - if([[alertView title] isEqualToString:@"Hello!"]){ - NSLog(@"Entered: %@",[[alertView textFieldAtIndex:0] text]); - NSString *userName = [[alertView textFieldAtIndex:0] text]; - if ([userName isEqualToString:@""]){ - [self showUserNamePrompt:43]; - return; - } - eventLogger.setUsername([userName cStringUsingEncoding:NSASCIIStringEncoding]); - } else if ([[alertView title] isEqualToString:@"Save"]) { - NSLog(@"Preset save "); - if(buttonIndex == 0){ - // cancel - NSLog(@"preset save was cancelled"); - }else{ - // save it - presetManager.addPreset([[[alertView textFieldAtIndex:0] text] cStringUsingEncoding:NSASCIIStringEncoding]); - } - } else { - NSLog(@"Dialog title didn't match anything"); - } - -} - - -- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView -{ - UITextField *textField = [alertView textFieldAtIndex:0]; - if ([textField.text length] == 0) - { - return NO; - } - return YES; -} - - -@end - - -// global. again. -IViewController *iViewController = [[IViewController alloc] init]; diff -r e45c3e631d20 -r fb2ef16dd013 presetManager.h --- a/presetManager.h Thu Jan 17 13:01:19 2013 +0000 +++ b/presetManager.h Thu Jan 17 18:21:48 2013 +0000 @@ -26,7 +26,7 @@ #include "json.h" #include -#import "iViewController.h" +#import "presetAlertViewController.h" diff -r e45c3e631d20 -r fb2ef16dd013 presetManager.mm --- a/presetManager.mm Thu Jan 17 13:01:19 2013 +0000 +++ b/presetManager.mm Thu Jan 17 18:21:48 2013 +0000 @@ -12,7 +12,7 @@ extern Grid theGridView; PresetManager presetManager; extern EventLogger eventLogger; -extern IViewController *iViewController; +extern PresetAlertViewController *presetAlertViewController; //--------------------------------------------------------------------------- vector Preset::makePresetPicture(TwoVector coord){ // convert midi parameters to a nice piccy @@ -163,7 +163,7 @@ } } void PresetManager::showNameDialog(){ - [iViewController showPresetNamePrompt]; + [presetAlertViewController showPresetNamePrompt]; } //--------------------------------------------------------------------------- // when save button pressed diff -r e45c3e631d20 -r fb2ef16dd013 testApp.h --- a/testApp.h Thu Jan 17 13:01:19 2013 +0000 +++ b/testApp.h Thu Jan 17 18:21:48 2013 +0000 @@ -17,7 +17,8 @@ #include "json.h" -#import "iViewController.h" + +#import "QuestionnaireViewController.h" #define HOST "169.254.1.1" #define PORT 12345 @@ -31,7 +32,7 @@ int prevTouchX; int prevTouchY; double prevDist; - + bool paused; // not many so dont bother with vectors/arrays? TwoVector touch0; TwoVector touch1; @@ -55,33 +56,39 @@ int numActiveTouches; - ofxiPhoneKeyboard * keyboard; + QuestionnaireViewController * questionnaireViewController; // - void setup(); - void update(); - void draw(); - void exit(); - - void touchDown(ofTouchEventArgs &touch); - void touchMoved(ofTouchEventArgs &touch); - void touchUp(ofTouchEventArgs &touch); - void touchDoubleTap(ofTouchEventArgs &touch); - void touchCancelled(ofTouchEventArgs &touch); + void setup(); + void update(); + void draw(); + void exit(); + + float getWidth(); + float getHeight(); + + void touchDown(ofTouchEventArgs &touch); + void touchMoved(ofTouchEventArgs &touch); + void touchUp(ofTouchEventArgs &touch); + void touchDoubleTap(ofTouchEventArgs &touch); + void touchCancelled(ofTouchEventArgs &touch); void handleScroll(); void handleZoom(); vector vectorFilter(vector newVec); - - void lostFocus(); - void gotFocus(); - void gotMemoryWarning(); - void deviceOrientationChanged(int newOrientation); - - ofxOscSender sender; + + void lostFocus(); + void gotFocus(); + void gotMemoryWarning(); + void deviceOrientationChanged(int newOrientation); + + ofxOscSender sender; void sendOSCParams(); + void showQuestionnaire(); + void questionnaireHidden(NSArray * answers); + // stardard GUI - knbs and sliders - hides zoomer bool standardGUIShowing; void standardGUIEvent(ofxUIEventArgs &e); diff -r e45c3e631d20 -r fb2ef16dd013 testApp.mm --- a/testApp.mm Thu Jan 17 13:01:19 2013 +0000 +++ b/testApp.mm Thu Jan 17 18:21:48 2013 +0000 @@ -6,13 +6,14 @@ extern EventLogger eventLogger; extern Frequencer frequencer; -extern IViewController *iViewController; //DeviceID3523537000 //-------------------------------------------------------------- void testApp::setup(){ - - ofBackground( 0, 0, 0 ); + paused = true; + + ofBackground( 0, 0, 0 ); ofEnableAlphaBlending(); + ofEnableSmoothing(); // open an outgoing connection to HOST:PORT sender.setup( HOST, PORT ); @@ -32,11 +33,23 @@ prevTouch0.setCoord(1,2); prevTouch1.setCoord(10,20); prevDist = 10; + slowFactor = 0.98; + + + // the 5 harmonics for the frequencer + freqIndexes.push_back(0); + freqIndexes.push_back(4); + freqIndexes.push_back(6); + freqIndexes.push_back(7); + freqIndexes.push_back(8); + + ofxiPhoneDeviceType device = ofxiPhoneGetDeviceType(); + cout << "Device: " << device << '\n'; + + + ofxiPhoneSetOrientation( OFXIPHONE_ORIENTATION_PORTRAIT ); // do this before setting up all the other objects theGridView.init(); - - slowFactor = 0.98; - setupStandardGui(); standardGUIShowing = false; @@ -49,26 +62,7 @@ for(int i=0; i<10;i++){ sliderVals.push_back(64); } - - // the 5 harmonics for the frequencer - freqIndexes.push_back(0); - freqIndexes.push_back(4); - freqIndexes.push_back(6); - freqIndexes.push_back(7); - freqIndexes.push_back(8); - ofxiPhoneDeviceType device = ofxiPhoneGetDeviceType(); - cout << "Device: " << device << '\n'; - - //ofxiPhoneSetOrientation( OF_ORIENTATION_DEFAULT ); // TODO orientation CRAP - ofxiPhoneSetOrientation( OF_ORIENTATION_90_RIGHT ); - - //NSString * q = @"Why the hell did you do that? Are you mad?"; - //[iViewController showQuestionPrompt:q]; - -//----------------- - // the number if libpd ticks per buffer, - // used to compute the audio buffer len: tpb * blocksize (always 64) int ticksPerBuffer = 8; // 8 * 64 = buffer len of 512 // setup the app core @@ -79,12 +73,27 @@ presetManager.startupLoadAll(); eventLogger.init(); + + paused = false; + } #pragma mark GUI +//-- +float testApp::getWidth(){ + // depends on orientation + return ofGetWidth(); + +} +float testApp::getHeight(){ + // depends on orientation + return ofGetHeight(); + +} //-------------------------------------------------------------- void testApp::setupZoomGui(){ - zoomGUI = new ofxUICanvas(ofGetWidth()-200,0,190,300); + // width = height + zoomGUI = new ofxUICanvas(getWidth()-200,0,190,300); zoomGUI->setTheme(OFX_UI_THEME_HACKER ); zoomGUI->addLabelToggle("SWITCH VIEW", false); @@ -94,6 +103,7 @@ zoomGUI->addLabelButton("ZOOM MIN", false); zoomGUI->addLabelButton("ZOOM MAX", false); + zoomGUI->addLabelButton("QUESTIONS", false); ofAddListener(zoomGUI->newGUIEvent, this, &testApp::zoomGUIEvent); } @@ -102,8 +112,10 @@ if(e.widget->getName() == "SWITCH VIEW") { + // is toggle cout << "change VIEW\n"; - + cout << "of width " << ofGetWidth() <<'\n'; + cout << "of height " << ofGetHeight() <<'\n'; standardGUI->setVisible(!standardGUIShowing); standardGUIShowing = !standardGUIShowing; if(standardGUIShowing){ @@ -115,7 +127,7 @@ }else if(e.widget->getName() == "SAVE PRESET") { - if(((ofxUIButton *)e.widget)->getValue()){ + if(((ofxUIButton *)e.widget)->getValue()==0){ // touchup cout << "SAVE PRESET\n"; presetManager.showNameDialog(); @@ -123,25 +135,56 @@ }else if(e.widget->getName() == "ZOOM MIN") { - if(((ofxUIButton *)e.widget)->getValue()){ + if(((ofxUIButton *)e.widget)->getValue()==0){ // touchup cout << "ZOOM MIN\n"; theGridView.setMinZoom(); eventLogger.logEvent(SET_MIN_ZOOM); } }else if(e.widget->getName() == "ZOOM MAX") { - if(((ofxUIButton *)e.widget)->getValue()){ + if(((ofxUIButton *)e.widget)->getValue()==0){ // touchup cout << "ZOOM MAX\n"; theGridView.setMaxZoom(); eventLogger.logEvent(SET_MAX_ZOOM); } + }else if(e.widget->getName() == "QUESTIONS") + { + if(((ofxUIButton *)e.widget)->getValue()==0){ // touchup + showQuestionnaire(); + } }else{ cout << "GUI error : unknown event recieved\n"; } } //-------------------------------------------------------------- +void testApp::showQuestionnaire(){ + // stop updating / drawing + + paused = true; + + questionnaireViewController = [[QuestionnaireViewController alloc] initWithNibName:@"QuestionnaireViewController" bundle:nil]; + [ofxiPhoneGetGLParentView() addSubview:questionnaireViewController.view]; + + [questionnaireViewController setAppRef:(id)this]; + [questionnaireViewController show:(id)this]; + + //IF THE VIEW IS HIDDEN LETS BRING IT BACK! + //if( questionnaireViewController.view.hidden ){ + // questionnaireViewController.view.hidden = NO; + //} + +} +//-------------------------------------------------------------- +void testApp::questionnaireHidden(NSArray * answers){ + // send answers to server as json + + + // set "we've done questionnaire" to true in event logger + paused = false; +} +//-------------------------------------------------------------- void testApp::setupStandardGui(){ float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; float length = 256-xInit*2; @@ -150,7 +193,7 @@ float dim = 42; // LEFT GUI - standardGUI = new ofxUICanvas(0,0,length+90,ofGetHeight()); + standardGUI = new ofxUICanvas(0,0,length+90,getHeight()); ofxUILabelToggle * butt = standardGUI->addLabelToggle("LOCK SEQUENCE (X)", false); @@ -288,6 +331,8 @@ void testApp::update(){ //we do a heartbeat on iOS as the phone will shut down the network connection to save power //this keeps the network alive as it thinks it is being used. + if(paused) return; + if( ofGetFrameNum() % 120 == 0 ){ ofxOscMessage m; m.setAddress( "/misc/heartbeat" ); @@ -343,15 +388,13 @@ } //-------------------------------------------------------------- void testApp::draw(){ - - if (standardGUIShowing){ + if(paused) return; + if (standardGUIShowing){// ? ofSetColor(57, 57, 57,200); - ofRect(0,0,ofGetWidth(),ofGetHeight()); + ofRect(0,0,getWidth(),getHeight()); } theGridView.draw(); - - //ofSetColor(20, 160, 240, 255); - //ofDrawBitmapString("text entered = "+ keyboard->getText() , 2, 70); + } //-------------------------------------------------------------- @@ -411,7 +454,7 @@ if(touch.x < 256) return; } // check if in other gui area - if(touch.x > ofGetWidth()-200 && touch.y < 300){ + if(touch.x > getWidth()-200 && touch.y < 300){ return; } @@ -550,15 +593,21 @@ //-------------------------------------------------------------- void testApp::deviceOrientationChanged(int newOrientation){ - /* +/* cout << "orientation: " << newOrientation; if(newOrientation == 4){ - ofxiPhoneSetOrientation( OF_ORIENTATION_90_RIGHT ); + ofxiPhoneSetOrientation( OF_ORIENTATION_DEFAULT ); + }else if(newOrientation == 3){ ofxiPhoneSetOrientation( OF_ORIENTATION_90_LEFT ); - } - */ + }else if(newOrientation == 3){ + ofxiPhoneSetOrientation( OF_ORIENTATION_90_LEFT ); + } + + + [ofxiPhoneGetGLView() updateDimensions]; +*/ }