[commit] r2297 - iOS etoy changes for touch

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[commit] r2297 - iOS etoy changes for touch

commits-3
 
Author: johnmci
Date: 2010-09-11 15:22:46 -0700 (Sat, 11 Sep 2010)
New Revision: 2297

Modified:
   trunk/platforms/iOS/vm/iPhone/Classes/SqueakNoOGLIPhoneAppDelegate.m
   trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIController.m
   trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIView.h
   trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIView.m
   trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIViewOpenGL.h
   trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIViewOpenGL.m
   trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneApplication+events.m
   trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneApplication+imageReadWrite.m
Log:
iOS etoy changes for touch

SqueakUIView.m
set multipleTouchEnabled in setup not SqueakUIView
record touchesCancelled: action
recordCharEvent needs to auto-translate LF to CR

sqSqueakIPhoneApplication+imageReadWrite.m
#define what sources and image to use..

sqSqueakIPhoneApplication+events.m
Need the touch id in the record


SqueakUIViewOpenGL.m
no glFlush needed

SqueakUIView.h
broken #ifdef

SqueakUIController.m
willRotateToInterfaceOrientation changes

SqueakNoOpenGLIPhoneAppDelegatem
zoomToOrientation
changes to window setup


Modified: trunk/platforms/iOS/vm/iPhone/Classes/SqueakNoOGLIPhoneAppDelegate.m
===================================================================
--- trunk/platforms/iOS/vm/iPhone/Classes/SqueakNoOGLIPhoneAppDelegate.m 2010-09-11 18:59:33 UTC (rev 2296)
+++ trunk/platforms/iOS/vm/iPhone/Classes/SqueakNoOGLIPhoneAppDelegate.m 2010-09-11 22:22:46 UTC (rev 2297)
@@ -92,6 +92,19 @@
  return self.window;
 }
 
+- (void) zoomToOrientation:(UIInterfaceOrientation)o animated:(BOOL)animated {
+    CGRect zoomRect;
+    zoomRect.origin.x = 0;
+    zoomRect.origin.y = 0;
+ if (UIInterfaceOrientationIsPortrait(o)) {
+ zoomRect.size.width  = 1200 * 4 / 3;
+ } else {
+ zoomRect.size.width  = 1200 * 3 / 4;
+ }
+ zoomRect.size.height = zoomRect.size.width * 3 / 4;
+ [self.scrollView zoomToRect: zoomRect animated: animated];
+}
+
 - (void) makeMainWindowOnMainThread
 
 //This is fired via a cross thread message send from logic that checks to see if the window exists in the squeak thread.
@@ -108,26 +121,28 @@
 
  if (useScrollingView) {
  scrollView = [[UIScrollView alloc ] initWithFrame: mainScreenSize];
-
+
  //Now setup the true view size as the width/height * 2.0  so we can have a larger squeak window and zoom in/out.
-
- CGRect fakeScreenSize = mainScreenSize ;
+ CGRect fakeScreenSize ;
  fakeScreenSize.origin.x = 0;
  fakeScreenSize.origin.y = 0;
- fakeScreenSize.size.width *= 2.0;
- fakeScreenSize.size.height *= 2.0;
-#error use SqueakUIViewCALayer
- mainView = [[SqueakUIViewOpenGL alloc] initWithFrame: fakeScreenSize];
+ fakeScreenSize.size.width = 1200;
+ fakeScreenSize.size.height = 900;
+//#error use SqueakUIViewCALayer SqueakUIViewOpenGL
+ mainView = [[SqueakUIViewCALayer alloc] initWithFrame: fakeScreenSize];
+ mainView.backgroundColor = [UIColor blackColor];
+ mainView.multipleTouchEnabled = YES;
+ mainView.autoresizingMask = UIViewAutoresizingNone;
  self.mainView.clearsContextBeforeDrawing = NO;
 
  //Setup the scroll view which wraps the mainView
-
+ self.scrollView.scrollEnabled = useScrollingView;
  self.scrollView.clearsContextBeforeDrawing = NO;
  self.scrollView.canCancelContentTouches = NO;
- self.scrollView.contentSize = [self.mainView bounds].size;
- self.scrollView.minimumZoomScale = 0.5;
+ self.scrollView.minimumZoomScale = 0.35555;
  self.scrollView.maximumZoomScale = 4.0;
  self.scrollView.delegate = self;
+ self.scrollView.backgroundColor = [UIColor blackColor];
  self.viewController = [SqueakUIController new];
  self.viewController.view = self.scrollView;
 
@@ -135,15 +150,16 @@
  // self.scrollView.autoresizesSubviews=YES;
  // self.scrollView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
 
+ [self zoomToOrientation: UIInterfaceOrientationPortrait animated: NO];
  [self.scrollView addSubview: self.mainView];
  [window addSubview: self.scrollView];
 
  } else {
-
- CGRect fakeScreenSize = mainScreenSize ;
-#error use SqueakUIViewCALayer
- mainView = [[SqueakUIViewOpenGL alloc] initWithFrame: fakeScreenSize];
+ CGRect fakeScreenSize = mainScreenSize;
+//#error use SqueakUIViewCALayer SqueakUIViewOpenGL
+ mainView = [[SqueakUIViewCALayer alloc] initWithFrame: fakeScreenSize];
  self.mainView.clearsContextBeforeDrawing = NO;
+ [self.mainView setMultipleTouchEnabled: YES];
  self.viewController = [SqueakUIController new];
  self.viewController.view = self.mainView;
  [window addSubview: self.mainView];

Modified: trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIController.m
===================================================================
--- trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIController.m 2010-09-11 18:59:33 UTC (rev 2296)
+++ trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIController.m 2010-09-11 22:22:46 UTC (rev 2297)
@@ -61,9 +61,19 @@
  [data release];
 }
 
