blob: 730ff6301981bbcad2e740796c68662bd337c379 [file] [log] [blame]
Alexandre Lision4e280d62015-09-09 15:56:30 -04001/*
2 * Copyright (C) 2015 Savoir-faire Linux Inc.
3 * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#import "ContextualTableCellView.h"
21
22@interface ContextualTableCellView()
23
24@property NSTrackingArea *trackingArea;
25
26@end
27
28@implementation ContextualTableCellView
29
30
31- (void)updateTrackingAreas {
32 [super updateTrackingAreas];
33 [self ensureTrackingArea];
34 if (![[self trackingAreas] containsObject:_trackingArea]) {
35 [self addTrackingArea:_trackingArea];
36 }
37}
38
39- (void)ensureTrackingArea {
40 if (_trackingArea == nil) {
41 _trackingArea = [[NSTrackingArea alloc] initWithRect:NSZeroRect
42 options:NSTrackingInVisibleRect
43 | NSTrackingActiveAlways
44 | NSTrackingMouseEnteredAndExited owner:self userInfo:nil];
45 }
46}
47
48- (void)prepareForReuse
49{
50 for (NSView* item in self.contextualsControls) {
51 [item setHidden:YES];
52 }
53}
54
55- (void)mouseEntered:(NSEvent *)theEvent
56{
Alexandre Lision21666f32015-09-22 17:04:36 -040057 if (self.activeState)
58 return;
59
Alexandre Lision4e280d62015-09-09 15:56:30 -040060 for (NSView* item in self.contextualsControls) {
61 [item setHidden:NO];
62 }
63}
64
65- (void)mouseExited:(NSEvent *)theEvent
66{
67 for (NSView* item in self.contextualsControls) {
68 [item setHidden:YES];
69 }
70}
71
72@end