Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions RHStatusItemView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
Expand All @@ -230,14 +230,16 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
MACOSX_DEPLOYMENT_TARGET = 10.8;
SDKROOT = macosx;
};
name = Release;
};
131B4ED31627AD6D00CCF430 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -254,6 +256,8 @@
131B4ED41627AD6D00CCF430 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>F6B5F711-AA9F-469C-BD86-D17EB4822F5A</string>
<key>IDESourceControlProjectName</key>
<string>RHStatusItemView</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>5AE9B92A-9F83-43F9-BAE0-ECCB2F29E1AF</key>
<string>https://github.com/heardrwt/RHStatusItemView.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>RHStatusItemView.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>5AE9B92A-9F83-43F9-BAE0-ECCB2F29E1AF</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/heardrwt/RHStatusItemView.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>5AE9B92A-9F83-43F9-BAE0-ECCB2F29E1AF</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>5AE9B92A-9F83-43F9-BAE0-ECCB2F29E1AF</string>
<key>IDESourceControlWCCName</key>
<string>RHStatusItemView</string>
</dict>
</array>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges</key>
<true/>
<key>SnapshotAutomaticallyBeforeSignificantChanges</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "131B4EBC1627AD6D00CCF430"
BuildableName = "RHStatusItemView.framework"
BlueprintName = "RHStatusItemView"
ReferencedContainer = "container:RHStatusItemView.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>RHStatusItemView.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>131B4EBC1627AD6D00CCF430</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
14 changes: 6 additions & 8 deletions RHStatusItemView/RHStatusItemView.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,17 @@
BOOL _isMenuVisible;
}

@property (nonatomic, assign) NSStatusItem *statusItem; //should never be nil
@property (nonatomic) NSStatusItem *statusItem; //should never be nil

@property (nonatomic, retain) NSImage *image;
@property (nonatomic, retain) NSImage *alternateImage;
@property (nonatomic, strong) NSImage *image;
@property (nonatomic, strong) NSImage *alternateImage;

// NSControl provides these for us
//@property (weak) id target;
//@property SEL action; //if no action specified, we will try and pop up menu if set.

@property SEL rightAction; //if no rightAction specified, we will try and pop up, in order rightMenu, menu.

@property (nonatomic, retain) NSMenu *menu;
@property (nonatomic, retain) NSMenu *rightMenu;
//@property (strong) NSMenu *menu;
@property (nonatomic) SEL rightAction; //if no rightAction specified, we will try and pop up, in order rightMenu, menu.
@property (nonatomic, strong) NSMenu *rightMenu;

-(id)initWithStatusBarItem:(NSStatusItem*)statusItem; //designated initializer

Expand Down
37 changes: 13 additions & 24 deletions RHStatusItemView/RHStatusItemView.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


static CGFloat RHStatusItemViewImageHPadding = 4.0f;
static CGFloat RHStatusItemViewImageVPadding = 3.0f;


#import "RHStatusItemView.h"

@implementation RHStatusItemView
Expand All @@ -41,8 +37,6 @@ @implementation RHStatusItemView
@synthesize alternateImage=_alternateImage;

@synthesize rightAction=_rightAction;

@synthesize menu=_menu;
@synthesize rightMenu=_rightMenu;


Expand All @@ -64,37 +58,31 @@ -(id)initWithStatusBarItem:(NSStatusItem*)statusItem{
- (void)dealloc{
_statusItem = nil;

[_image release]; _image = nil;
[_alternateImage release]; _alternateImage = nil;

_rightAction = NULL;

[_menu release]; _menu = nil;
[_rightMenu release]; _rightMenu = nil;

[super dealloc];
}


#pragma mark - properties
-(void)setStatusItem:(NSStatusItem *)statusItem{
if (!statusItem) [NSException raise:NSInvalidArgumentException format:@"-[%@ %@] statusItem should not be nil!", NSStringFromClass(self.class), NSStringFromSelector(_cmd)];
_statusItem = statusItem;
_statusItem.highlightMode = YES;
_statusItem.view = self;
}

-(void)setImage:(NSImage *)image{
if (image != _image){
[_image release];
_image = [image retain];
_image = image;
}

[self setNeedsDisplay];
}

-(void)setAlternateImage:(NSImage *)alternateImage{
if (alternateImage != _alternateImage){
[_alternateImage release];
_alternateImage = [alternateImage retain];
_alternateImage = alternateImage;
}

[self setNeedsDisplay];
Expand All @@ -108,14 +96,15 @@ - (void)drawRect:(NSRect)rect {
// Draw status bar background, highlighted if menu is showing
[_statusItem drawStatusBarBackgroundInRect:[self bounds] withHighlight:highlighted];

NSRect imageRect = NSInsetRect(self.bounds, RHStatusItemViewImageHPadding, RHStatusItemViewImageVPadding);
imageRect.origin.y++; //move it up one pix

if (highlighted){
[self.alternateImage drawInRect:imageRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1];
} else {
[self.image drawInRect:imageRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1];
}
NSImage *image = self.image;
if (highlighted && self.alternateImage)
image = self.alternateImage;

[image drawInRect:self.bounds fromRect:NSRectFromCGRect(
CGRectMake( image.size.width / 2 - self.bounds.size.width / 2,
image.size.height / 2 - self.bounds.size.height / 2,
self.bounds.size.width, self.bounds.size.height ) )
operation:NSCompositeSourceOver fraction:1];
}


Expand Down