Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added setting for window hints shadows. #298

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Slate/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ extern NSString *const WINDOW_HINTS_FONT_SIZE;
extern NSString *const WINDOW_HINTS_FONT_SIZE_DEFAULT;
extern NSString *const WINDOW_HINTS_FONT_COLOR;
extern NSString *const WINDOW_HINTS_FONT_COLOR_DEFAULT;
extern NSString *const WINDOW_HINTS_SHADOW_COLOR;
extern NSString *const WINDOW_HINTS_SHADOW_COLOR_DEFUALT;
extern NSString *const WINDOW_HINTS_SHADOW_BLUR_RADIUS;
extern NSString *const WINDOW_HINTS_SHADOW_BLUR_RADIUS_DEFAULT;
extern NSString *const WINDOW_HINTS_WIDTH;
extern NSString *const WINDOW_HINTS_WIDTH_DEFAULT;
extern NSString *const WINDOW_HINTS_HEIGHT;
Expand Down
4 changes: 4 additions & 0 deletions Slate/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
NSString *const WINDOW_HINTS_FONT_SIZE_DEFAULT = @"40";
NSString *const WINDOW_HINTS_FONT_COLOR = @"windowHintsFontColor";
NSString *const WINDOW_HINTS_FONT_COLOR_DEFAULT = @"255;255;255;1.0";
NSString *const WINDOW_HINTS_SHADOW_COLOR = @"windowHintsShadowColor";
NSString *const WINDOW_HINTS_SHADOW_COLOR_DEFUALT = @"255;255;255;1.0";
NSString *const WINDOW_HINTS_SHADOW_BLUR_RADIUS = @"windowHintsShadowBlurRadius";
NSString *const WINDOW_HINTS_SHADOW_BLUR_RADIUS_DEFAULT = @"0.0";
NSString *const WINDOW_HINTS_WIDTH = @"windowHintsWidth";
NSString *const WINDOW_HINTS_WIDTH_DEFAULT = @"100";
NSString *const WINDOW_HINTS_HEIGHT = @"windowHintsHeight";
Expand Down
28 changes: 26 additions & 2 deletions Slate/HintView.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ @implementation HintView
static NSColor *hintFontColor = nil;
static NSFont *hintFont = nil;
static float hintIconAlpha = -1.0;
static NSShadow *hintShadow = nil;

- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
Expand Down Expand Up @@ -59,6 +60,24 @@ - (id)initWithFrame:(NSRect)frame {
if (hintIconAlpha < 0.0) {
hintIconAlpha = [[SlateConfig getInstance] getFloatConfig:WINDOW_HINTS_ICON_ALPHA];
}
if (hintShadow == nil) {
NSColor *hintShadowColor = nil;
NSArray *fColorArr = [[SlateConfig getInstance] getArrayConfig:WINDOW_HINTS_SHADOW_COLOR];
if ([fColorArr count] < 4) {
fColorArr = [WINDOW_HINTS_SHADOW_COLOR_DEFUALT componentsSeparatedByString:SEMICOLON];
}
hintShadowColor = [NSColor colorWithDeviceRed:[[fColorArr objectAtIndex:0] floatValue]/255.0
green:[[fColorArr objectAtIndex:1] floatValue]/255.0
blue:[[fColorArr objectAtIndex:2] floatValue]/255.0
alpha:[[fColorArr objectAtIndex:3] floatValue]];


CGFloat hintShadowBlurRadius = [[SlateConfig getInstance] getFloatConfig:WINDOW_HINTS_SHADOW_BLUR_RADIUS];

hintShadow = [[NSShadow alloc] init];
[hintShadow setShadowColor:hintShadowColor];
[hintShadow setShadowBlurRadius:hintShadowBlurRadius];
}
}
return self;
}
Expand Down Expand Up @@ -93,14 +112,19 @@ - (void)drawRect:(NSRect)dirtyRect {
if (icon != nil) {
[icon drawInRect:[self bounds] fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:hintIconAlpha];
}

// draw hint letter
[self drawCenteredText:text
bounds:self.bounds
attributes:[NSDictionary dictionaryWithObjectsAndKeys:hintFont,
NSFontAttributeName,
hintFontColor,
NSForegroundColorAttributeName, nil]];
NSForegroundColorAttributeName,
hintShadow,
NSShadowAttributeName,
nil]];


[[NSGraphicsContext currentContext] restoreGraphicsState];
}

Expand Down
2 changes: 2 additions & 0 deletions Slate/SlateConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ - (void)setupDefaultConfigs {
[configDefaults setObject:ORDER_SCREENS_LEFT_TO_RIGHT_DEFAULT forKey:ORDER_SCREENS_LEFT_TO_RIGHT];
[configDefaults setObject:WINDOW_HINTS_BACKGROUND_COLOR_DEFAULT forKey:WINDOW_HINTS_BACKGROUND_COLOR];
[configDefaults setObject:WINDOW_HINTS_FONT_COLOR_DEFAULT forKey:WINDOW_HINTS_FONT_COLOR];
[configDefaults setObject:WINDOW_HINTS_SHADOW_COLOR_DEFUALT forKey:WINDOW_HINTS_SHADOW_COLOR];
[configDefaults setObject:WINDOW_HINTS_SHADOW_BLUR_RADIUS_DEFAULT forKey:WINDOW_HINTS_SHADOW_BLUR_RADIUS];
[configDefaults setObject:WINDOW_HINTS_FONT_NAME_DEFAULT forKey:WINDOW_HINTS_FONT_NAME];
[configDefaults setObject:WINDOW_HINTS_FONT_SIZE_DEFAULT forKey:WINDOW_HINTS_FONT_SIZE];
[configDefaults setObject:WINDOW_HINTS_HEIGHT_DEFAULT forKey:WINDOW_HINTS_HEIGHT];
Expand Down