Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: aabhaskumar/CanvasBoard
base: 067fc3588a
...
head fork: aabhaskumar/CanvasBoard
compare: dcadcc6bcf
  • 2 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
6 CanvasBoard.xcodeproj/project.pbxproj
@@ -22,6 +22,7 @@
3C30C93C14BF193C002B3724 /* CanvasBoardTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C30C93B14BF193C002B3724 /* CanvasBoardTests.m */; };
3C30C94614BF1957002B3724 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C30C94514BF1957002B3724 /* QuartzCore.framework */; };
3C30C95014BF1F5D002B3724 /* ViewElements.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C30C94F14BF1F5D002B3724 /* ViewElements.m */; };
+ 3C30C95C14BF8BE9002B3724 /* CircleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C30C95B14BF8BE9002B3724 /* CircleView.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -57,6 +58,8 @@
3C30C94514BF1957002B3724 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
3C30C94E14BF1F5D002B3724 /* ViewElements.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewElements.h; sourceTree = "<group>"; };
3C30C94F14BF1F5D002B3724 /* ViewElements.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewElements.m; sourceTree = "<group>"; };
+ 3C30C95A14BF8BE9002B3724 /* CircleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CircleView.h; sourceTree = "<group>"; };
+ 3C30C95B14BF8BE9002B3724 /* CircleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CircleView.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -124,6 +127,8 @@
3C30C94F14BF1F5D002B3724 /* ViewElements.m */,
3C30C92214BF193C002B3724 /* ViewController.h */,
3C30C92314BF193C002B3724 /* ViewController.m */,
+ 3C30C95A14BF8BE9002B3724 /* CircleView.h */,
+ 3C30C95B14BF8BE9002B3724 /* CircleView.m */,
3C30C92514BF193C002B3724 /* ViewController.xib */,
3C30C91714BF193C002B3724 /* Supporting Files */,
);
@@ -271,6 +276,7 @@
3C30C92114BF193C002B3724 /* AppDelegate.m in Sources */,
3C30C92414BF193C002B3724 /* ViewController.m in Sources */,
3C30C95014BF1F5D002B3724 /* ViewElements.m in Sources */,
+ 3C30C95C14BF8BE9002B3724 /* CircleView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
BIN  ...ect.xcworkspace/xcuserdata/gauravtoshniwal1989.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown
View
64 ...rd.xcodeproj/xcuserdata/gauravtoshniwal1989.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
@@ -9,12 +9,68 @@
continueAfterRunningActions = "No"
isPathRelative = "1"
filePath = "CanvasBoard/ViewController.m"
- timestampString = "348090833.838438"
+ timestampString = "348102585.52002"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "44"
- endingLineNumber = "44"
- landmarkName = "-touchesBegan:withEvent:"
+ startingLineNumber = "84"
+ endingLineNumber = "84"
+ landmarkName = "-touchesEnded:withEvent:"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "CanvasBoard/CircleView.m"
+ timestampString = "348100297.391835"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "13"
+ endingLineNumber = "13"
+ landmarkName = "circleView"
+ landmarkType = "19">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "Yes"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "CanvasBoard/CircleView.h"
+ timestampString = "348100297.391835"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "15"
+ endingLineNumber = "15"
+ landmarkName = "@interface CircleView"
+ landmarkType = "2">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "Yes"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "CanvasBoard/ViewController.m"
+ timestampString = "348101069.75739"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "29"
+ endingLineNumber = "29"
+ landmarkName = "-viewDidLoad"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "Yes"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "CanvasBoard/ViewController.m"
+ timestampString = "348102585.52002"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "65"
+ endingLineNumber = "65"
+ landmarkName = "-touchesMoved:withEvent:"
landmarkType = "5">
</FileBreakpoint>
</FileBreakpoints>
View
7 ...Board.xcodeproj/xcuserdata/gauravtoshniwal1989.xcuserdatad/xcschemes/CanvasBoard.xcscheme
@@ -65,6 +65,13 @@
ReferencedContainer = "container:CanvasBoard.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
+ <EnvironmentVariables>
+ <EnvironmentVariable
+ key = "NSZombieEnabled"
+ value = "YES"
+ isEnabled = "YES">
+ </EnvironmentVariable>
+ </EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
View
26 CanvasBoard/CircleView.h
@@ -0,0 +1,26 @@
+//
+// CircleView.h
+// CanvasBoard
+//
+// Created by Gaurav Toshniwal on 13/01/12.
+// Copyright (c) 2012 gauravtoshniwal1989@gmail.com. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <QuartzCore/CAAnimation.h>
+#import "ViewController.h"
+#import <math.h>
+
+@class ViewController;
+@interface CircleView : UIView{
+ UIView *circleView;
+ CGPoint origin;
+ CGFloat radius;
+
+}
+
+@property(nonatomic,retain)UIView *circleView;
+
+-(void)loadCircle;
+-(void)updateCircle:(CGPoint) movedTo;
+@end
View
32 CanvasBoard/CircleView.m
@@ -0,0 +1,32 @@
+//
+// CircleView.m
+// CanvasBoard
+//
+// Created by Gaurav Toshniwal on 13/01/12.
+// Copyright (c) 2012 gauravtoshniwal1989@gmail.com. All rights reserved.
+//
+
+#import "CircleView.h"
+
+@implementation CircleView
+
+@synthesize circleView;
+
+
+
+
+
+-(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
+
+}
+
+/*
+// Only override drawRect: if you perform custom drawing.
+// An empty implementation adversely affects performance during animation.
+- (void)drawRect:(CGRect)rect
+{
+ // Drawing code
+}
+*/
+
+@end
View
8 CanvasBoard/ViewController.h
@@ -9,16 +9,22 @@
#import <UIKit/UIKit.h>
#import <QuartzCore/CAAnimation.h>
#import "ViewElements.h"
+#import "CircleView.h"
@interface ViewController : UIViewController{
ViewElements *accessView;
UIView *leftView;
UIView *toolBarHandle;
+ UIView *circleView;
+ UIButton *circleButton;
+ CGPoint origin;
+ BOOL buttonState;
}
-
+-(void)updateCircle:(CGPoint) movedTo;
@property(nonatomic,retain) ViewElements *accessView;
@property(nonatomic,retain) UIView *leftView;
@property(nonatomic,retain) UIView *toolBarHandle;
+@property(nonatomic,retain) UIView *circleView;
@end
View
101 CanvasBoard/ViewController.m
@@ -14,6 +14,7 @@ @implementation ViewController
@synthesize accessView;
@synthesize leftView;
@synthesize toolBarHandle;
+@synthesize circleView;
- (void)didReceiveMemoryWarning
{
@@ -34,42 +35,104 @@ - (void)viewDidLoad
[self.view addSubview:leftView];
toolBarHandle = [accessView initView:CGRectMake(screenBounds.size.width/10, 0, 20, screenBounds.size.height) withBackground:[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.5]];
- UIButton *circleButton = [accessView createButton:CGRectMake(5, 5, screenBounds.size.width/10 - 10, 25) withText:@"Circle"];
+ circleButton = [accessView createButton:CGRectMake(5, 5, screenBounds.size.width/10 - 10, 25) withText:@"Circle"];
+ buttonState=NO;
+ [circleButton addTarget:self action:@selector(circleDraw) forControlEvents:UIControlEventTouchUpInside];
+ //clear screen
+ UIButton *clearButton = [accessView createButton:CGRectMake(5, 50, screenBounds.size.width/10 - 10, 25) withText:@"Clear"];
+ [clearButton addTarget:self action:@selector(clearScreen) forControlEvents:UIControlEventTouchUpInside];
[leftView addSubview:circleButton];
[leftView addSubview:toolBarHandle];
+ [leftView addSubview:clearButton];
}
+-(void)clearScreen{
+ UIView *v=[[UIView alloc] init];
+ for (v in self.view.subviews) {
+ // Include the if-statement if you want to remove UIControls only
+ if ([v isKindOfClass:[UIView class]]) {
+ [v removeFromSuperview];
+ }
+ [self.view addSubview:leftView];
+ }
+}
+-(void)circleDraw{
+ if(buttonState==NO)
+ buttonState=YES;
+ else
+ buttonState=NO;
+ //NSLog(@"buttonstate::%@\n",buttonState);
+}
+
+-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event{
+ UIView *demoCircle=[[UIView alloc]init];
+ circleView=demoCircle;
+ UITouch *touch = [[event allTouches] anyObject];
+ origin = [ touch locationInView:self.view];
+}
+-(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event{
+ [circleView removeFromSuperview];
+
+ UITouch *touch = [[event allTouches] anyObject];
+ CGPoint movedTo=[touch locationInView:self.view];
+ [self updateCircle:movedTo];
+
+
+}
+-(void)updateCircle:(CGPoint) movedTo{
+
+ if(buttonState==YES){
+ float xcor=pow((origin.x-movedTo.x),2);
+ float ycor=pow((origin.y-movedTo.y),2);
+ CGFloat radius=sqrt(xcor+ycor);
+ circleView = [[UIView alloc] initWithFrame:CGRectMake(origin.x-radius, origin.y-radius, 2*radius, 2*radius)];
+ circleView.layer.cornerRadius=radius;
+ circleView.alpha = 0.5;
+ circleView.backgroundColor = [UIColor blueColor];
+ [self.view addSubview:circleView];
--(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event //here enable the touch
+ }
+
+}
+-(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event //here enable the touch
{
// get touch event
UITouch *touch = [[event allTouches] anyObject];
+ CGPoint location = [ touch locationInView: self.view ];
+ NSUInteger taps = [ touch tapCount ];
+ NSLog(@"%s tap at %f, %f tap count: %d", (taps == 1) ? "Single" :
+
+ (taps == 2) ? "Double" : "Triple+", location.x, location.y, taps);
CGPoint touchLocation = [touch locationInView:leftView];
- if (CGRectContainsPoint(toolBarHandle.frame, touchLocation))
- {
- CGRect screenBounds = [ [ UIScreen mainScreen ] applicationFrame ];
- if(leftView.frame.origin.x == 0)
+ if(taps==1){
+ if (CGRectContainsPoint(toolBarHandle.frame, touchLocation))
{
- CGRect toolBarBounds = CGRectMake(-screenBounds.size.width/10, 0, screenBounds.size.width/10+20, screenBounds.size.height);
- [UIView beginAnimations:nil context:NULL]; // animate the following:
- leftView.frame = toolBarBounds; // move to new location
- [UIView setAnimationDuration:5.0];
- [UIView commitAnimations];
- }
- else
- {
- CGRect toolBarBounds = CGRectMake(0, 0, screenBounds.size.width/10+20, screenBounds.size.height);
- [UIView beginAnimations:nil context:NULL]; // animate the following:
- leftView.frame = toolBarBounds; // move to new location
- [UIView setAnimationDuration:5.0];
- [UIView commitAnimations];
+ CGRect screenBounds = [ [ UIScreen mainScreen ] applicationFrame ];
+ if(leftView.frame.origin.x == 0)
+ {
+ CGRect toolBarBounds = CGRectMake(-screenBounds.size.width/10, 0, screenBounds.size.width/10+20, screenBounds.size.height);
+ [UIView beginAnimations:nil context:NULL]; // animate the following:
+ leftView.frame = toolBarBounds; // move to new location
+ [UIView setAnimationDuration:5.0];
+ [UIView commitAnimations];
+ }
+ else
+ {
+ CGRect toolBarBounds = CGRectMake(0, 0, screenBounds.size.width/10+20, screenBounds.size.height);
+ [UIView beginAnimations:nil context:NULL]; // animate the following:
+ leftView.frame = toolBarBounds; // move to new location
+ [UIView setAnimationDuration:5.0];
+ [UIView commitAnimations];
+ }
}
}
+
}
+
- (void)viewDidUnload
{
[super viewDidUnload];
View
1  CanvasBoard/ViewElements.h
@@ -21,5 +21,4 @@
//-----Methods-------
-(UIView *)initView:(CGRect)rect withBackground:(UIColor *)color;
-(UIButton *)createButton:(CGRect)rect withText:(NSString *)text;
-
@end

No commit comments for this range

Something went wrong with that request. Please try again.