Skip to content

Commit bf489e6

Browse files
committed
Merge pull request codler#2 from mac-cain13/pullbranch
Tuned dynamic fill of the icon
2 parents e8846c1 + dae315e commit bf489e6

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

Battery Time Remaining.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
2841C7F415C91CC100F4F15F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2841C7F315C91CC100F4F15F /* AppDelegate.m */; };
1515
2841C7F715C91CC200F4F15F /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2841C7F515C91CC200F4F15F /* MainMenu.xib */; };
1616
2841C7FE15C91CEF00F4F15F /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2841C7FD15C91CEF00F4F15F /* IOKit.framework */; };
17+
D570489C15CF1B9200E488C4 /* battery.icns in Resources */ = {isa = PBXBuildFile; fileRef = D570489B15CF1B9200E488C4 /* battery.icns */; };
1718
D58C7EF815CD7C6100C07E0C /* StartAtLoginHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = D58C7EF715CD7C6100C07E0C /* StartAtLoginHelper.m */; };
1819
/* End PBXBuildFile section */
1920

@@ -32,6 +33,7 @@
3233
2841C7F315C91CC100F4F15F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
3334
2841C7F615C91CC200F4F15F /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
3435
2841C7FD15C91CEF00F4F15F /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
36+
D570489B15CF1B9200E488C4 /* battery.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = battery.icns; sourceTree = "<group>"; };
3537
D58C7EF615CD7C6100C07E0C /* StartAtLoginHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StartAtLoginHelper.h; sourceTree = "<group>"; };
3638
D58C7EF715CD7C6100C07E0C /* StartAtLoginHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StartAtLoginHelper.m; sourceTree = "<group>"; };
3739
/* End PBXFileReference section */
@@ -52,6 +54,7 @@
5254
2841C7D115C91CC100F4F15F = {
5355
isa = PBXGroup;
5456
children = (
57+
D570489B15CF1B9200E488C4 /* battery.icns */,
5558
2841C7E615C91CC100F4F15F /* Battery Time Remaining */,
5659
2841C7DF15C91CC100F4F15F /* Frameworks */,
5760
2841C7DD15C91CC100F4F15F /* Products */,
@@ -165,6 +168,7 @@
165168
2841C7EB15C91CC100F4F15F /* InfoPlist.strings in Resources */,
166169
2841C7F115C91CC100F4F15F /* Credits.rtf in Resources */,
167170
2841C7F715C91CC200F4F15F /* MainMenu.xib in Resources */,
171+
D570489C15CF1B9200E488C4 /* battery.icns in Resources */,
168172
);
169173
runOnlyForDeploymentPostprocessing = 0;
170174
};

Battery Time Remaining/AppDelegate.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,20 @@ - (void)updateStatusItem
132132
NSInteger hour = (int)timeRemaining / 3600;
133133
NSInteger minute = (int)timeRemaining % 3600 / 60;
134134

135-
// Make dynamic Battery icon
135+
// Make dynamic battery icon
136136
NSImage *batteryDynamic = [self getBatteryIconNamed:@"BatteryEmpty"];
137137

138138
[batteryDynamic lockFocus];
139-
139+
140140
NSRect sourceRect;
141141
sourceRect.origin = NSZeroPoint;
142142
sourceRect.origin.x += [batteryDynamic size].width / 100 * 15;
143-
sourceRect.origin.y += [batteryDynamic size].height / 50 * 10;
143+
sourceRect.origin.y += [batteryDynamic size].height / 50 * 15;
144144
sourceRect.size = [batteryDynamic size];
145-
sourceRect.size.width -= [batteryDynamic size].width / 100 * 40;
146-
sourceRect.size.height -= [batteryDynamic size].height / 50 * 20;
145+
sourceRect.size.width -= [batteryDynamic size].width / 100 * 43;
146+
sourceRect.size.height -= [batteryDynamic size].height / 50 * 30;
147147

148-
sourceRect.size.width -= [batteryDynamic size].width / 100 * (60.0f - (60.0f / 100.0f * percent));
148+
sourceRect.size.width -= [batteryDynamic size].width / 100 * (60.f - (60.f / 100.f * percent));
149149

150150
if (percent > 15)
151151
{
@@ -156,7 +156,7 @@ - (void)updateStatusItem
156156
[[NSColor redColor] set];
157157
}
158158

159-
NSRectFill (sourceRect);
159+
NSRectFill(sourceRect);
160160

161161
[batteryDynamic unlockFocus];
162162

Battery Time Remaining/Battery Time Remaining-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>${EXECUTABLE_NAME}</string>
99
<key>CFBundleIconFile</key>
10-
<string></string>
10+
<string>battery</string>
1111
<key>CFBundleIdentifier</key>
1212
<string>com.codler.${PRODUCT_NAME:rfc1034identifier}</string>
1313
<key>CFBundleInfoDictionaryVersion</key>

battery.icns

59.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)