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

Draw transparent rounded rect ontop of icon when using windowHints, addressing issue Issue #183 #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Slate/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
NSString *const WINDOW_HINTS_HEIGHT = @"windowHintsHeight";
NSString *const WINDOW_HINTS_HEIGHT_DEFAULT = @"100";
NSString *const WINDOW_HINTS_BACKGROUND_COLOR = @"windowHintsBackgroundColor";
NSString *const WINDOW_HINTS_BACKGROUND_COLOR_DEFAULT = @"50;53;58;0.9";
NSString *const WINDOW_HINTS_BACKGROUND_COLOR_DEFAULT = @"50;53;58;0.6";
NSString *const WINDOW_HINTS_DURATION = @"windowHintsDuration";
NSString *const WINDOW_HINTS_DURATION_DEFAULT = @"3";
NSString *const WINDOW_HINTS_ROUNDED_CORNER_SIZE = @"windowHintsRoundedCornerSize";
Expand Down
12 changes: 6 additions & 6 deletions Slate/HintView.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ - (void)drawRect:(NSRect)dirtyRect {
[[NSGraphicsContext currentContext] saveGraphicsState];
[[NSGraphicsContext currentContext] setShouldAntialias:YES];

// draw the icon behind the rounded rect, if specified
if (icon != nil) {
[icon drawInRect:[self bounds] fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:hintIconAlpha];
}

// draw the rounded rect
[hintBackgroundColor set];
float cornerSize = [[SlateConfig getInstance] getFloatConfig:WINDOW_HINTS_ROUNDED_CORNER_SIZE];
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:[self bounds] xRadius:cornerSize yRadius:cornerSize];
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:CGRectMake(self.bounds.origin.x + (self.bounds.size.width / 4), self.bounds.origin.y + (self.bounds.size.height / 4), self.bounds.size.width / 2, self.bounds.size.height / 2) xRadius:cornerSize yRadius:cornerSize];
[path fill];

// draw the icon on top of the rounded rect, if specified
if (icon != nil) {
[icon drawInRect:[self bounds] fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:hintIconAlpha];
}

// draw hint letter
[self drawCenteredText:text
bounds:self.bounds
Expand Down