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"
|
2009-02-09 16:09:29 +00:00
|
|
|
#import "PlaybackController.h"
|
2009-02-09 05:53:38 +00:00
|
|
|
|
2021-01-07 21:22:01 +00:00
|
|
|
@implementation VolumeButton {
|
2022-02-07 05:49:27 +00:00
|
|
|
NSPopover *popover;
|
|
|
|
NSViewController *viewController;
|
2021-01-07 21:22:01 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)awakeFromNib {
|
|
|
|
popover = [[NSPopover alloc] init];
|
|
|
|
popover.behavior = NSPopoverBehaviorTransient;
|
|
|
|
[popover setContentSize:_popView.bounds.size];
|
2021-01-07 21:22:01 +00:00
|
|
|
}
|
2009-02-09 05:53:38 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)scrollWheel:(NSEvent *)theEvent {
|
|
|
|
if([popover isShown]) {
|
|
|
|
[_popView scrollWheel:theEvent];
|
|
|
|
return;
|
|
|
|
}
|
2021-01-07 21:22:01 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
double change = [theEvent deltaY];
|
2021-01-07 21:22:01 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
[_popView setDoubleValue:[_popView doubleValue] + change];
|
2021-01-07 21:22:01 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
[[_popView target] changeVolume:_popView];
|
2021-01-07 21:22:01 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
[_popView showToolTipForView:self closeAfter:1.0];
|
2009-02-09 05:53:38 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)mouseDown:(NSEvent *)theEvent {
|
|
|
|
[popover close];
|
2021-01-08 06:35:41 +00:00
|
|
|
|
2022-06-22 05:52:05 +00:00
|
|
|
if(!viewController) {
|
|
|
|
viewController = [[NSViewController alloc] init];
|
|
|
|
viewController.view = _popView;
|
|
|
|
popover.contentViewController = viewController;
|
|
|
|
}
|
2021-01-08 06:35:41 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
[popover showRelativeToRect:self.bounds ofView:self preferredEdge:NSRectEdgeMaxY];
|
2009-02-09 05:53:38 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
[super mouseDown:theEvent];
|
2009-02-09 05:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|