+
+- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
+ [gDelegateApp zoomToOrientation: toInterfaceOrientation animated: YES];
+}
+
 - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
+ UIInterfaceOrientation o = [[UIApplication sharedApplication] statusBarOrientation];
+ if (UIInterfaceOrientationIsPortrait(o))
+ [gDelegateApp.mainView becomeFirstResponder];
+ else
+ [gDelegateApp.mainView resignFirstResponder];
+
  CGRect mainScreenSize = [[UIScreen mainScreen] applicationFrame];
- UIInterfaceOrientation o = [[UIApplication sharedApplication] statusBarOrientation];
  CGRect f;
 
  f.origin.x = 0.0f;
@@ -85,7 +95,8 @@
 // gDelegateApp.mainView.frame = f;
 // [gDelegateApp.scrollView sizeToFit];
 
- [self performSelector: @selector(pushEventToQueue) withObject: nil afterDelay: 1.0];  
+ [self performSelector: @selector(pushEventToQueue) withObject: nil afterDelay: 1.0];
+
 }
 
 @end

Modified: trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIView.h
===================================================================
--- trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIView.h 2010-09-11 18:59:33 UTC (rev 2296)
+++ trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIView.h 2010-09-11 22:22:46 UTC (rev 2297)
@@ -40,7 +40,7 @@
 #import <Foundation/Foundation.h>
 #include <AvailabilityInternal.h>
 
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_3_1
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
 @interface SqueakUIView : UIView  <UIKeyInput> {
 #else
 @interface SqueakUIView : UIView  {

Modified: trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIView.m
===================================================================
--- trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIView.m 2010-09-11 18:59:33 UTC (rev 2296)
+++ trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIView.m 2010-09-11 22:22:46 UTC (rev 2297)
@@ -53,7 +53,6 @@
  self = [super initWithFrame: aFrame];
  self.autoresizingMask = UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
  colorspace = CGColorSpaceCreateDeviceRGB();
- self.multipleTouchEnabled = YES;
  return self;
 }
 
@@ -92,6 +91,8 @@
 }
 
 - (void) touchesCancelled: (NSSet *) touches withEvent: (UIEvent *) event {
+ //Called by Main Thread, beware of calling Squeak routines in Squeak Thread
+ [(sqSqueakIPhoneApplication *) gDelegateApp.squeakApplication recordTouchEvent: touches type: UITouchPhaseCancelled];
 }
 
 - (BOOL)canBecomeFirstResponder {
@@ -155,6 +156,10 @@
    options: 0 range: picker remainingRange: NULL];
  [lookupString release];
 
