Declare mouse inside variable in interface
This commit is contained in:
parent
1493d6763c
commit
37ba1b0a6b
1 changed files with 12 additions and 9 deletions
|
@ -46,19 +46,22 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// This view encapsuate Quit, Minimize and Full Screen buttons. It is being
|
// This view encapsuates the Quit, Minimize and Full Screen buttons. It is being
|
||||||
// used for frameless window.
|
// used for frameless windows.
|
||||||
@interface SemaphoreView : NSView
|
@interface SemaphoreView : NSView {
|
||||||
|
@private
|
||||||
|
BOOL mouse_inside_;
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SemaphoreView
|
@implementation SemaphoreView
|
||||||
|
|
||||||
BOOL mouseInside = NO;
|
|
||||||
|
|
||||||
- (id)initWithFrame:(NSRect)frame {
|
- (id)initWithFrame:(NSRect)frame {
|
||||||
self = [super initWithFrame:frame];
|
self = [super initWithFrame:frame];
|
||||||
|
|
||||||
if (self) {
|
if (self) {
|
||||||
|
mouse_inside_ = NO;
|
||||||
|
|
||||||
// create buttons
|
// create buttons
|
||||||
NSButton* closeButton = [NSWindow standardWindowButton:NSWindowCloseButton
|
NSButton* closeButton = [NSWindow standardWindowButton:NSWindowCloseButton
|
||||||
forStyleMask:NSTitledWindowMask];
|
forStyleMask:NSTitledWindowMask];
|
||||||
|
@ -112,7 +115,7 @@ BOOL mouseInside = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)_mouseInGroup:(NSButton*)button {
|
- (BOOL)_mouseInGroup:(NSButton*)button {
|
||||||
return mouseInside;
|
return mouse_inside_;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateTrackingAreas {
|
- (void)updateTrackingAreas {
|
||||||
|
@ -126,19 +129,19 @@ BOOL mouseInside = NO;
|
||||||
|
|
||||||
- (void)mouseEntered:(NSEvent*)event {
|
- (void)mouseEntered:(NSEvent*)event {
|
||||||
[super mouseEntered:event];
|
[super mouseEntered:event];
|
||||||
mouseInside = YES;
|
mouse_inside_ = YES;
|
||||||
[self setNeedsDisplayForButtons];
|
[self setNeedsDisplayForButtons];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseExited:(NSEvent*)event {
|
- (void)mouseExited:(NSEvent*)event {
|
||||||
[super mouseExited:event];
|
[super mouseExited:event];
|
||||||
mouseInside = NO;
|
mouse_inside_ = NO;
|
||||||
[self setNeedsDisplayForButtons];
|
[self setNeedsDisplayForButtons];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setNeedsDisplayForButtons {
|
- (void)setNeedsDisplayForButtons {
|
||||||
for (NSView* subview in self.subviews) {
|
for (NSView* subview in self.subviews) {
|
||||||
[subview setHidden:!mouseInside];
|
[subview setHidden:!mouse_inside_];
|
||||||
[subview setNeedsDisplay:YES];
|
[subview setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue