Cog/Utils/NSView+Visibility.m
Christopher Snowhill fef8821cf6 [Visualizer] Add extra condition to visible check
Add an extra condition to the visibility check, which is similar to the
previous version of this check, which now guards against the window it
is hosted in not being visible.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-06-09 00:43:23 -07:00

30 lines
470 B
Objective-C

//
// NSView+Visibility.m
// Cog
//
// Created by Christopher Snowhill on 6/8/22.
//
#import "NSView+Visibility.h"
@implementation NSView (Visibility)
- (BOOL)visibleInWindow {
if(self.window == nil) {
return NO;
}
if(![self.window isVisible]) {
return NO;
}
// Might have zero opacity.
if(self.alphaValue == 0 || self.hiddenOrHasHiddenAncestor) {
return NO;
}
// Might be clipped by an ancestor.
return !NSIsEmptyRect(self.visibleRect);
}
@end