mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
tooltips are now themable.
This commit is contained in:
@@ -27,15 +27,31 @@
|
||||
{
|
||||
BOOL _mouseDownPressed @accessors(getter=isMouseDownPressed, setter=setMouseDownPressed:);
|
||||
unsigned _gravity @accessors(property=gravity);
|
||||
|
||||
CPColor _backgroundColor;
|
||||
CPColor _strokeColor;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Class methods
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"tooltip";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[[CPColor colorWithHexString:@"E3E3E3"],
|
||||
[CPColor colorWithHexString:@"FFFFCA"],
|
||||
2.0,
|
||||
1.0,
|
||||
[CPColor blackColor]]
|
||||
forKeys:[@"stroke-color",
|
||||
@"background-color",
|
||||
@"border-radius",
|
||||
@"stroke-width",
|
||||
@"color"]];
|
||||
}
|
||||
|
||||
/*! compute the contentView frame from a given window frame
|
||||
@param aFrameRect the window frame
|
||||
*/
|
||||
@@ -67,21 +83,6 @@
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization
|
||||
|
||||
- (id)initWithFrame:(CPRect)aFrame styleMask:(unsigned)aStyleMask
|
||||
{
|
||||
if (self = [super initWithFrame:aFrame styleMask:aStyleMask])
|
||||
{
|
||||
_strokeColor = [CPColor colorWithHexString:@"E3E3E3"];
|
||||
_backgroundColor = [CPColor colorWithHexString:@"FFFFCA"];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark drawing
|
||||
|
||||
@@ -90,11 +91,13 @@
|
||||
[super drawRect:aRect];
|
||||
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
radius = 2,
|
||||
strokeWidth = 1;
|
||||
radius = [self currentValueForThemeAttribute:@"border-radius"],
|
||||
strokeWidth = [self currentValueForThemeAttribute:@"stroke-width"],
|
||||
strokeColor = [self currentValueForThemeAttribute:@"stroke-color"],
|
||||
bgColor = [self currentValueForThemeAttribute:@"background-color"];
|
||||
|
||||
CGContextSetStrokeColor(context, _strokeColor);
|
||||
CGContextSetFillColor(context, _backgroundColor);
|
||||
CGContextSetStrokeColor(context, strokeColor);
|
||||
CGContextSetFillColor(context, bgColor);
|
||||
CGContextSetLineWidth(context, strokeWidth);
|
||||
CGContextBeginPath(context);
|
||||
|
||||
|
||||
@@ -1766,6 +1766,24 @@ var themedButtonValues = nil,
|
||||
return ruleEditor;
|
||||
}
|
||||
|
||||
+ (_CPToolTipWindowView)themedTooltip
|
||||
{
|
||||
var toolTipView = [[_CPToolTipWindowView alloc] initWithFrame:CPRectMakeZero() styleMask:_CPToolTipWindowMask],
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"stroke-color", [CPColor colorWithHexString:@"E3E3E3"]],
|
||||
[@"stroke-width", 1.0],
|
||||
[@"border-radius", 2.0],
|
||||
[@"background-color", [CPColor colorWithHexString:@"FFFFCA"]],
|
||||
[@"color", [CPColor blackColor]]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themeValues forView:toolTipView];
|
||||
|
||||
return toolTipView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation AristoHUDThemeDescriptor : BKThemeDescriptor
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ var _CPToolTipHeight = 24.0,
|
||||
[_content setFrameOrigin:CPPointMake(0.0, 0.0)];
|
||||
[_content setFrameSize:textFrameSize];
|
||||
[_content setTextShadowOffset:CGSizeMake(0.0, 1.0)];
|
||||
[_content setTextColor:[CPColor blackColor]];
|
||||
[_content setTextColor:[[[CPTheme defaultTheme] attributeWithName:@"color" forClass:_CPToolTipWindowView] value]];
|
||||
|
||||
[[self contentView] addSubview:_content];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user