Skip to content

Commit

Permalink
Merge pull request #58 from MichaelRow/master
Browse files Browse the repository at this point in the history
Add: shadow color and radius & Change:Screen capture method
  • Loading branch information
MartianZ committed Nov 11, 2015
2 parents 280c47b + a4f773b commit 325f2bb
Show file tree
Hide file tree
Showing 13 changed files with 1,177 additions and 922 deletions.
11 changes: 9 additions & 2 deletions DynamicLyrics/LyricX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@
attributes = {
LastUpgradeCheck = 0600;
ORGANIZATIONNAME = Martian;
TargetAttributes = {
02710E89152A839F006D4BFF = {
DevelopmentTeam = V7RJA6U5A6;
};
};
};
buildConfigurationList = 02710E84152A839F006D4BFF /* Build configuration list for PBXProject "LyricX" */;
compatibilityVersion = "Xcode 3.2";
Expand Down Expand Up @@ -692,7 +697,8 @@
02710EA9152A839F006D4BFF /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Developer ID Application: Zhu Zheng (R5RMP6G3GQ)";
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -714,7 +720,8 @@
02710EAA152A839F006D4BFF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Developer ID Application: Zhu Zheng (R5RMP6G3GQ)";
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down
2 changes: 1 addition & 1 deletion DynamicLyrics/LyricX/AppPrefsWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ -(void)changeColor:(id)sender

- (NSUInteger)validModesForFontPanel:(NSFontPanel *)fontPanel
{
return NSFontPanelSizeModeMask | NSFontPanelCollectionModeMask | NSFontPanelShadowEffectModeMask;
return NSFontPanelSizeModeMask | NSFontPanelCollectionModeMask | NSFontPanelFaceModeMask;
}

-(IBAction)openFontPanel:(id)sender
Expand Down
3 changes: 3 additions & 0 deletions DynamicLyrics/LyricX/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@

#define Pref_Desktop_Text_Color "PrefDesktopTextColor"
#define Pref_Desktop_Background_Color "PrefDesktopBackgroundColor"
#define PrefDesktopShadowColor "PrefDesktopShadowColor"
#define PrefDesktopShadowRadius "PrefDesktopShadowRadius"
#define WhetherDisableWhenSnapshot "WhetherDisableWhenSnapshot"

#define Pref_Launch_Quit_With_iTunes "PrefLaunchQuitWithiTunes"
#define Pref_Lyrics_Show_Next_Line "PrefLyricsShowNextLine"
Expand Down
7 changes: 6 additions & 1 deletion DynamicLyrics/LyricX/LyricX-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@
<key>CFBundleShortVersionString</key>
<string>2.1</string>
<key>CFBundleVersion</key>
<string>1320</string>
<string>1475</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.music</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>LSUIElement</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012 Martian. All rights reserved.</string>
<key>NSMainNibFile</key>
Expand Down
46 changes: 3 additions & 43 deletions DynamicLyrics/LyricX/LyricXAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ + (void)initialize {
if ( self == [AppDelegate class] ) {
//set default preference values
NSDictionary *defaultValues = @{@Pref_Desktop_Text_Color: [NSArchiver archivedDataWithRootObject:[NSColor yellowColor]],
@PrefDesktopShadowColor: [NSArchiver archivedDataWithRootObject:[NSColor blackColor]],
@PrefDesktopShadowRadius:[NSNumber numberWithDouble:4],
@Pref_Desktop_Background_Color: [NSArchiver archivedDataWithRootObject:[NSColor colorWithCalibratedWhite:0 alpha:0.25]],
@WhetherDisableWhenSnapshot:[NSNumber numberWithBool:NO],
@Pref_Enable_Desktop_Lyrics: @(YES),
@Pref_Enable_MenuBar_Lyrics: @(NO),
@Pref_hotkeyCodeWriteLyrics: [NSNumber numberWithInt:kVK_ANSI_W],
Expand Down Expand Up @@ -73,9 +76,6 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
//注册快捷键:option+W 写入歌词
RegisterEventHotKey((UInt32)[userDefaults integerForKey:@Pref_hotkeyCodeWriteLyrics], (UInt32)[userDefaults integerForKey:@Pref_hotkeyModifiersWriteLyrics], a_HotKeyID, GetApplicationEventTarget(), 0, &a_HotKeyRef);
}

//监视系统截图按键,关闭桌面歌词,防止影响截图
RegisterEventHotKey(kVK_ANSI_4, cmdKey | shiftKey, b_HotKeyID, GetApplicationEventTarget(), 0, &b_HotKeyRef);

NSLog(@"%@", [userDefaults stringForKey:@"translatorLanguageX"]);
}
Expand Down Expand Up @@ -149,8 +149,6 @@ static int GetBSDProcessList(struct kinfo_proc **procList, size_t *procCount)
return err;
}



