Remove dead code after NSPopover migration.

CQTexperiment
Dzmitry Neviadomski 2021-01-10 03:29:03 +03:00
parent 0df2dc2160
commit 8fa30d109d
10 changed files with 0 additions and 1069 deletions

View File

@ -21,7 +21,6 @@
172A123C0F5912AE0078EF0C /* ShuffleTransformers.m in Sources */ = {isa = PBXBuildFile; fileRef = 172A123B0F5912AE0078EF0C /* ShuffleTransformers.m */; };
172A12A90F59AF8A0078EF0C /* NSString+CogSort.m in Sources */ = {isa = PBXBuildFile; fileRef = 172A12A80F59AF8A0078EF0C /* NSString+CogSort.m */; };
173855FF0E0CC81F00488CD4 /* FileTreeOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 173855FE0E0CC81F00488CD4 /* FileTreeOutlineView.m */; };
173A43A10F3FD26500676A7B /* ToolTipWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 173A43A00F3FD26500676A7B /* ToolTipWindow.m */; };
1745CBA50F661DBB00E513F7 /* shuffle_albums.png in Resources */ = {isa = PBXBuildFile; fileRef = 1745CBA40F661DBB00E513F7 /* shuffle_albums.png */; };
1752C36C0F59E00100F85F28 /* PlaybackButtons.m in Sources */ = {isa = PBXBuildFile; fileRef = 1752C36B0F59E00100F85F28 /* PlaybackButtons.m */; };
1755E1F90BA0D2B600CA3560 /* PlaylistLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1755E1F70BA0D2B600CA3560 /* PlaylistLoader.m */; };
@ -55,9 +54,6 @@
17818A9B0C0B27AC001C4916 /* wv.icns in Resources */ = {isa = PBXBuildFile; fileRef = 17818A940C0B27AC001C4916 /* wv.icns */; };
1784560F0F631E24007E8021 /* FileTreeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1784560E0F631E24007E8021 /* FileTreeViewController.m */; };
178456120F631E31007E8021 /* SideViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 178456110F631E31007E8021 /* SideViewController.m */; };
178BAB990CD4E1B700B33D47 /* GCOneShotEffectTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 178BAB940CD4E1B700B33D47 /* GCOneShotEffectTimer.m */; };
178BAB9A0CD4E1B700B33D47 /* GCWindowMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 178BAB960CD4E1B700B33D47 /* GCWindowMenu.m */; };
178BAB9B0CD4E1B700B33D47 /* PopupButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 178BAB980CD4E1B700B33D47 /* PopupButton.m */; };
1791005E0CB44D6D0070BC5C /* Cog.scriptSuite in Resources */ = {isa = PBXBuildFile; fileRef = 1791005C0CB44D6D0070BC5C /* Cog.scriptSuite */; };
1791005F0CB44D6D0070BC5C /* Cog.scriptTerminology in Resources */ = {isa = PBXBuildFile; fileRef = 1791005D0CB44D6D0070BC5C /* Cog.scriptTerminology */; };
1791FF900CB43A2C0070BC5C /* MediaKeysApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 1791FF8E0CB43A2C0070BC5C /* MediaKeysApplication.m */; };
@ -705,8 +701,6 @@
172A12A80F59AF8A0078EF0C /* NSString+CogSort.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+CogSort.m"; sourceTree = "<group>"; };
173855FD0E0CC81F00488CD4 /* FileTreeOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileTreeOutlineView.h; path = FileTree/FileTreeOutlineView.h; sourceTree = "<group>"; };
173855FE0E0CC81F00488CD4 /* FileTreeOutlineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FileTreeOutlineView.m; path = FileTree/FileTreeOutlineView.m; sourceTree = "<group>"; };
173A439F0F3FD26500676A7B /* ToolTipWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ToolTipWindow.h; path = ToolTip/ToolTipWindow.h; sourceTree = "<group>"; };
173A43A00F3FD26500676A7B /* ToolTipWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ToolTipWindow.m; path = ToolTip/ToolTipWindow.m; sourceTree = "<group>"; };
1745CBA40F661DBB00E513F7 /* shuffle_albums.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = shuffle_albums.png; path = Images/shuffle_albums.png; sourceTree = "<group>"; };
1752C36A0F59E00100F85F28 /* PlaybackButtons.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlaybackButtons.h; path = Window/PlaybackButtons.h; sourceTree = "<group>"; };
1752C36B0F59E00100F85F28 /* PlaybackButtons.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PlaybackButtons.m; path = Window/PlaybackButtons.m; sourceTree = "<group>"; };
@ -753,12 +747,6 @@
1784560E0F631E24007E8021 /* FileTreeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FileTreeViewController.m; path = FileTree/FileTreeViewController.m; sourceTree = "<group>"; };
178456100F631E31007E8021 /* SideViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SideViewController.h; sourceTree = "<group>"; };
178456110F631E31007E8021 /* SideViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SideViewController.m; sourceTree = "<group>"; };
178BAB930CD4E1B700B33D47 /* GCOneShotEffectTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCOneShotEffectTimer.h; sourceTree = "<group>"; };
178BAB940CD4E1B700B33D47 /* GCOneShotEffectTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCOneShotEffectTimer.m; sourceTree = "<group>"; };
178BAB950CD4E1B700B33D47 /* GCWindowMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCWindowMenu.h; sourceTree = "<group>"; };
178BAB960CD4E1B700B33D47 /* GCWindowMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCWindowMenu.m; sourceTree = "<group>"; };
178BAB970CD4E1B700B33D47 /* PopupButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopupButton.h; sourceTree = "<group>"; };
178BAB980CD4E1B700B33D47 /* PopupButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PopupButton.m; sourceTree = "<group>"; };
1791005C0CB44D6D0070BC5C /* Cog.scriptSuite */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Cog.scriptSuite; sourceTree = "<group>"; };
1791005D0CB44D6D0070BC5C /* Cog.scriptTerminology */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Cog.scriptTerminology; sourceTree = "<group>"; };
1791FF8D0CB43A2C0070BC5C /* MediaKeysApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaKeysApplication.h; sourceTree = "<group>"; };
@ -1062,15 +1050,6 @@
name = "Other Frameworks";
sourceTree = "<group>";
};
173A439D0F3FD25500676A7B /* ToolTip */ = {
isa = PBXGroup;
children = (
173A439F0F3FD26500676A7B /* ToolTipWindow.h */,
173A43A00F3FD26500676A7B /* ToolTipWindow.m */,
);
name = ToolTip;
sourceTree = "<group>";
};
1766C68D0B911DF1004A7AE4 /* AudioScrobbler */ = {
isa = PBXGroup;
children = (
@ -1103,8 +1082,6 @@
isa = PBXGroup;
children = (
83790D4A1809F4980073CF51 /* SPMediaKeyTap */,
173A439D0F3FD25500676A7B /* ToolTip */,
178BAB920CD4E1B700B33D47 /* GCWindowMenu */,
177EBF850B8BC2A70000BC8C /* ImageTextCell */,
179790DD0C087AB7001D6996 /* OpenURLPanel */,
);
@ -1200,19 +1177,6 @@
name = Images;
sourceTree = "<group>";
};
178BAB920CD4E1B700B33D47 /* GCWindowMenu */ = {
isa = PBXGroup;
children = (
178BAB930CD4E1B700B33D47 /* GCOneShotEffectTimer.h */,
178BAB940CD4E1B700B33D47 /* GCOneShotEffectTimer.m */,
178BAB950CD4E1B700B33D47 /* GCWindowMenu.h */,
178BAB960CD4E1B700B33D47 /* GCWindowMenu.m */,
178BAB970CD4E1B700B33D47 /* PopupButton.h */,
178BAB980CD4E1B700B33D47 /* PopupButton.m */,
);
path = GCWindowMenu;
sourceTree = "<group>";
};
179790DD0C087AB7001D6996 /* OpenURLPanel */ = {
isa = PBXGroup;
children = (
@ -2347,9 +2311,6 @@
83790D501809F4980073CF51 /* NSObject+SPInvocationGrabbing.m in Sources */,
1791FF900CB43A2C0070BC5C /* MediaKeysApplication.m in Sources */,
838491211807F38A00E7332D /* NowPlayingBarView.m in Sources */,
178BAB990CD4E1B700B33D47 /* GCOneShotEffectTimer.m in Sources */,
178BAB9A0CD4E1B700B33D47 /* GCWindowMenu.m in Sources */,
178BAB9B0CD4E1B700B33D47 /* PopupButton.m in Sources */,
5604D45B0D60349B004F5C5D /* SpotlightWindowController.m in Sources */,
5604D4F60D60726E004F5C5D /* SpotlightPlaylistEntry.m in Sources */,
56462EAF0D6341F6000AB68C /* SpotlightTransformers.m in Sources */,
@ -2373,7 +2334,6 @@
179D03280E0CB2500064A77A /* SmartFolderNode.m in Sources */,
173855FF0E0CC81F00488CD4 /* FileTreeOutlineView.m in Sources */,
07D971E60ED1DAA800E7602E /* TagEditorController.m in Sources */,
173A43A10F3FD26500676A7B /* ToolTipWindow.m in Sources */,
838491231807F38A00E7332D /* NowPlayingBarController.m in Sources */,
17E0D5EA0F520F02005B6FED /* MainWindow.m in Sources */,
836D28A818086386005B7299 /* MiniModeMenuTitleTransformer.m in Sources */,

View File

@ -1,53 +0,0 @@
///**********************************************************************************************************************************
/// GCOneShotEffectTimer.h
/// GCDrawKit
///
/// Created by graham on 24/04/2007.
/// Released under the Creative Commons license 2007 Apptree.net.
///
///
/// This work is licensed under the Creative Commons Attribution-ShareAlike 2.5 License.
/// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/ or send a letter to
/// Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
///
///**********************************************************************************************************************************
#import <Cocoa/Cocoa.h>
@interface GCOneShotEffectTimer : NSObject
{
NSTimer* _timer;
NSTimeInterval _start;
NSTimeInterval _total;
id _delegate;
}
+ (id) oneShotWithTime:(NSTimeInterval) t forDelegate:(id) del;
@end
@interface NSObject (OneShotDelegate)
- (void) oneShotHasReached:(float) relpos;
- (void) oneShotHasReachedInverse:(float) relpos;
- (void) oneShotComplete;
@end
/* This class wraps up a very simple piece of timer functionality. It sets up a timer that will call the
delegate frequently with a value from 0..1. Once 1 is reached, it stops.
This is useful for one-shot type animations such as fading out a window or similar.
The inverse method is called with interval 1..0.
The timer starts as soon as it is created.
The timer attempts to maintain a 30fps rate, and is capped at this value. On slower systems, it will drop
frames as needed.
*/

View File

@ -1,104 +0,0 @@
///**********************************************************************************************************************************
/// GCOneShotEffectTimer.m
/// GCDrawKit
///
/// Created by graham on 24/04/2007.
/// Released under the Creative Commons license 2007 Apptree.net.
///
///
/// This work is licensed under the Creative Commons Attribution-ShareAlike 2.5 License.
/// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/ or send a letter to
/// Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
///
///**********************************************************************************************************************************
#import "GCOneShotEffectTimer.h"
#import "Logging.h"
@interface GCOneShotEffectTimer (Private)
- (id) initWithTimeInterval:(NSTimeInterval) t forDelegate:(id) del;
- (void) setDelegate:(id) del;
- (id) delegate;
- (void) osfx_callback:(NSTimer*) timer;
@end
@implementation GCOneShotEffectTimer
+ (id) oneShotWithTime:(NSTimeInterval) t forDelegate:(id) del
{
GCOneShotEffectTimer* ft = [[GCOneShotEffectTimer alloc] initWithTimeInterval:t forDelegate:del];
// unlike the usual case, this is returned retained (by self, effectively). The one-shot releases
// itself when it's complete
return ft;
}
- (id) initWithTimeInterval:(NSTimeInterval) t forDelegate:(id) del
{
if ((self = [super init]))
{
[self setDelegate:del];
_total = t;
_timer = [NSTimer scheduledTimerWithTimeInterval:1/60.0f target:self selector:@selector(osfx_callback:) userInfo:nil repeats:YES];
_start = [NSDate timeIntervalSinceReferenceDate];
}
return self;
}
- (void) dealloc
{
[_timer invalidate];
}
- (void) setDelegate:(id) del
{
// delegate is retained and released when one-shot completes. This allows some effects to work even
// though the original delegate might be released by the caller.
_delegate = del;
}
- (id) delegate
{
return _delegate;
}
- (void) osfx_callback:(NSTimer*) timer
{
NSTimeInterval elapsed = [NSDate timeIntervalSinceReferenceDate] - _start;
float val = elapsed / _total;
//DLog(@"t = %f", val );
if ( elapsed > _total )
{
[timer invalidate];
_timer = nil;
if ( _delegate && [_delegate respondsToSelector:@selector(oneShotComplete)])
[_delegate oneShotComplete];
}
else
{
if ( _delegate && [_delegate respondsToSelector:@selector(oneShotHasReached:)])
[_delegate oneShotHasReached:val];
if ( _delegate && [_delegate respondsToSelector:@selector(oneShotHasReachedInverse:)])
[_delegate oneShotHasReachedInverse:1.0 - val];
}
}
@end

View File

@ -1,44 +0,0 @@
///**********************************************************************************************************************************
/// GCWindowMenu.h
/// GCDrawKitUI
///
/// Created by graham on 27/03/07.
/// Released under the Creative Commons license 2006 Apptree.net.
///
///
/// This work is licensed under the Creative Commons Attribution-ShareAlike 2.5 License.
/// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/ or send a letter to
/// Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
///
///**********************************************************************************************************************************
#import <Cocoa/Cocoa.h>
@interface GCWindowMenu : NSWindow
{
NSView* _mainView;
BOOL _passFirstClick;
BOOL _oneShotTracking;
}
+ (GCWindowMenu*) windowMenu;
+ (GCWindowMenu*) windowMenuWithContentView:(NSView*) view;
- (void) popUpAtPoint:(NSPoint) p withEvent:(NSEvent*) event;
- (void) popUpWithEvent:(NSEvent*) event;
- (void) setMainView:(NSView*) aView sizeToFit:(BOOL) stf;
- (NSView*) mainView;
- (void) setMainViewWantsFirstClick:(BOOL) firstClick;
- (void) setShouldCloseWhenViewTrackingReturns:(BOOL) cmup;
@end
@interface NSEvent (GCAdditions)
- (BOOL) isMouseEventType;
@end

View File

@ -1,615 +0,0 @@
///**********************************************************************************************************************************
/// GCWindowMenu.m
/// GCDrawKitUI
///
/// Created by graham on 27/03/07.
/// Released under the Creative Commons license 2006 Apptree.net.
///
///
/// This work is licensed under the Creative Commons Attribution-ShareAlike 2.5 License.
/// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/ or send a letter to
/// Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
///
///**********************************************************************************************************************************
#import "GCWindowMenu.h"
#import "GCOneShotEffectTimer.h"
#import "Logging.h"
@interface GCWindowMenu (Private)
+ (void) popUpWindowMenu:(GCWindowMenu*) menu withEvent:(NSEvent*) event;
+ (void) popUpWindowMenu:(GCWindowMenu*) menu atPoint:(NSPoint) loc withEvent:(NSEvent*) event;
- (void) trackWithEvent:(NSEvent*) event;
- (NSEvent*) transmogrify:(NSEvent*) event;
@end
#define kGCDefaultWindowMenuSize (NSMakeRect(0, 0, 100, 28 ))
#define kGCMenuContentInset 2
@implementation GCWindowMenu
///*********************************************************************************************************************
///
/// method: popUpWindowMenu:withEvent:forView:
/// scope: private class method
/// overrides:
/// description: pops up a custom popup menu, tracks it, then hides it again with a fadeout
///
/// parameters: <menu> the custom popup window to display
/// <event> the event to start the display with (usually from a mouse down)
/// result: none
///
/// notes: the menu is positioned with its top, left point just to the left of, and slightly below, the
/// point given in the event
///
///********************************************************************************************************************
+ (void) popUpWindowMenu:(GCWindowMenu*) menu withEvent:(NSEvent*) event
{
NSPoint loc = [event locationInWindow];
loc.x -= 10;
loc.y -= 5;
[self popUpWindowMenu:menu atPoint:loc withEvent:event];
}
///*********************************************************************************************************************
///
/// method: popUpWindowMenu:atPoint:withEvent:forView:
/// scope: private class method
/// overrides:
/// description: pops up a custom popup menu, tracks it, then hides it again with a fadeout
///
/// parameters: <menu> the custom popup window to display
/// <loc> the location within the window at which to display the menu (top, left of menu)
/// <event> the event to start the display with (usually from a mouse down)
/// result: none
///
/// notes:
///
///********************************************************************************************************************
+ (void) popUpWindowMenu:(GCWindowMenu*) menu atPoint:(NSPoint) loc withEvent:(NSEvent*) event
{
if ( menu == nil )
menu = [GCWindowMenu windowMenu];
NSRect rect = NSMakeRect(loc.x, loc.y, 0.0, 0.0);
rect = [[event window] convertRectToScreen:rect];
loc = NSMakePoint(rect.origin.x, rect.origin.y);
[menu setFrameTopLeftPoint:loc];
[[event window] addChildWindow:menu ordered:NSWindowAbove];
// show the "menu"
[menu orderFront:self];
// track the menu (keeps control in its own event loop):
[menu trackWithEvent:event];
// all done, tear down - remove with a fade effect
[GCOneShotEffectTimer oneShotWithTime:0.15 forDelegate:menu];
}
///*********************************************************************************************************************
///
/// method: windowMenu
/// scope: public class method
/// overrides:
/// description: makes a window menu that can be popped up using the above methods.
///
/// parameters: none
/// result: a new poppable window menu
///
/// notes: this method just makes an empy window with the default size. It's up to you to add some useful
/// content before displaying it
///
///********************************************************************************************************************
+ (GCWindowMenu*) windowMenu
{
GCWindowMenu* fi = [[GCWindowMenu alloc] initWithContentRect:NSZeroRect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:YES];
// note - because windows are all sent a -close message at quit time, set it
// not to be released at that time, otherwise the release from the autorelease pool
// will cause a crash due to the stale reference
[fi setReleasedWhenClosed:NO]; // **** important!! ****
return fi;
}
///*********************************************************************************************************************
///
/// method: windowMenuWithContentView:
/// scope: public class method
/// overrides:
/// description: makes a window menu that can be popped up using the above methods.
///
/// parameters: <view> the view to display within the menu
/// result: a new poppable window menu containing the given view
///
/// notes: the window is sized to fit the frame of the view you pass.
///
///********************************************************************************************************************
+ (GCWindowMenu*) windowMenuWithContentView:(NSView*) view
{
GCWindowMenu* menu = [self windowMenu];
[menu setMainView:view sizeToFit:YES];
return menu;
}
///*********************************************************************************************************************
///
/// method: popUpAtPoint:withEvent:forView:
/// scope: public instance method
/// overrides:
/// description: pops up a custom popup menu, tracks it, then hides it again with a fadeout
///
/// parameters: <p> the location within the window at which to display the menu (top, left of menu)
/// <event> the event to start the display with (usually from a mouse down in some view)
/// result: none
///
/// notes:
///
///********************************************************************************************************************
- (void) popUpAtPoint:(NSPoint) p withEvent:(NSEvent*) event
{
[[self class] popUpWindowMenu:self atPoint:p withEvent:event];
}
///*********************************************************************************************************************
///
/// method: popUpWithEvent:forView:
/// scope: public instance method
/// overrides:
/// description: pops up a custom popup menu, tracks it, then hides it again with a fadeout
///
/// parameters: <event> the event to start the display with (usually from a mouse down in some view)
/// result: none
///
/// notes:
///
///********************************************************************************************************************
- (void) popUpWithEvent:(NSEvent*) event
{
[[self class] popUpWindowMenu:self withEvent:event];
}
///*********************************************************************************************************************
///
/// method: initWithContentRect:styleMask:backing:defer:
/// scope: public instance method
/// overrides: NSWindow
/// description: designated initializer.
///
/// parameters: <> see NSWindow
/// result: the window
///
/// notes:
///
///********************************************************************************************************************
- (id) initWithContentRect:(NSRect) contentRect
styleMask:(NSWindowStyleMask) styleMask
backing:(NSBackingStoreType) bufferingType
defer:(BOOL) deferCreation
{
if ((self = [super initWithContentRect:contentRect
styleMask:styleMask
backing:bufferingType
defer:deferCreation]) != nil )
{
[self setLevel:NSPopUpMenuWindowLevel];
[self setHasShadow:YES];
[self setAlphaValue:0.95];
[self setReleasedWhenClosed:YES];
[self setFrame:kGCDefaultWindowMenuSize display:NO];
_mainView = nil;
_passFirstClick = YES;
_oneShotTracking = YES;
}
return self;
}
///*********************************************************************************************************************
///
/// method: trackWithEvent:
/// scope: public instance method
/// overrides:
/// description: track the mouse in the menu
///
/// parameters: <event> the initial starting event (will usually be a mouse down)
/// result: none
///
/// notes: tracking calls the main view's usual mouseDown/dragged/up methods, and tries to do so as compatibly
/// as possible with the usual view behaviours.
///
///********************************************************************************************************************
- (void) trackWithEvent:(NSEvent*) event
{
// tracks the "menu" by keeping control until a mouse up (or down, if menu 'clicked' into being)
DLog(@"starting tracking; initial event = %@", event);
// [NSEvent startPeriodicEventsAfterDelay:1.0 withPeriod:0.1];
NSTimeInterval startTime = [event timestamp];
[self setAcceptsMouseMovedEvents:YES];
if ( _passFirstClick )
{
[[self mainView] mouseDown:[self transmogrify:event]];
// the view may have trapped the mouse down and implemented its own tracking.
// Standard NSControls do that for example. In that case we don't want to track
// ourselves, so need to detect that and abort.
if ([[self currentEvent] timestamp] - startTime > 0.25 )
return;
}
NSEvent* theEvent;
BOOL keepOn = YES;
unsigned int mask;
BOOL invertedTracking = NO;
mask = NSLeftMouseUpMask | NSLeftMouseDraggedMask |
NSRightMouseUpMask | NSRightMouseDraggedMask |
NSAppKitDefinedMask | NSFlagsChangedMask |
NSScrollWheelMask | NSPeriodicMask;
while (keepOn)
{
theEvent = [self transmogrify:[self nextEventMatchingMask:mask]];
switch ([theEvent type])
{
case NSMouseMoved:
[[self mainView] mouseMoved:theEvent];
break;
case NSRightMouseDragged:
case NSLeftMouseDragged:
[[self mainView] mouseDragged:theEvent];
break;
case NSRightMouseUp:
case NSLeftMouseUp:
// if this is within a very short time of the mousedown, leave the menu up but track it
// using mouse moved and mouse down to end.
if ([theEvent timestamp] - startTime < 0.25 || !_passFirstClick )
{
invertedTracking = YES;
mask |= ( NSLeftMouseDownMask | NSRightMouseDownMask | NSMouseMovedMask );
}
else
{
[[self mainView] mouseUp:theEvent];
keepOn = NO;
}
break;
case NSRightMouseDown:
case NSLeftMouseDown:
if ( ! NSPointInRect([theEvent locationInWindow], [[self mainView] frame]))
keepOn = NO;
else
{
[[self mainView] mouseDown:theEvent];
if ( _oneShotTracking )
keepOn = NO;
}
break;
case NSPeriodic:
break;
case NSFlagsChanged:
[[self mainView] flagsChanged:theEvent];
break;
case NSAppKitDefined:
if([theEvent subtype] == NSApplicationDeactivatedEventType )
keepOn = NO;
break;
case NSScrollWheel:
[[self mainView] scrollWheel:theEvent];
break;
default:
/* Ignore any other kind of event. */
break;
}
}
[self discardEventsMatchingMask:NSAnyEventMask beforeEvent:theEvent];
//[NSEvent stopPeriodicEvents];
DLog(@"tracking ended");
}
///*********************************************************************************************************************
///
/// method: transmogrify:
/// scope: private instance method
/// overrides:
/// description: convert the event to the local window if necessary
///
/// parameters: <event> an event
/// result: the same event, or a modified version
///
/// notes: ensures that events received while tracking are always targetted at the right window
///
///********************************************************************************************************************
- (NSEvent*) transmogrify:(NSEvent*) event
{
if(([event window] != self) && [event isMouseEventType])
{
NSPoint pt = [event locationInWindow];
NSRect rect = NSMakeRect(pt.x, pt.y, 0.0, 0.0);
rect = [[event window] convertRectToScreen:rect];
NSPoint glob = NSMakePoint(rect.origin.x, rect.origin.y);
rect = NSMakeRect(glob.x, glob.y, 0.0, 0.0);
rect = [self convertRectFromScreen:rect];
pt = NSMakePoint(rect.origin.x, rect.origin.y);
return [NSEvent mouseEventWithType: [event type]
location: pt
modifierFlags: [event modifierFlags]
timestamp: [event timestamp]
windowNumber: [self windowNumber]
context: [event context]
eventNumber: [event eventNumber]
clickCount: [event clickCount]
pressure: [event pressure]];
}
else
return event;
}
///*********************************************************************************************************************
///
/// method: canBecomeMainWindow
/// scope: public instance method
/// overrides: NSWindow
/// description:
///
/// parameters: none
/// result: return YES
///
/// notes:
///
///********************************************************************************************************************
- (BOOL) canBecomeMainWindow
{
return NO;
}
///*********************************************************************************************************************
///
/// method: setMainView:sizeToFit:
/// scope: public instance method
/// overrides:
/// description: sets the pop-up window's content to the given view, and optionally sizes the window to fit
///
/// parameters: <aView> any view already created to be displayed in the menu
/// <stf> if YES, window is sized to the view's frame. If NO, the window size is not changed
/// result: none
///
/// notes: main view is additionally retained so outlet from NIB may be directly passed in
///
///********************************************************************************************************************
- (void) setMainView:(NSView*) aView sizeToFit:(BOOL) stf
{
_mainView = aView;
// add as a subview which retains it as well
[[self contentView] addSubview:aView];
// if stf, position the view at top, left corner of the window and
// make the window the size of the view
if ( stf )
{
NSRect fr = [self frameRectForContentRect:NSInsetRect( [aView frame], -kGCMenuContentInset, -kGCMenuContentInset )];
fr.origin = NSZeroPoint;
[aView setFrameOrigin:NSMakePoint( kGCMenuContentInset, kGCMenuContentInset )];
[self setFrame:fr display:YES];
}
[_mainView setNeedsDisplay:YES];
// if the view added is an NSControl, set first click to NO by default
if ([aView isKindOfClass:[NSControl class]])
[self setMainViewWantsFirstClick:NO];
}
///*********************************************************************************************************************
///
/// method: mainView
/// scope: public instance method
/// overrides:
/// description: get the main view
///
/// parameters: none
/// result: the main view
///
/// notes:
///
///********************************************************************************************************************
- (NSView*) mainView
{
return _mainView;
}
///*********************************************************************************************************************
///
/// method: setMainViewWantsFirstClick:
/// scope: public instance method
/// overrides:
/// description: sets whether the main view should receive a mouse down on entry to the tracking loop
///
/// parameters: <firstClick> YES to get the first click
/// result: none
///
/// notes: normally should be YES (the default). However views such as NSControl derivatives that implement
/// their own tracking should set NO. If NO, the popup can only be operated by clicking to open, then
/// clicking and dragging within - the continuous click to open, drag through and release operation
/// wont work because the control doesn't get a mouse down to start with.
///
///********************************************************************************************************************
- (void) setMainViewWantsFirstClick:(BOOL) firstClick
{
_passFirstClick = firstClick;
}
///*********************************************************************************************************************
///
/// method: setShouldCloseWhenViewTrackingReturns:
/// scope: public instance method
/// overrides:
/// description: sets whether popup should close or remain visible after main view completes its own tracking
///
/// parameters: <cmup> YES close on return from view tracking, NO to remain visble
/// result: none
///
/// notes: this affects tracking with views that implement their own tracking, such as NSControl. If YES, you
/// get one shot at the control - after operating it, it will be hidden. If NO, the control may be
/// changed as often as you want but you must manually click outside the menu to close it.
///
///********************************************************************************************************************
- (void) setShouldCloseWhenViewTrackingReturns:(BOOL) cmup
{
_oneShotTracking = cmup;
}
///*********************************************************************************************************************
///
/// method: oneShotHasReachedInverse:
/// scope: public instance method
/// overrides: NSObject (OneShotDelegate)
/// description: callback from fade out effect
///
/// parameters: <relpos> goes from 1..0
/// result: none
///
/// notes:
///
///********************************************************************************************************************
- (void) oneShotHasReachedInverse:(float) relpos
{
[self setAlphaValue:relpos];
}
///*********************************************************************************************************************
///
/// method: oneShotComplete
/// scope: public instance method
/// overrides: NSObject (OneShotDelegate)
/// description: callback from fade out effect
///
/// parameters: none
/// result: none
///
/// notes: removes the window from screen - oneshot will then release it
///
///********************************************************************************************************************
- (void) oneShotComplete
{
[[self parentWindow] removeChildWindow:self];
[self orderOut:self];
}
@end
@implementation NSEvent (GCAdditions)
///*********************************************************************************************************************
///
/// method: isMouseEventType:
/// scope: public instance method
/// overrides:
/// description: checks event to see if it's any mouse event
///
/// parameters: none
/// result: YES if the event is a mouse event of any kind
///
/// notes:
///
///********************************************************************************************************************
- (BOOL) isMouseEventType
{
// returns YES if type is any mouse type
NSEventType t = [self type];
return ( t == NSLeftMouseDown ||
t == NSLeftMouseUp ||
t == NSRightMouseDown ||
t == NSRightMouseUp ||
t == NSLeftMouseDragged ||
t == NSRightMouseDragged ||
t == NSOtherMouseDown ||
t == NSOtherMouseUp ||
t == NSOtherMouseDragged );
}
@end

View File

@ -1,19 +0,0 @@
//
// GCPopTestView.h
// GCWindowMenuTest
//
// Created by Graham on Tue Apr 24 2007. Modified from NSView to NSButton by Vincent Spader.
// Copyright (c) 2007 __MyCompanyName__. All rights reserved.
//
#import <AppKit/AppKit.h>
@interface PopupButton : NSButton
{
NSImage* _popButton;
IBOutlet NSView *_popView;
BOOL _hilited;
}
@end

View File

@ -1,38 +0,0 @@
//
// GCPopTestView.m
// GCWindowMenuTest
//
// Created by Graham on Tue Apr 24 2007.
// Copyright (c) 2007 __MyCompanyName__. All rights reserved.
//
#import "PopupButton.h"
#import "GCWindowMenu.h"
@implementation PopupButton
- (void) mouseDown:(NSEvent*) event
{
// create the menu to pop up using the view connected to the _popView outlet
GCWindowMenu* menu = [GCWindowMenu windowMenuWithContentView:_popView];
[menu setShouldCloseWhenViewTrackingReturns:YES];
// place the menu relative to our window
NSPoint p = [self bounds].origin;
p.y += [self bounds].size.height;
p.x += ([self bounds].size.width - [[[_popView window] contentView] bounds].size.width)/2.0;
p = [self convertPoint:p toView:nil];
// draw self highlighted
[self highlight:YES];
// pop up and track the menu
[menu popUpAtPoint:p withEvent:event];
// unhighlight self
[self highlight:NO];
}
@end

View File

@ -1,38 +0,0 @@
//
// ToolTip.h
// Cog
//
// Created by Vincent Spader on 2/8/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
// From http://www.cocoadev.com/index.pl?ToolTip
#import <AppKit/AppKit.h>
@interface ToolTipWindow : NSWindow
{
id closeTimer;
id tooltipObject;
NSColor *backgroundColor;
NSDictionary *textAttributes;
}
// returns the approximate window size needed to display the tooltip string.
- (NSSize)suggestedSizeForTooltip:(id)tooltip;
// setting and getting the bgColor
- (void)setBackgroundColor:(NSColor *)bgColor;
- (NSColor *)backgroundColor;
- (id)init;
- (id)toolTip;
- (void)setToolTip:(id)tip;
- (void)orderFront;
- (void)orderFrontForDuration:(NSTimeInterval)duration;
@end

View File

@ -1,117 +0,0 @@
#import "ToolTipWindow.h"
@implementation ToolTipWindow
- (void)setBackgroundColor:(NSColor *)bgColor
{
backgroundColor = bgColor;
}
- (NSColor *)backgroundColor
{
return backgroundColor;
}
- (NSSize)suggestedSizeForTooltip:(id)tooltip
{
NSSize tipSize = NSZeroSize;
if ([tooltip isKindOfClass:[NSAttributedString class]]) {
tipSize = [tooltip size];
}
else if ([tooltip isKindOfClass:[NSString class]]){
tipSize = [tooltip sizeWithAttributes:textAttributes];
}
if (!NSEqualSizes(tipSize, NSZeroSize))
tipSize.width += 4;
return tipSize;
}
- (id)init
{
self = [super initWithContentRect:NSMakeRect(0,0,0,0)
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO];
{ // window setup...
[self setAlphaValue:0.90];
[self setOpaque:NO];
[self setHasShadow:YES];
[self setBackgroundColor:[NSColor textBackgroundColor]];
[self setLevel:NSStatusWindowLevel];
[self setHidesOnDeactivate:YES];
[self setIgnoresMouseEvents:YES];
[self setReleasedWhenClosed:NO];
}
{ // textfield setup...
NSTextField *field = [[NSTextField alloc] initWithFrame:NSMakeRect(0,0,0,0)];
[field setEditable:NO];
[field setSelectable:NO];
[field setBezeled:NO];
[field setBordered:NO];
[field setDrawsBackground:NO];
[field setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[self setContentView:field];
[self setFrame:[self frameRectForContentRect:[field frame]] display:NO];
[field setStringValue:@" "]; // Just having at least 1 char to allow the next message...
textAttributes = [[field attributedStringValue] attributesAtIndex:0 effectiveRange:nil];
}
return self;
}
- (void)dealloc
{
if (closeTimer) {
[closeTimer invalidate];
}
}
- (id)toolTip { return tooltipObject; }
- (void)setToolTip:(id)tip
{
id contentView = [self contentView];
tooltipObject = tip;
if ([contentView isKindOfClass:[NSTextField class]]) {
if ([tip isKindOfClass:[NSString class]]) [contentView setStringValue:tip];
else
if ([tip isKindOfClass:[NSAttributedString class]]) [contentView setAttributedStringValue:tip];
}
}
- (void)orderFrontForDuration:(NSTimeInterval)duration
{
[self orderFront:nil];
if (closeTimer) { [closeTimer invalidate]; }
closeTimer = [NSTimer timerWithTimeInterval:duration target:self selector:@selector(close) userInfo:nil repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:closeTimer forMode:NSRunLoopCommonModes];
}
- (void)orderFront
{
if (closeTimer) { [closeTimer invalidate]; closeTimer = nil; }
[super orderFront:nil];
}
- (NSString *)description
{
return [NSString stringWithFormat:@"TooltipWindow:\n%@", [[self contentView] stringValue]];
}
@end

View File

@ -7,7 +7,6 @@
//
#import <Cocoa/Cocoa.h>
#import "ToolTipWindow.h"
@interface VolumeSlider : NSSlider {
NSPopover *popover;