From 52c79f33aea293eb817a75adacfab00113aa0714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Wed, 21 Dec 2016 20:27:03 +0100 Subject: [PATCH] Handle touch-events betetr, recompile with latest --- ios/Classes/TiPaintModule.m | 29 +---------------------------- ios/Classes/TiPaintPaintView.m | 32 +++++++++++++------------------- ios/Classes/WetPaintView.m | 6 ++---- ios/manifest | 6 +++--- ios/titanium.xcconfig | 2 +- 5 files changed, 20 insertions(+), 55 deletions(-) diff --git a/ios/Classes/TiPaintModule.m b/ios/Classes/TiPaintModule.m index 209651c..958ec00 100644 --- a/ios/Classes/TiPaintModule.m +++ b/ios/Classes/TiPaintModule.m @@ -33,34 +33,7 @@ -(void)startup // you *must* call the superclass [super startup]; - NSLog(@"[INFO] %@ loaded",self); -} - --(void)shutdown:(id)sender -{ - // this method is called when the module is being unloaded - // typically this is during shutdown. make sure you don't do too - // much processing here or the app will be quit forceably - - // you *must* call the superclass - [super shutdown:sender]; -} - -#pragma mark Cleanup - --(void)dealloc -{ - // release any resources that have been retained by the module - [super dealloc]; -} - -#pragma mark Internal Memory Management - --(void)didReceiveMemoryWarning:(NSNotification*)notification -{ - // optionally release any resources that can be dynamically - // reloaded once memory is available - such as caches - [super didReceiveMemoryWarning:notification]; + NSLog(@"[DEBUG] %@ loaded",self); } @end diff --git a/ios/Classes/TiPaintPaintView.m b/ios/Classes/TiPaintPaintView.m index 5b32ae5..3f2125a 100644 --- a/ios/Classes/TiPaintPaintView.m +++ b/ios/Classes/TiPaintPaintView.m @@ -34,6 +34,7 @@ - (void)dealloc [wetPaintView removeFromSuperview]; RELEASE_TO_NIL(wetPaintView); RELEASE_TO_NIL(drawImage); + [super dealloc]; } @@ -41,8 +42,7 @@ - (void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds { [super frameSizeChanged:frame bounds:bounds]; [wetPaintView setFrame:bounds]; - if (drawImage != nil) - { + if (drawImage != nil) { [drawImage setFrame:bounds]; } @@ -56,8 +56,7 @@ - (void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds - (UIImageView*)imageView { - if (drawImage == nil) - { + if (drawImage == nil) { drawImage = [[UIImageView alloc] initWithImage:nil]; drawImage.frame = [self bounds]; [self addSubview:drawImage]; @@ -70,13 +69,7 @@ - (UIImageView*)imageView -(void)readyToSavePaint { - char majorVersion = [[[UIDevice currentDevice] systemVersion] characterAtIndex:0]; - if (majorVersion == '2' || majorVersion == '3') { - UIGraphicsBeginImageContext(drawBox.size); - } - else { - UIGraphicsBeginImageContextWithOptions(drawBox.size, NO, 0.0); - } + UIGraphicsBeginImageContextWithOptions(drawBox.size, NO, 0.0); CGContextRef context = UIGraphicsGetCurrentContext(); [[self imageView].image drawInRect:CGRectMake(0, 0, drawBox.size.width, drawBox.size.height)]; [wetPaintView drawInContext:context andApplyErase:YES]; @@ -113,7 +106,8 @@ - (void)setImage_:(id)value { ENSURE_UI_THREAD(setImage_, value); RELEASE_TO_NIL(drawImage); - UIImage* image = value == nil ? nil : [TiUtils image:value proxy:self.proxy]; + UIImage* image = [TiUtils image:value proxy:self.proxy] ?: nil; + if (image != nil) { drawImage = [[UIImageView alloc] initWithImage:image]; drawImage.frame = [self bounds]; @@ -126,30 +120,30 @@ - (void)setImage_:(id)value - (void)clear:(id)args { - if (drawImage != nil) - { + if (drawImage != nil) { drawImage.image = nil; } } -#pragma mark Event Handlers +#pragma mark Events + -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ - [self.proxy fireEvent:@"touchend"]; + [self processTouchesEnded:touches withEvent:event]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - [self.proxy fireEvent:@"touchstart"]; + [self processTouchesBegan:touches withEvent:event]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - [self.proxy fireEvent:@"touchmove"]; + [self processTouchesMoved:touches withEvent:event]; } - (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - [self.proxy fireEvent:@"touchcancel"]; + [self processTouchesCancelled:touches withEvent:event]; } @end diff --git a/ios/Classes/WetPaintView.m b/ios/Classes/WetPaintView.m index 378fdb9..e87577f 100644 --- a/ios/Classes/WetPaintView.m +++ b/ios/Classes/WetPaintView.m @@ -57,12 +57,10 @@ - (void)drawInContext:(CGContextRef)context andApplyErase:(bool)applyErase { CGContextSetAlpha(context, strokeAlpha); CGContextSetBlendMode(context, kCGBlendModeNormal); CFDictionaryApplyFunction(_touchLines, drawPoints, context); - } - else if (applyErase) { + } else if (applyErase) { CGContextSetBlendMode(context, kCGBlendModeClear); CFDictionaryApplyFunction(_touchLines, drawPoints, context); - } - else { + } else { CGContextSetAlpha(context, 1); // Erasing does not respect alpha, unfortunately. CGContextSetStrokeColorWithColor(context, [[TiUtils colorValue:@"#000"] _color].CGColor); CFDictionaryApplyFunction(_touchLines, drawPoints, context); diff --git a/ios/manifest b/ios/manifest index 1b68e91..066812b 100644 --- a/ios/manifest +++ b/ios/manifest @@ -2,13 +2,13 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 1.4.1 +version: 1.4.2 apiversion: 2 architectures: armv7 i386 x86_64 arm64 description: Provides a paint surface user interface view. author: Jeff Haynie license: Appcelerator Commercial License -copyright: Copyright (c) 2010-2014 by Appcelerator, Inc. +copyright: Copyright (c) 2010-Present by Appcelerator, Inc. # these should not be edited @@ -16,4 +16,4 @@ name: paint moduleid: ti.paint guid: 43f13063-d426-4e9c-8a7a-72dc5e4aec57 platform: iphone -minsdk: 3.4.1.GA +minsdk: 5.0.0 diff --git a/ios/titanium.xcconfig b/ios/titanium.xcconfig index ec7d8b9..e41f6ab 100644 --- a/ios/titanium.xcconfig +++ b/ios/titanium.xcconfig @@ -4,7 +4,7 @@ // OF YOUR TITANIUM SDK YOU'RE BUILDING FOR // // -TITANIUM_SDK_VERSION = 3.5.0.GA +TITANIUM_SDK_VERSION = 6.0.0.GA //