2022-06-09 04:32:52 +00:00
|
|
|
//
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2022-06-09 07:43:23 +00:00
|
|
|
if(![self.window isVisible]) {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2022-06-09 04:32:52 +00:00
|
|
|
// Might have zero opacity.
|
|
|
|
if(self.alphaValue == 0 || self.hiddenOrHasHiddenAncestor) {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Might be clipped by an ancestor.
|
|
|
|
return !NSIsEmptyRect(self.visibleRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|