12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- //
- // KMBatchTableRowView.m
- // PDF Reader Pro Edition
- //
- // Created by zhipeng jiang on 2020/11/2.
- //
- #import "KMBatchTableRowView.h"
- @interface KMBatchTableRowView ()
- @property (nonatomic, strong) NSView *backgroundView;
- @end
- @implementation KMBatchTableRowView
- - (instancetype)initWithFrame:(NSRect)frameRect {
- if (self = [super initWithFrame:frameRect]) {
- [self addSubview:self.backgroundView];
-
- self.backgroundView.hidden = YES;
- }
- return self;
- }
- - (void)layout {
- [super layout];
-
- self.backgroundView.frame = NSMakeRect(self.selectionInset.left, self.selectionInset.top, NSWidth(self.bounds)-self.selectionInset.left-self.selectionInset.right, NSHeight(self.bounds)-self.selectionInset.top-self.selectionInset.bottom);
- }
- - (void)setSelectionInset:(NSEdgeInsets)selectionInset {
- [super setSelectionInset:selectionInset];
-
- [self setNeedsLayout:YES];
- }
- - (void)setSelected:(BOOL)selected {
- [super setSelected:selected];
-
- if (selected) {
- self.backgroundView.hidden = YES;
- }
- }
- #pragma mark - Mouse Event
- - (void)mouseExited:(NSEvent *)event {
- [super mouseExited:event];
-
- self.backgroundView.hidden = YES;
- for (NSUInteger i = 0; i < self.subviews.count; i++) {
- NSView *v = [self.subviews objectAtIndex:i];
- for (NSUInteger j = 0; j < v.subviews.count; j++) {
- NSView *sub = [v.subviews objectAtIndex:j];
- if ([sub isKindOfClass:[NSButton class]]) {
- sub.hidden = YES;
- }
- }
- }
- }
- - (void)mouseEntered:(NSEvent *)event {
- [super mouseEntered:event];
-
- if (self.isSelected) {
- self.backgroundView.hidden = YES;
- } else {
- self.backgroundView.hidden = NO;
- }
-
- for (NSUInteger i = 0; i < self.subviews.count; i++) {
- NSView *v = [self.subviews objectAtIndex:i];
- for (NSUInteger j = 0; j < v.subviews.count; j++) {
- NSView *sub = [v.subviews objectAtIndex:j];
- if ([sub isKindOfClass:[NSButton class]]) {
- sub.hidden = NO;
- }
- }
- }
- }
- #pragma mark -
- #pragma mark - Getting
- - (NSView *)backgroundView {
- if (!_backgroundView) {
- _backgroundView = [[NSView alloc] init];
- _backgroundView.wantsLayer = YES;
- _backgroundView.layer.backgroundColor = [NSColor clearColor].CGColor;
- }
- return _backgroundView;
- }
- @end
|