+ // LF -> CR
+ if (macRomanCharacter == 10)
+ macRomanCharacter = 13;
+
  evt.pressCode = EventKeyDown;
  BOOL isUppercase = [[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember: unicode];
  evt.modifiers = isUppercase ? ShiftKeyBit : 0;

Modified: trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIViewOpenGL.h
===================================================================
--- trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIViewOpenGL.h 2010-09-11 18:59:33 UTC (rev 2296)
+++ trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIViewOpenGL.h 2010-09-11 22:22:46 UTC (rev 2297)
@@ -46,7 +46,7 @@
 extern struct VirtualMachine* interpreterProxy;
 
 // Run-time assertion
-#if 1
+#if 0
 #define rt_assert(expression) assert(expression)
 #else
 #define rt_assert(expression)

Modified: trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIViewOpenGL.m
===================================================================
--- trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIViewOpenGL.m 2010-09-11 18:59:33 UTC (rev 2296)
+++ trunk/platforms/iOS/vm/iPhone/Classes/SqueakUIViewOpenGL.m 2010-09-11 22:22:46 UTC (rev 2297)
@@ -140,7 +140,7 @@
  [self drawRect: clippy];
  syncNeeded = NO;
  clippyIsEmpty = YES;
- glFlush();
+// glFlush();
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);glCheckError();
  [context presentRenderbuffer:GL_RENDERBUFFER_OES];
  }

Modified: trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneApplication+events.m
===================================================================
--- trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneApplication+events.m 2010-09-11 18:59:33 UTC (rev 2296)
+++ trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneApplication+events.m 2010-09-11 22:22:46 UTC (rev 2297)
@@ -113,10 +113,10 @@
 
  sqInt count = [touches count],arrayIndex=0,squeakMSTimeNow = ioMSecs(),action;
  UITouch *touch;
- sqInt  previousLocationInViewY,previousLocationInViewX,locationInViewX,locationInViewY,squeakMSTime, view, window, tapCount, phase,timeStamp,storageArea,containerArray;
+ sqInt  previousLocationInViewY,previousLocationInViewX,locationInViewX,locationInViewY,squeakMSTime, view, window, tapCount, phase,timeStamp,storageArea,containerArray,touchId;
  interpreterProxy->pushRemappableOop(interpreterProxy->instantiateClassindexableSize(interpreterProxy->classArray(), count));
  for (touch in touches) {
- interpreterProxy->pushRemappableOop(interpreterProxy->instantiateClassindexableSize(interpreterProxy->classArray(), 10));
+ interpreterProxy->pushRemappableOop(interpreterProxy->instantiateClassindexableSize(interpreterProxy->classArray(), 11));
  interpreterProxy->pushRemappableOop(interpreterProxy->integerObjectOf(squeakMSTimeNow));
  interpreterProxy->pushRemappableOop(interpreterProxy->floatObjectOf([touch timestamp]));
  interpreterProxy->pushRemappableOop(interpreterProxy->integerObjectOf((signed)[touch phase]));
@@ -127,6 +127,8 @@
  interpreterProxy->pushRemappableOop(interpreterProxy->floatObjectOf([touch locationInView:[gDelegateApp mainView]].y));
  interpreterProxy->pushRemappableOop(interpreterProxy->floatObjectOf([touch previousLocationInView:[gDelegateApp mainView]].x));
  interpreterProxy->pushRemappableOop(interpreterProxy->floatObjectOf([touch previousLocationInView:[gDelegateApp mainView]].y));
+ interpreterProxy->pushRemappableOop(interpreterProxy->positive64BitIntegerFor((sqLong)touch));
+ touchId = interpreterProxy->popRemappableOop();
  previousLocationInViewY = interpreterProxy->popRemappableOop();
  previousLocationInViewX = interpreterProxy->popRemappableOop();
  locationInViewY = interpreterProxy->popRemappableOop();
@@ -149,6 +151,7 @@
  interpreterProxy->storePointerofObjectwithValue(7, storageArea, locationInViewY);
  interpreterProxy->storePointerofObjectwithValue(8, storageArea, previousLocationInViewX);
  interpreterProxy->storePointerofObjectwithValue(9, storageArea, previousLocationInViewY);
+ interpreterProxy->storePointerofObjectwithValue(10, storageArea, touchId);
  interpreterProxy->storePointerofObjectwithValue(arrayIndex++, containerArray, storageArea);
  interpreterProxy->pushRemappableOop(containerArray);
  }

