Permalink
Browse files

Modified UIColor properties to be retain.

Changed leaf view implementation to manage colour objects differently.
Other minor updates include the removal of commented out code.
  • Loading branch information...
1 parent 195758b commit 4f80d314d64fc124d289e54860f13ff7b80f59b2 @epreston committed Sep 4, 2011
@@ -35,7 +35,7 @@
#pragma mark - Styling
/// The color of the ContainerView's stroked border.
-@property (nonatomic, copy) UIColor *borderColor;
+@property (nonatomic, retain) UIColor *borderColor;
/// The width of the ContainerView's stroked border. May be zero.
@property (nonatomic, assign) CGFloat borderWidth;
@@ -44,7 +44,7 @@
@property (nonatomic, assign) CGFloat cornerRadius;
/// The fill color for the ContainerView's interior.
-@property (nonatomic, copy) UIColor *fillColor;
+@property (nonatomic, retain) UIColor *fillColor;
#pragma mark - Selection State
@@ -85,7 +85,6 @@ - (void) configureDetaults
self = [super initWithFrame:newFrame];
if (self) {
[self configureDetaults];
- // [self setLayerContentsRedrawPolicy:UIViewLayerContentsRedrawNever];
}
return self;
}
@@ -97,51 +96,15 @@ - (void) awakeFromNib
}
-#pragma mark - Drawing
-
-// Since we set each ContainerView's layerContentsRedrawPolicy to UIViewLayerContentsRedrawNever,
-// this -drawRect: method will only be invoked if the ContainerView is window-backed. If the
-// ContainerView is layer-backed, the layer's appearance properties, as configured in
-// -updateLayerAppearanceToMatchContainerView above, provide this drawing for us.
-
-//- (void)drawRect:(CGRect)rect {
-// float halfBorderWidth = 0.5 * [self borderWidth];
-// CGRect borderRect = CGRectInset([self bounds], halfBorderWidth, halfBorderWidth);
-// CGFloat effectiveRadius = MAX(0.0, [self cornerRadius] - halfBorderWidth);
-//
-// // CALayer's cornerRadius applies to its overall shape, with its border (if any) extending
-// // for borderWidth pixels from there. A srtroked UIBezierPath extends by half the path's
-// // line width to either side of the ideal path. To produce rendered results that closely
-// // match those in layer-backed mode, since ContainerView is optimized to leverage CALayer's
-// // programmatic drawing capabilities when layer-backed, we need to inset the path we're going
-// // to stroke by half the border width.
-//
-// UIBezierPath *borderStrokePath = [UIBezierPath bezierPathWithRoundedRect:borderRect cornerRadius:effectiveRadius];
-//
-// // Fill background.
-// [(showingSelected ? [UIColor yellowColor] : [self fillColor]) set];
-// [borderStrokePath fill];
-//
-// // Stroke border.
-// if (halfBorderWidth > 0.0) {
-// [borderStrokePath setLineWidth:[self borderWidth]];
-// [[self borderColor] set];
-// [borderStrokePath stroke];
-// }
-//}
-
-
#pragma mark - Styling
@synthesize borderColor;
- (void) setBorderColor:(UIColor *)color
{
- if (borderColor != color) {
- [borderColor release];
- borderColor = [[color copy] retain];
- [self updateLayerAppearanceToMatchContainerView];
- }
+ [borderColor release];
+ borderColor = [color retain];
+ [self updateLayerAppearanceToMatchContainerView];
}
@synthesize borderWidth;
@@ -168,11 +131,9 @@ - (void) setCornerRadius:(CGFloat)radius
- (void) setFillColor:(UIColor *)color
{
- if (fillColor != color) {
- [fillColor release];
- fillColor = [[color copy] retain];
- [self updateLayerAppearanceToMatchContainerView];
- }
+ [fillColor release];
+ fillColor = [[color copy] retain];
+ [self updateLayerAppearanceToMatchContainerView];
}
@@ -38,6 +38,7 @@
// State
BOOL expanded; // YES if this subtree is expanded to show its descendants; NO if it's been
// collapsed to show just its root node
+
BOOL needsGraphLayout; // YES if this SubtreeView needs to position its child views and assess its
// size; NO if we're sure its layout is up to date
}
@@ -424,25 +424,6 @@ - (IBAction) toggleExpansion:(id)sender
#pragma mark - Drawing
-//- (void)drawRect:(CGRect)dirtyRect {
-//
-// // Stroke the path with the appropriate color and line width.
-// PSBaseTreeGraphView *treeGraph = [self enclosingTreeView];
-//
-// // Fill background.
-// [[treeGraph backgroundColor] set];
-// UIRectFill(dirtyRect);
-//
-// // DEBUG: Stroke bounds if requested. In practice, SubtreeViews don't normally draw anything.
-// if ( [treeGraph showsSubtreeFrames] ) {
-// CGFloat strokeWidth = subtreeBorderWidth();
-// UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectInset([self bounds], 0.5 * strokeWidth, 0.5 * strokeWidth)];
-// [path setLineWidth:strokeWidth];
-// [subtreeBorderColor() setStroke];
-// [path stroke];
-// }
-//}
-
- (void) updateSubtreeBorder
{
CALayer *layer = [self layer];
@@ -396,23 +396,6 @@ - (void) parentClipViewDidResize:(id)object
}
}
-- (void) willMoveToSuperview:(UIView *)newSuperview
-{
- // Ask to be notified when our superview's frame size changes (if it's an NSClipView, which is a pretty
- // good indication that this TreeGraph is an UIScrollView's documentView), so that we can automatically
- // resize to always fill the UIScrollView's content area.
-
- // UIView *oldSuperview = [self superview];
- // if (oldSuperview) {
- // [[NSNotificationCenter defaultCenter] removeObserver:self name:UIViewFrameDidChangeNotification object:oldSuperview];
- // }
- // if (newSuperview && [newSuperview isKindOfClass:[NSClipView class]]) {
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(parentClipViewDidResize:) name:UIViewFrameDidChangeNotification object:newSuperview];
- // }
-
- [super willMoveToSuperview:newSuperview];
-}
-
- (void) layoutSubviews
{
// Do graph layout if we need to.
@@ -522,20 +505,6 @@ - (void) scrollSelectedModelNodesToVisible
}
-#pragma mark - Drawing
-
-// TreeGraph always completely fills its bounds with its backgroundColor, so as long
-// as the TreeGraph's backgroundColor is opaque, the TreeGraph can be considered opaque.
-// Returning YES from this method is usually an easy, high-reward optimization in
-// window-backed mode, as it enables AppKit to skip drawing content behind the view
-// that the view would just paint over.
-
-
-//- (BOOL)isOpaque {
-// return ( CGColorGetAlpha([[self backgroundColor] CGColor]) < 1.0) ? NO : YES;
-//}
-
-
#pragma mark - Data Source
@synthesize modelRoot;
@@ -697,38 +666,6 @@ - (void) moveRight:(id)sender
//}
-#pragma mark - Mouse Event Handling
-
-// Always receive -mouseDown: messages for clicks that occur in a TreeGraph, even if the click
-// is one that's activating the window. This lets the user start interacting with the TreeGraph's
-// contents without having to click again.
-//
-//- (BOOL)acceptsFirstMouse {
-// return YES;
-//}
-//
-////User clicked the main mouse button inside the TreeGraph.
-//
-//- (void)mouseDown:(NSEvent *)theEvent {
-//
-// // Identify the mdoel node (if any) that the user clicked, and make it the new selection.
-// CGPoint viewPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
-// id<TreeGraphModelNode> hitModelNode = [self modelNodeAtPoint:viewPoint];
-// [self setSelectedModelNodes:(hitModelNode ? [NSSet setWithObject:hitModelNode] : [NSSet set])];
-//
-// // Make the TreeGraph the window's firstResponder when clicked.
-// [[self window] makeFirstResponder:self];
-//}
-//
-//- (void)rightMouseDown:(NSEvent *)theEvent {
-// // For debugging: Dump a compact description of the tree.
-// if (modelRoot) {
-// SubtreeView *rootSubtreeView = [self rootSubtreeView];
-// NSLog(@"Tree=\n%@", [rootSubtreeView treeSummaryWithDepth:0]);
-// }
-//}
-
-
#pragma mark - Gesture Event Handling
//- (void)beginGestureWithEvent:(NSEvent *)event {
@@ -772,26 +709,6 @@ - (void) moveRight:(id)sender
// conventions.
-//- (UIColor *)backgroundColor {
-// return backgroundColor;
-//}
-//
-//- (void)setBackgroundColor:(UIColor *)newBackgroundColor {
-// if (backgroundColor != newBackgroundColor && newBackgroundColor) {
-// [backgroundColor release];
-// //[backgroundColor initWithCGColor:newBackgroundColor.CGColor];
-//
-// backgroundColor = [newBackgroundColor retain];
-//
-// CALayer *layer = [self layer];
-// if (layer) {
-// [layer setBackgroundColor:[backgroundColor CGColor]];
-// } else {
-// [self setNeedsDisplay];
-// }
-// }
-//}
-
@synthesize connectingLineColor;
- (void) setConnectingLineColor:(UIColor *)newConnectingLineColor

0 comments on commit 4f80d31

Please sign in to comment.