[maccode commit] r279 - Support for colored tab counts from Zac West

1 view
Skip to first unread message

codesite...@google.com

unread,
Apr 4, 2009, 3:56:20 PM4/4/09
to mac...@googlegroups.com
Author: catfish.man
Date: Sat Apr 4 12:52:16 2009
New Revision: 279

Modified:
trunk/Utilities/PSMTabBarControl/source/PSMAdiumTabStyle.m
trunk/Utilities/PSMTabBarControl/source/PSMAquaTabStyle.m
trunk/Utilities/PSMTabBarControl/source/PSMMetalTabStyle.m
trunk/Utilities/PSMTabBarControl/source/PSMTabBarCell.h
trunk/Utilities/PSMTabBarControl/source/PSMTabBarCell.m
trunk/Utilities/PSMTabBarControl/source/PSMTabBarControl.m
trunk/Utilities/PSMTabBarControl/source/PSMUnifiedTabStyle.m

Log:
Support for colored tab counts from Zac West

Modified: trunk/Utilities/PSMTabBarControl/source/PSMAdiumTabStyle.m
==============================================================================
--- trunk/Utilities/PSMTabBarControl/source/PSMAdiumTabStyle.m (original)
+++ trunk/Utilities/PSMTabBarControl/source/PSMAdiumTabStyle.m Sat Apr 4
12:52:16 2009
@@ -446,7 +446,7 @@