Modified: trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneApplication+imageReadWrite.m
===================================================================
--- trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneApplication+imageReadWrite.m 2010-09-11 18:59:33 UTC (rev 2296)
+++ trunk/platforms/iOS/vm/iPhone/Classes/sqSqueakIPhoneApplication+imageReadWrite.m 2010-09-11 22:22:46 UTC (rev 2297)
@@ -41,15 +41,29 @@
 #import "sqMacV2Memory.h"
 #import "sqSqueakIPhoneInfoPlistInterface.h"
 
+#define QUOTEME_(x) #x
+#define QUOTEME(x) QUOTEME_(x)
+
+#ifndef ISQUEAK_IMAGE
+#error ISQUEAK_IMAGE is undefined (add ISQUEAK_IMAGE="iPhone" to your preprocessor macros)
+#else
+#define QUOTEDIMAGE QUOTEME(ISQUEAK_IMAGE)
+#endif
+
+#ifndef ISQUEAK_SOURCES
+#error ISQUEAK_SOURCES is undefined (add ISQUEAK_SOURCES="PharoV10" to your preprocessor macros)
+#else
+#define QUOTEDSOURCES QUOTEME(ISQUEAK_SOURCES)
+#endif
+
 @implementation sqSqueakIPhoneApplication (imageReadWrite)
 
 - (void) findImageViaBundleOrPreferences {
  NSAutoreleasePool * pool = [NSAutoreleasePool new];
  NSFileManager *dfm = [NSFileManager defaultManager];
  NSString* documentsPath = [dfm currentDirectoryPath];  //This should point to the Documents folder via a previous setup
- NSString* documentsImagePath = [documentsPath stringByAppendingPathComponent: @"iPhone.image"];
-// NSString* documentsSourcesPath = [documentsPath stringByAppendingPathComponent: @"SqueakV39.sources"];
- NSString* documentsSourcesPath = [documentsPath stringByAppendingPathComponent: @"PharoV10.sources"];
+ NSString* documentsImagePath = [documentsPath stringByAppendingPathComponent: [@QUOTEDIMAGE stringByAppendingString: @".image"]];
+ NSString* documentsSourcesPath = [documentsPath stringByAppendingPathComponent: [@QUOTEDSOURCES stringByAppendingString: @".sources"]];
 
  BOOL fileExists = [dfm fileExistsAtPath: documentsImagePath], sourcesFileIsReadable,sourcesFileExists,copyOk,removeOK;
  NSError* error;
@@ -79,8 +93,7 @@
  }
 
  if (!sourcesFileExists) {
-// NSString* bundleSourcesPath = [[NSBundle mainBundle] pathForResource:@"SqueakV39" ofType:@"sources"];
- NSString* bundleSourcesPath = [[NSBundle mainBundle] pathForResource:@"PharoV10" ofType:@"sources"];
+ NSString* bundleSourcesPath = [[NSBundle mainBundle] pathForResource:@QUOTEDSOURCES ofType:@"sources"];
  if (bundleSourcesPath)
  copyOk = [dfm createSymbolicLinkAtPath: documentsSourcesPath withDestinationPath: bundleSourcesPath error: &error];
  }
@@ -90,12 +103,12 @@
  return;
  } else {
 
- NSString* bundleImagePath = [[NSBundle mainBundle] pathForResource:@"iPhone" ofType:@"image"];
+ NSString* bundleImagePath = [[NSBundle mainBundle] pathForResource:@QUOTEDIMAGE ofType:@"image"];
  BOOL writeable = [(sqSqueakIPhoneInfoPlistInterface*)[self infoPlistInterfaceLogic] imageIsWriteable];
 
  if (writeable) {
- NSString* documentsChangesPath = [documentsPath stringByAppendingPathComponent: @"iPhone.changes"];
- NSString* bundleChangesPath = [[NSBundle mainBundle] pathForResource:@"iPhone" ofType:@"changes"];
+ NSString* documentsChangesPath = [documentsPath stringByAppendingPathComponent: [@QUOTEDIMAGE stringByAppendingString: @".changes"]];
+ NSString* bundleChangesPath = [[NSBundle mainBundle] pathForResource:@QUOTEDIMAGE ofType:@"changes"];
 
  copyOk = [dfm copyItemAtPath: bundleImagePath toPath: documentsImagePath error: &error];
  if (!copyOk) {
@@ -111,3 +124,9 @@
  [pool drain];
 }
 @end
+
+#undef QUOTEDIMAGE
+#undef QUOTEDSOURCES
+#undef QUOTEME
+#undef QUOTEME_
+