cog/Window/VolumeButton.m

52 lines
1.1 KiB
Matlab
Raw Normal View History

2009-02-09 05:53:38 +00:00
//
// VolumeButton.m
// Cog
//
// Created by Vincent Spader on 2/8/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "VolumeButton.h"
#import "PlaybackController.h"
2009-02-09 05:53:38 +00:00
@implementation VolumeButton {
NSPopover *popover;
NSViewController *viewController;
}
- (void)awakeFromNib {
popover = [[NSPopover alloc] init];
popover.behavior = NSPopoverBehaviorTransient;
[popover setContentSize:_popView.bounds.size];
}
2009-02-09 05:53:38 +00:00
- (void)scrollWheel:(NSEvent *)theEvent {
if([popover isShown]) {
[_popView scrollWheel:theEvent];
return;
}
double change = [theEvent deltaY];
[_popView setDoubleValue:[_popView doubleValue] + change];
[[_popView target] changeVolume:_popView];
[_popView showToolTipForView:self closeAfter:1.0];
2009-02-09 05:53:38 +00:00
}
- (void)mouseDown:(NSEvent *)theEvent {
[popover close];
popover.contentViewController = nil;
viewController = [[NSViewController alloc] init];
viewController.view = _popView;
popover.contentViewController = viewController;
[popover showRelativeToRect:self.bounds ofView:self preferredEdge:NSRectEdgeMaxY];
2009-02-09 05:53:38 +00:00
[super mouseDown:theEvent];
2009-02-09 05:53:38 +00:00
}
@end