- (NSDictionary *)infoForPID:(pid_t)pid
{
NSDictionary *ret = nil;
Expand All @@ -163,27 +161,6 @@ - (NSDictionary *)infoForPID:(pid_t)pid
return ret;
}

- (BOOL)isScreencCaptureRunning
{
struct kinfo_proc *mylist;
size_t mycount = 0;
mylist = (struct kinfo_proc *)malloc(sizeof(struct kinfo_proc));
GetBSDProcessList(&mylist, &mycount);
int k;
for(k = 0; k < mycount; k++) {
struct kinfo_proc *proc = NULL;
proc = &mylist[k];
NSString *fullName = [[self infoForPID:proc->kp_proc.p_pid] objectForKey:(id)kCFBundleNameKey];
if (fullName == nil) fullName = [NSString stringWithFormat:@"%s",proc->kp_proc.p_comm];
if ([fullName isEqualToString:@"screencapture"]) {
free(mylist);
return YES;
}
}
free(mylist);
return NO;
}

- (void)applicationWillTerminate:(NSNotification *)notification
{

Expand Down Expand Up @@ -243,23 +220,6 @@ OSStatus myHotKeyHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent,
}
}

if (keyID.id == b_HotKeyID.id) {
NSLog(@"Screen Capture!");


NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];

[nc postNotificationName:@NC_Hide_DesktopLyrics object:mySelf];

do {
sleep(1);

} while ([mySelf isScreencCaptureRunning]);

[nc postNotificationName:@NC_Show_DesktopLyrics object:mySelf];


}
}
return noErr;
}
Expand Down
7 changes: 4 additions & 3 deletions DynamicLyrics/LyricX/LyricsFloatWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ - (id)initWithContentRect:(NSRect)contentRect
self.opaque = NO;
self.hasShadow = NO;
self.hidesOnDeactivate = NO;
self.IgnoresMouseEvents = YES;
self.ignoresMouseEvents = YES;
if ([[NSUserDefaults standardUserDefaults] boolForKey:@Pref_Attach_LyricsWindow_To_All_Spaces]) {
[self setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
}
lyricsView = [[LyricsView alloc] initWithFrame:NSScreen.mainScreen.frame];
[self setContentView:lyricsView];
[self setSharingType:NSWindowSharingNone];

if ([[NSUserDefaults standardUserDefaults] boolForKey:@WhetherDisableWhenSnapshot]) {
[self setSharingType:NSWindowSharingNone];
}
nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(hideLyricsWindow:) name:@NC_Hide_DesktopLyrics object:nil];
[nc addObserver:self selector:@selector(showLyricsWindow:) name:@NC_Show_DesktopLyrics object:nil];
Expand Down
10 changes: 8 additions & 2 deletions DynamicLyrics/LyricX/LyricsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,11 @@ -(void)iTunesLyricsChanged:(NSNotification *)note
textLayer.alignmentMode = kCAAlignmentCenter;
textLayer.font = font;
if ([userDefaults boolForKey:@Pref_Shadow_Style_Text]) {
NSColor *shadowColor=[NSUnarchiver unarchiveObjectWithData:[userDefaults objectForKey:@PrefDesktopShadowColor]];
double shadowRadius=[userDefaults doubleForKey:@PrefDesktopShadowRadius];
textLayer.shadowColor=CGColorCreateFromNSColor(colorSpace,shadowColor);
textLayer.shadowOpacity = 1.0;
textLayer.shadowRadius = 2;
textLayer.shadowRadius = shadowRadius;
textLayer.shadowOffset = CGSizeMake (0, 0);
} else {
textLayer.shadowOpacity = 0;
Expand All @@ -183,8 +186,11 @@ -(void)iTunesLyricsChanged:(NSNotification *)note
secondTextLayer.alignmentMode = kCAAlignmentCenter;
secondTextLayer.font = font;
if ([userDefaults boolForKey:@Pref_Shadow_Style_Text]) {
NSColor *shadowColor=[NSUnarchiver unarchiveObjectWithData:[userDefaults objectForKey:@PrefDesktopShadowColor]];
double shadowRadius=[userDefaults doubleForKey:@PrefDesktopShadowRadius];
secondTextLayer.shadowColor=CGColorCreateFromNSColor(colorSpace,shadowColor);
secondTextLayer.shadowOpacity = 1.0;
secondTextLayer.shadowRadius = 2;
secondTextLayer.shadowRadius = shadowRadius;
secondTextLayer.shadowOffset = CGSizeMake (0, 0);
} else {
secondTextLayer.shadowOpacity = 0;
Expand Down
Loading

0 comments on commit 325f2bb

Please sign in to comment.