Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

We now have a "current paint view" to easily hook up tool palettes wi…

…th the paint view.
  • Loading branch information...
commit 3031c3b0cd22869a45da63c7d2e2bfc8f381a114 1 parent d46fa02
@uliwitness authored
Showing with 32 additions and 0 deletions.
  1. +4 −0 ULIPaintView.h
  2. +28 −0 ULIPaintView.m
View
4 ULIPaintView.h
@@ -56,6 +56,8 @@
IBOutlet id delegate;
}
++(ULIPaintView*) currentPaintView;
+
-(IBAction) takeLineSizeFromObject: (id)sender;
-(IBAction) takeToolFromObject: (id)sender;
@@ -125,6 +127,8 @@
-(void) paintViewLineColorDidChange: (ULIPaintView*)sender;
-(void) paintViewFillColorDidChange: (ULIPaintView*)sender;
+-(void) paintViewWillBecomeCurrent: (ULIPaintView*)sender;
+
@end
View
28 ULIPaintView.m
@@ -31,6 +31,13 @@
@implementation ULIPaintView
+static ULIPaintView * sCurrentPaintView = nil;
+
++(ULIPaintView*) currentPaintView
+{
+ return sCurrentPaintView;
+}
+
-(id) initWithFrame: (NSRect)frame
{
if(( self = [super initWithFrame:frame] ))
@@ -58,6 +65,13 @@ -(id) initWithFrame: (NSRect)frame
-(void) dealloc
{
+ if( sCurrentPaintView == self )
+ {
+ if( [[self delegate] respondsToSelector: @selector(paintViewWillBecomeCurrent:)] )
+ [[self delegate] paintViewWillBecomeCurrent: nil];
+ sCurrentPaintView = nil;
+ }
+
[undoManager release];
[image release];
[tempTrackImage release];
@@ -571,6 +585,13 @@ -(BOOL) becomeFirstResponder
[[NSRunLoop currentRunLoop] addTimer: selectionTimer forMode: NSEventTrackingRunLoopMode];
}
+ if( sCurrentPaintView != self )
+ {
+ if( [[self delegate] respondsToSelector: @selector(paintViewWillBecomeCurrent:)] )
+ [[self delegate] paintViewWillBecomeCurrent: nil];
+ sCurrentPaintView = self;
+ }
+
return YES;
}
@@ -652,6 +673,13 @@ -(void) setCurrentTool: (ULIPaintTool*)t
[[self window] invalidateCursorRectsForView: self];
[self paintToolDidChange: self];
}
+
+ if( sCurrentPaintView != self )
+ {
+ if( [[self delegate] respondsToSelector: @selector(paintViewWillBecomeCurrent:)] )
+ [[self delegate] paintViewWillBecomeCurrent: nil];
+ sCurrentPaintView = self;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.