Mercurial > hg > soniczoomios
changeset 16:fb2ef16dd013
Split alert views. Settled on using portrait mode.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Thu, 17 Jan 2013 18:21:48 +0000 |
parents | e45c3e631d20 |
children | 6d72049a480c |
files | PresetAlertViewController.h PresetAlertViewController.mm QuestionnaireViewController.h QuestionnaireViewController.m QuestionnaireViewController.mm QuestionnaireViewController.xib UsernameAlertViewController.h UsernameAlertViewController.mm eventLogger.h eventLogger.mm grid.mm iViewController.h iViewController.mm presetManager.h presetManager.mm testApp.h testApp.mm |
diffstat | 17 files changed, 598 insertions(+), 432 deletions(-) [+] |
line wrap: on
line diff
--- /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 <Foundation/Foundation.h> + + + +@interface PresetAlertViewController : NSObject <UIAlertViewDelegate> + +- (void)showPresetNamePrompt; + +@end +
--- /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];
--- 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
--- 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
--- /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<N;i++){ + [self.answerArray addObject:[NSNumber numberWithInt:-1]]; + } + NSLog(@"Answer count: %d", [self.answerArray count]); + +} + +@end // end implementation \ No newline at end of file
--- a/QuestionnaireViewController.xib Thu Jan 17 13:01:19 2013 +0000 +++ b/QuestionnaireViewController.xib Thu Jan 17 18:21:48 2013 +0000 @@ -37,10 +37,46 @@ <reference key="NSNextResponder"/> <int key="NSvFlags">292</int> <array class="NSMutableArray" key="NSSubviews"> + <object class="IBUIButton" id="871929113"> + <reference key="NSNextResponder" ref="766721923"/> + <int key="NSvFlags">292</int> + <string key="NSFrame">{{530, 649}, {121, 44}}</string> + <reference key="NSSuperview" ref="766721923"/> + <reference key="NSWindow"/> + <reference key="NSNextKeyView"/> + <string key="NSReuseIdentifierKey">_NS:9</string> + <bool key="IBUIOpaque">NO</bool> + <string key="targetRuntimeIdentifier">IBIPadFramework</string> + <int key="IBUIContentHorizontalAlignment">0</int> + <int key="IBUIContentVerticalAlignment">0</int> + <int key="IBUIButtonType">1</int> + <string key="IBUINormalTitle">Finish</string> + <object class="NSColor" key="IBUIHighlightedTitleColor" id="1041582678"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MQA</bytes> + </object> + <object class="NSColor" key="IBUINormalTitleColor"> + <int key="NSColorSpace">1</int> + <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes> + </object> + <object class="NSColor" key="IBUINormalTitleShadowColor" id="907174598"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC41AA</bytes> + </object> + <object class="IBUIFontDescription" key="IBUIFontDescription" id="113804367"> + <int key="type">2</int> + <double key="pointSize">15</double> + </object> + <object class="NSFont" key="IBUIFont" id="774363385"> + <string key="NSName">Helvetica-Bold</string> + <double key="NSSize">15</double> + <int key="NSfFlags">16</int> + </object> + </object> <object class="IBUILabel" id="783180915"> <reference key="NSNextResponder" ref="766721923"/> <int key="NSvFlags">292</int> - <string key="NSFrame">{{118, 96}, {137, 53}}</string> + <string key="NSFrame">{{118, 96}, {212, 53}}</string> <reference key="NSSuperview" ref="766721923"/> <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="838658605"/> @@ -117,27 +153,14 @@ <int key="IBUIContentVerticalAlignment">0</int> <int key="IBUIButtonType">1</int> <string key="IBUINormalTitle">Next Question</string> - <object class="NSColor" key="IBUIHighlightedTitleColor" id="1041582678"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MQA</bytes> - </object> + <reference key="IBUIHighlightedTitleColor" ref="1041582678"/> <object class="NSColor" key="IBUINormalTitleColor"> <int key="NSColorSpace">1</int> <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes> </object> - <object class="NSColor" key="IBUINormalTitleShadowColor" id="907174598"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MC41AA</bytes> - </object> - <object class="IBUIFontDescription" key="IBUIFontDescription" id="113804367"> - <int key="type">2</int> - <double key="pointSize">15</double> - </object> - <object class="NSFont" key="IBUIFont" id="830486844"> - <string key="NSName">Helvetica-Bold</string> - <double key="NSSize">15</double> - <int key="NSfFlags">16</int> - </object> + <reference key="IBUINormalTitleShadowColor" ref="907174598"/> + <reference key="IBUIFontDescription" ref="113804367"/> + <reference key="IBUIFont" ref="774363385"/> </object> <object class="IBUIButton" id="356964106"> <reference key="NSNextResponder" ref="766721923"/> @@ -160,7 +183,7 @@ </object> <reference key="IBUINormalTitleShadowColor" ref="907174598"/> <reference key="IBUIFontDescription" ref="113804367"/> - <reference key="IBUIFont" ref="830486844"/> + <reference key="IBUIFont" ref="774363385"/> </object> <object class="IBUISegmentedControl" id="744737041"> <reference key="NSNextResponder" ref="766721923"/> @@ -210,28 +233,6 @@ <reference ref="4"/> </array> </object> - <object class="IBUIButton" id="871929113"> - <reference key="NSNextResponder" ref="766721923"/> - <int key="NSvFlags">292</int> - <string key="NSFrame">{{530, 897}, {121, 44}}</string> - <reference key="NSSuperview" ref="766721923"/> - <reference key="NSWindow"/> - <string key="NSReuseIdentifierKey">_NS:9</string> - <bool key="IBUIOpaque">NO</bool> - <string key="targetRuntimeIdentifier">IBIPadFramework</string> - <int key="IBUIContentHorizontalAlignment">0</int> - <int key="IBUIContentVerticalAlignment">0</int> - <int key="IBUIButtonType">1</int> - <string key="IBUINormalTitle">Finish</string> - <reference key="IBUIHighlightedTitleColor" ref="1041582678"/> - <object class="NSColor" key="IBUINormalTitleColor"> - <int key="NSColorSpace">1</int> - <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes> - </object> - <reference key="IBUINormalTitleShadowColor" ref="907174598"/> - <reference key="IBUIFontDescription" ref="113804367"/> - <reference key="IBUIFont" ref="830486844"/> - </object> <object class="IBUILabel" id="547100810"> <reference key="NSNextResponder" ref="766721923"/> <int key="NSvFlags">292</int> @@ -246,10 +247,9 @@ <bool key="IBUIUserInteractionEnabled">NO</bool> <string key="targetRuntimeIdentifier">IBIPadFramework</string> <string key="IBUIText">Strongly disagree</string> - <object class="NSColor" key="IBUITextColor" id="326394288"> + <object class="NSColor" key="IBUITextColor" id="424916273"> <int key="NSColorSpace">1</int> - <bytes key="NSRGB">MCAwIDAAA</bytes> - <string key="IBUIColorCocoaTouchKeyPath">darkTextColor</string> + <bytes key="NSRGB">MCAwLjkwNTk5MDg0MjggMQA</bytes> </object> <nil key="IBUIHighlightedColor"/> <int key="IBUIBaselineAdjustment">0</int> @@ -280,8 +280,8 @@ <int key="IBUIContentMode">7</int> <bool key="IBUIUserInteractionEnabled">NO</bool> <string key="targetRuntimeIdentifier">IBIPadFramework</string> - <string key="IBUIText">Strongly disagree</string> - <reference key="IBUITextColor" ref="326394288"/> + <string key="IBUIText">Disagree</string> + <reference key="IBUITextColor" ref="424916273"/> <nil key="IBUIHighlightedColor"/> <int key="IBUIBaselineAdjustment">0</int> <int key="IBUINumberOfLines">2</int> @@ -304,8 +304,8 @@ <int key="IBUIContentMode">7</int> <bool key="IBUIUserInteractionEnabled">NO</bool> <string key="targetRuntimeIdentifier">IBIPadFramework</string> - <string key="IBUIText">Strongly disagree</string> - <reference key="IBUITextColor" ref="326394288"/> + <string key="IBUIText">Neither</string> + <reference key="IBUITextColor" ref="424916273"/> <nil key="IBUIHighlightedColor"/> <int key="IBUIBaselineAdjustment">0</int> <int key="IBUINumberOfLines">2</int> @@ -328,8 +328,8 @@ <int key="IBUIContentMode">7</int> <bool key="IBUIUserInteractionEnabled">NO</bool> <string key="targetRuntimeIdentifier">IBIPadFramework</string> - <string key="IBUIText">Strongly disagree</string> - <reference key="IBUITextColor" ref="326394288"/> + <string key="IBUIText">Agree</string> + <reference key="IBUITextColor" ref="424916273"/> <nil key="IBUIHighlightedColor"/> <int key="IBUIBaselineAdjustment">0</int> <int key="IBUINumberOfLines">2</int> @@ -352,8 +352,8 @@ <int key="IBUIContentMode">7</int> <bool key="IBUIUserInteractionEnabled">NO</bool> <string key="targetRuntimeIdentifier">IBIPadFramework</string> - <string key="IBUIText">Strongly disagree</string> - <reference key="IBUITextColor" ref="326394288"/> + <string key="IBUIText">Strongly agree</string> + <reference key="IBUITextColor" ref="424916273"/> <nil key="IBUIHighlightedColor"/> <int key="IBUIBaselineAdjustment">0</int> <int key="IBUINumberOfLines">2</int> @@ -364,7 +364,7 @@ <double key="preferredMaxLayoutWidth">106</double> </object> </array> - <string key="NSFrameSize">{1024, 768}</string> + <string key="NSFrameSize">{768, 1024}</string> <reference key="NSSuperview"/> <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="783180915"/> @@ -374,10 +374,6 @@ </object> <bool key="IBUIOpaque">NO</bool> <bool key="IBUIClearsContextBeforeDrawing">NO</bool> - <object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics"> - <int key="IBUIInterfaceOrientation">3</int> - <int key="interfaceOrientation">3</int> - </object> <object class="IBUIScreenMetrics" key="IBUISimulatedDestinationMetrics"> <string key="IBUISimulatedSizeMetricsClass">IBUIScreenMetrics</string> <object class="NSMutableDictionary" key="IBUINormalizedOrientationToSizeMap"> @@ -425,6 +421,30 @@ <int key="connectionID">42</int> </object> <object class="IBConnectionRecord"> + <object class="IBCocoaTouchOutletConnection" key="connection"> + <string key="label">finishButton</string> + <reference key="source" ref="841351856"/> + <reference key="destination" ref="871929113"/> + </object> + <int key="connectionID">51</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchOutletConnection" key="connection"> + <string key="label">nextButton</string> + <reference key="source" ref="841351856"/> + <reference key="destination" ref="960474577"/> + </object> + <int key="connectionID">52</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchOutletConnection" key="connection"> + <string key="label">segControl</string> + <reference key="source" ref="841351856"/> + <reference key="destination" ref="744737041"/> + </object> + <int key="connectionID">53</int> + </object> + <object class="IBConnectionRecord"> <object class="IBCocoaTouchEventConnection" key="connection"> <string key="label">nextQuestionPressed:</string> <reference key="source" ref="960474577"/> @@ -444,6 +464,15 @@ </object> <object class="IBConnectionRecord"> <object class="IBCocoaTouchEventConnection" key="connection"> + <string key="label">answerSelected:</string> + <reference key="source" ref="744737041"/> + <reference key="destination" ref="841351856"/> + <int key="IBEventType">13</int> + </object> + <int key="connectionID">54</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchEventConnection" key="connection"> <string key="label">hide:</string> <reference key="source" ref="871929113"/> <reference key="destination" ref="841351856"/> @@ -480,11 +509,11 @@ <reference ref="960474577"/> <reference ref="356964106"/> <reference ref="744737041"/> - <reference ref="871929113"/> <reference ref="547100810"/> <reference ref="593355119"/> <reference ref="1020792119"/> <reference ref="1027404905"/> + <reference ref="871929113"/> <reference ref="384625478"/> </array> <reference key="parent" ref="0"/> @@ -572,7 +601,7 @@ <nil key="activeLocalization"/> <dictionary class="NSMutableDictionary" key="localizations"/> <nil key="sourceID"/> - <int key="maxID">50</int> + <int key="maxID">54</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <array class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -580,12 +609,17 @@ <string key="className">QuestionnaireViewController</string> <string key="superclassName">UIViewController</string> <dictionary class="NSMutableDictionary" key="actions"> + <string key="answerSelected:">id</string> <string key="hide:">id</string> <string key="nextQuestionPressed:">id</string> <string key="previousQuestionPressed:">id</string> <string key="show:">id</string> </dictionary> <dictionary class="NSMutableDictionary" key="actionInfosByName"> + <object class="IBActionInfo" key="answerSelected:"> + <string key="name">answerSelected:</string> + <string key="candidateClassName">id</string> + </object> <object class="IBActionInfo" key="hide:"> <string key="name">hide:</string> <string key="candidateClassName">id</string> @@ -604,14 +638,29 @@ </object> </dictionary> <dictionary class="NSMutableDictionary" key="outlets"> + <string key="finishButton">UIButton</string> + <string key="nextButton">UIButton</string> <string key="questionText">UILabel</string> + <string key="segControl">UISegmentedControl</string> <string key="titleText">UILabel</string> </dictionary> <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName"> + <object class="IBToOneOutletInfo" key="finishButton"> + <string key="name">finishButton</string> + <string key="candidateClassName">UIButton</string> + </object> + <object class="IBToOneOutletInfo" key="nextButton"> + <string key="name">nextButton</string> + <string key="candidateClassName">UIButton</string> + </object> <object class="IBToOneOutletInfo" key="questionText"> <string key="name">questionText</string> <string key="candidateClassName">UILabel</string> </object> + <object class="IBToOneOutletInfo" key="segControl"> + <string key="name">segControl</string> + <string key="candidateClassName">UISegmentedControl</string> + </object> <object class="IBToOneOutletInfo" key="titleText"> <string key="name">titleText</string> <string key="candidateClassName">UILabel</string>
--- /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 <Foundation/Foundation.h> + +@interface UsernameAlertViewController : NSObject <UIAlertViewDelegate> + +-(void)showUserNamePrompt; +@end +
--- /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];
--- 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<lEvent> theEvents; - QuestionnaireViewController * questionnaireViewController; + // values applicable to all events unsigned int nextUploadQty;
--- 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 }
--- 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;
--- 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 <Foundation/Foundation.h> - -#include "eventLogger.h" -#include "presetManager.h" - -@interface IViewController : NSObject <UIAlertViewDelegate> - -//@property (weak, nonatomic) NSString * aString; - - --(void)showUserNamePrompt; -- (void)showPresetNamePrompt; -//- (void)showQuestionPrompt:(NSString *)question; -@end -
--- 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];
--- 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 <ctime> -#import "iViewController.h" +#import "presetAlertViewController.h"
--- 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<ofColor> 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
--- 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<float> vectorFilter(vector<float> 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);
--- 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]; +*/ }