Skip to content

Commit

Permalink
Finetune content view height
Browse files Browse the repository at this point in the history
Required especially for vibrancy with titlebar present
  • Loading branch information
BlueM committed Sep 30, 2018
1 parent 83e087f commit f99a35b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PshWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
NSString *cancelButtonkey;
NSString *defaultButtonkey;
NSStringEncoding encoding; // Encoding to return values in

int contentViewExtraHeight;
NSButton *defaultButton;
NSButton *cancelButton;

Expand Down
10 changes: 10 additions & 0 deletions PshWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ - (id)initWithAttributes:(NSDictionary *)theAttributes
[[theAttributes objectForKey:@"transparency"] floatValue] : DEFAULT_ALPHA];

// Add content view
contentViewExtraHeight = 0;
NSView *contentView = [[NSView alloc] initWithFrame:[self frame]];
[self setContentView:contentView];
[contentView release];
Expand Down Expand Up @@ -120,14 +121,21 @@ - (id)initWithAttributes:(NSDictionary *)theAttributes
[effectView setBlendingMode: NSVisualEffectBlendingModeBehindWindow];
[self setContentView:effectView];
[effectView release];
contentViewExtraHeight += 10;
self.styleMask = self.styleMask | NSFullSizeContentViewWindowMask;
}

// With/Without titlebar
if ([theAttributes objectForKey:@"titlebar"] &&
[[theAttributes objectForKey:@"titlebar"] isEqualToString:@"0"]) {
self.titlebarAppearsTransparent = TRUE;
if (!vibrant) {
contentViewExtraHeight -= 10;
}
} else {
if (vibrant) {
contentViewExtraHeight += 10;
}
self.titlebarAppearsTransparent = FALSE;
}
}
Expand Down Expand Up @@ -208,6 +216,8 @@ - (void)setupWindowWithElements:(NSArray *)theElements {
[self finishCancelButton];
[self finishDefaultButton];

[self setContentSize:NSMakeSize([[self contentView] frame].size.width, [[self contentView] frame].size.height + contentViewExtraHeight)];

[elmnts release];
}

Expand Down

0 comments on commit f99a35b

Please sign in to comment.