- (void)drawObjectCounterInCell:(PSMTabBarCell *)cell
withRect:(NSRect)myRect
{
- [[NSColor colorWithCalibratedWhite:0.3 alpha:0.6] set];
+ [[cell countColor] ?: [NSColor colorWithCalibratedWhite:0.3 alpha:0.6]
set];
NSBezierPath *path = [NSBezierPath bezierPath];
[path setLineWidth:1.0];

Modified: trunk/Utilities/PSMTabBarControl/source/PSMAquaTabStyle.m
==============================================================================
--- trunk/Utilities/PSMTabBarControl/source/PSMAquaTabStyle.m (original)
+++ trunk/Utilities/PSMTabBarControl/source/PSMAquaTabStyle.m Sat Apr 4
12:52:16 2009
@@ -496,7 +496,7 @@

// object counter
if ([cell count] > 0) {
- [[NSColor colorWithCalibratedWhite:0.3 alpha:0.45] set];
+ [[cell countColor] ?: [NSColor colorWithCalibratedWhite:0.3
alpha:0.45] set];
NSBezierPath *path = [NSBezierPath bezierPath];
NSRect myRect = [self objectCounterRectForTabCell:cell];
[path moveToPoint:NSMakePoint(myRect.origin.x +
kPSMAquaObjectCounterRadius, myRect.origin.y)];

Modified: trunk/Utilities/PSMTabBarControl/source/PSMMetalTabStyle.m
==============================================================================
--- trunk/Utilities/PSMTabBarControl/source/PSMMetalTabStyle.m (original)
+++ trunk/Utilities/PSMTabBarControl/source/PSMMetalTabStyle.m Sat Apr 4
12:52:16 2009
@@ -512,7 +512,7 @@

// object counter
if ([cell count] > 0) {
- [[NSColor colorWithCalibratedWhite:0.3 alpha:0.6] set];
+ [[cell countColor] ?: [NSColor colorWithCalibratedWhite:0.3
alpha:0.6] set];
NSBezierPath *path = [NSBezierPath bezierPath];
NSRect myRect = [self objectCounterRectForTabCell:cell];
if ([cell state] == NSOnState) {

Modified: trunk/Utilities/PSMTabBarControl/source/PSMTabBarCell.h
==============================================================================
--- trunk/Utilities/PSMTabBarControl/source/PSMTabBarCell.h (original)
+++ trunk/Utilities/PSMTabBarControl/source/PSMTabBarCell.h Sat Apr 4
12:52:16 2009
@@ -32,6 +32,7 @@
BOOL _hasIcon;
BOOL _hasLargeImage;
int _count;
+ NSColor *_countColor;
BOOL _isEdited;
}

@@ -72,6 +73,8 @@
- (void)setHasLargeImage:(BOOL)value;
- (int)count;
- (void)setCount:(int)value;
+- (NSColor *)countColor;
+- (void)setCountColor:(NSColor *)value;
- (BOOL)isPlaceholder;
- (void)setIsPlaceholder:(BOOL)value;
- (int)currentStep;

Modified: trunk/Utilities/PSMTabBarControl/source/PSMTabBarCell.m
==============================================================================
--- trunk/Utilities/PSMTabBarControl/source/PSMTabBarCell.m (original)
+++ trunk/Utilities/PSMTabBarControl/source/PSMTabBarCell.m Sat Apr 4
12:52:16 2009
@@ -34,6 +34,7 @@
_hasCloseButton = YES;
_isCloseButtonSuppressed = NO;
_count = 0;
+ _countColor = nil;
_isEdited = NO;
_isPlaceholder = NO;
}
@@ -61,6 +62,7 @@
_hasCloseButton = YES;
_isCloseButtonSuppressed = NO;
_count = 0;
+ _countColor = nil;
_isEdited = NO;

if (value) {
@@ -74,6 +76,8 @@

- (void)dealloc
{
+ [_countColor release];
+
[_indicator removeFromSuperviewWithoutNeedingDisplay];

[_indicator release];
@@ -253,6 +257,17 @@
{
_count = value;
//[_controlView update:[[self controlView] automaticallyAnimates]]; //
binding notice is too fast
+}
+
+- (NSColor *)countColor
+{
+ return _countColor;
+}
+
+- (void)setCountColor:(NSColor *)color
+{
+ [_countColor release];
+ _countColor = [color retain];
}

- (BOOL)isPlaceholder

Modified: trunk/Utilities/PSMTabBarControl/source/PSMTabBarControl.m
==============================================================================
--- trunk/Utilities/PSMTabBarControl/source/PSMTabBarControl.m (original)
+++ trunk/Utilities/PSMTabBarControl/source/PSMTabBarControl.m Sat Apr 4
12:52:16 2009
@@ -632,6 +632,7 @@
[cell unbind:@"hasLargeImage"];
[cell unbind:@"title"];
[cell unbind:@"count"];
+ [cell unbind:@"countColor"];
[cell unbind:@"isEdited"];

if ([item identifier] != nil) {
@@ -651,6 +652,12 @@
[[item identifier] removeObserver:cell forKeyPath:@"objectCount"];
}
}
+
+ if ([item identifier] != nil) {
+ if ([[[cell representedObject] identifier]
respondsToSelector:@selector(countColor)]) {
+ [[item identifier] removeObserver:cell forKeyPath:@"countColor"];
+ }
+ }

if ([item identifier] != nil) {
if ([[[cell representedObject] identifier]
respondsToSelector:@selector(largeImage)]) {
@@ -1951,6 +1958,15 @@
if ([[[cell representedObject] identifier]
respondsToSelector:@selector(objectCount)]) {
[cell bind:@"count" toObject:[item identifier]
withKeyPath:@"objectCount" options:nil];
[[item identifier] addObserver:cell forKeyPath:@"objectCount"
options:nil context:nil];
+ }
+ }
+
+ // bind for the color of a counter
+ [cell setCountColor:nil];
+ if ([item identifier] != nil) {
+ if ([[[cell representedObject] identifier]
respondsToSelector:@selector(countColor)]) {
+ [cell bind:@"countColor" toObject:[item identifier]
withKeyPath:@"countColor" options:nil];
+ [[item identifier] addObserver:cell forKeyPath:@"countColor"
options:nil context:nil];
}
}


Modified: trunk/Utilities/PSMTabBarControl/source/PSMUnifiedTabStyle.m
==============================================================================
--- trunk/Utilities/PSMTabBarControl/source/PSMUnifiedTabStyle.m (original)
+++ trunk/Utilities/PSMTabBarControl/source/PSMUnifiedTabStyle.m Sat Apr 4
12:52:16 2009
@@ -476,7 +476,7 @@

// object counter
if ([cell count] > 0) {
- [[NSColor colorWithCalibratedWhite:0.3 alpha:0.6] set];
+ [[cell countColor] ?: [NSColor colorWithCalibratedWhite:0.3
alpha:0.6] set];
NSBezierPath *path = [NSBezierPath bezierPath];
NSRect myRect = [self objectCounterRectForTabCell:cell];
myRect.origin.y -= 1.0;

Reply all
Reply to author
Forward
0 new messages