adium 3162:73e511909bbe: Per corbin's suggestion, moving alterna...
commits at adium.im
commits at adium.im
Wed Mar 24 19:15:23 UTC 2010
details: http://hg.adium.im/adium/rev/73e511909bbe
revision: 3162:73e511909bbe
author: Stephen Holt <sholt at adium.im>
date: Wed Mar 24 15:06:41 2010 -0400
Per corbin's suggestion, moving alternating row color code to -drawBackgroundInClipRect. Fixes #13856
Adding a AIAlternatingRowsProtocol protocol to make introspection a bit easier, and keep the compiler quiet.
Subject: adium 3163:0572e73911b5: Redraw the contact list less, if we can.
details: http://hg.adium.im/adium/rev/0572e73911b5
revision: 3163:0572e73911b5
author: Stephen Holt <sholt at adium.im>
date: Wed Mar 24 15:15:16 2010 -0400
Redraw the contact list less, if we can.
diffs (124 lines):
diff -r 782f2894fdf5 -r 0572e73911b5 Frameworks/AIUtilities Framework/Source/AIAlternatingRowOutlineView.h
--- a/Frameworks/AIUtilities Framework/Source/AIAlternatingRowOutlineView.h Mon Mar 22 11:49:18 2010 -0400
+++ b/Frameworks/AIUtilities Framework/Source/AIAlternatingRowOutlineView.h Wed Mar 24 15:15:16 2010 -0400
@@ -21,7 +21,7 @@
*
* This functionality was added, with less control to the programmer, in OS X 10.3. <tt>AIAlternatingRowOutlineView</tt> also supports disabling it from drawing its background (useful if cells wish to draw their own backgrounds and potentially be transparent).
*/
- at interface AIAlternatingRowOutlineView : AIOutlineView {
+ at interface AIAlternatingRowOutlineView : AIOutlineView <AIAlternatingRowsProtocol> {
NSColor *alternatingRowColor;
BOOL drawsBackground;
diff -r 782f2894fdf5 -r 0572e73911b5 Frameworks/AIUtilities Framework/Source/AIAlternatingRowOutlineView.m
--- a/Frameworks/AIUtilities Framework/Source/AIAlternatingRowOutlineView.m Mon Mar 22 11:49:18 2010 -0400
+++ b/Frameworks/AIUtilities Framework/Source/AIAlternatingRowOutlineView.m Wed Mar 24 15:15:16 2010 -0400
@@ -29,7 +29,6 @@
@interface AIAlternatingRowOutlineView ()
- (void)initAlternatingRowOutlineView;
- (void)_drawGridInClipRect:(NSRect)rect;
-- (void)alternatingRowOutlineViewSelectionDidChange:(NSNotification *)notification;
@end
@interface NSOutlineView (Undocumented)
@@ -60,17 +59,11 @@
drawsBackground = YES;
drawsGradientSelection = NO;
alternatingRowColor = [[NSColor colorWithCalibratedRed:(237.0f/255.0f) green:(243.0f/255.0f) blue:(254.0f/255.0f) alpha:1.0f] retain];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(alternatingRowOutlineViewSelectionDidChange:)
- name:NSOutlineViewSelectionDidChangeNotification
- object:self];
}
- (void)dealloc
{
[alternatingRowColor release];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
@@ -164,11 +157,10 @@
- (void)highlightSelectionInClipRect:(NSRect)clipRect
{
- [self drawAlternatingRowsInRect:clipRect];
-
- if (drawsGradientSelection && [[self window] isKeyWindow] && ([[self window] firstResponder] == self)) {
- NSIndexSet *indices = [self selectedRowIndexes];
- NSUInteger bufSize = [indices count];
+ NSIndexSet *indices = [self selectedRowIndexes];
+ NSUInteger bufSize = [indices count];
+
+ if (drawsGradientSelection && bufSize > 0 && [[self window] isKeyWindow] && ([[self window] firstResponder] == self)) {
NSUInteger *buf = malloc(bufSize * sizeof(NSUInteger));
NSUInteger i = 0, j = 0;
@@ -230,14 +222,6 @@
}
}
-- (void)alternatingRowOutlineViewSelectionDidChange:(NSNotification *)notification
-{
- if (drawsGradientSelection) {
- //We do fancy drawing, so we need a full redisplay when selection changes
- [self setNeedsDisplay:YES];
- }
-}
-
#pragma mark Grid
- (void)drawGridInClipRect:(NSRect)rect
diff -r 782f2894fdf5 -r 0572e73911b5 Frameworks/AIUtilities Framework/Source/AIOutlineView.h
--- a/Frameworks/AIUtilities Framework/Source/AIOutlineView.h Mon Mar 22 11:49:18 2010 -0400
+++ b/Frameworks/AIUtilities Framework/Source/AIOutlineView.h Wed Mar 24 15:15:16 2010 -0400
@@ -95,6 +95,23 @@
@end
/*!
+ * @protocol AIAlternatingRowsProtocol
+ * @brief Delegate protocol for <tt>AIOutlineView</tt>
+ *
+ * Implementation of all methods is optional.
+ */
+ at protocol AIAlternatingRowsProtocol
+
+/*!
+ * @brief Draws rows of the view with alternating colors
+ *
+ * @param rect The <tt>NSRect</tt> defining the background to color.
+ */
+- (void)drawAlternatingRowsInRect:(NSRect)rect;
+ at end
+
+
+/*!
* @class AIOutlineView
* @brief An NSOutlineView subclass with several improvments
*
diff -r 782f2894fdf5 -r 0572e73911b5 Frameworks/AIUtilities Framework/Source/AIVariableHeightOutlineView.m
--- a/Frameworks/AIUtilities Framework/Source/AIVariableHeightOutlineView.m Mon Mar 22 11:49:18 2010 -0400
+++ b/Frameworks/AIUtilities Framework/Source/AIVariableHeightOutlineView.m Wed Mar 24 15:15:16 2010 -0400
@@ -444,8 +444,6 @@
free(selectionRects);
}
- } else {
- [self drawAlternatingRowsInRect:clipRect];
}
}
diff -r 782f2894fdf5 -r 0572e73911b5 Frameworks/Adium Framework/Source/AIListOutlineView+Drawing.m
--- a/Frameworks/Adium Framework/Source/AIListOutlineView+Drawing.m Mon Mar 22 11:49:18 2010 -0400
+++ b/Frameworks/Adium Framework/Source/AIListOutlineView+Drawing.m Wed Mar 24 15:15:16 2010 -0400
@@ -37,6 +37,9 @@
[[self backgroundColor] set];
NSRectFill(clipRect);
+ if([self conformsToProtocol:@protocol(AIAlternatingRowsProtocol)])
+ [(id<AIAlternatingRowsProtocol>)self drawAlternatingRowsInRect:clipRect];
+
//Image
NSScrollView *enclosingScrollView = [self enclosingScrollView];
if (backgroundImage && enclosingScrollView) {
More information about the commits
mailing list