Skip to content

Commit

Permalink
Change vertical lyrics mode to support mode fonts (still not perfect)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelRow authored and MichaelRow committed Dec 11, 2015
1 parent e442abf commit e2466b8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion LrcMaker/Base.lproj/MainWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ IA
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="XGW-nJ-mvd">
<rect key="frame" x="610" y="1" width="15" height="248"/>
<rect key="frame" x="609" y="1" width="16" height="248"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down
13 changes: 2 additions & 11 deletions Lyrics/Base.lproj/LyricsEditWindow.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="LyricsEditWindowController" customModule="LyricsX" customModuleProvider="target">
Expand All @@ -25,7 +25,6 @@
<button verticalHuggingPriority="750" id="eqX-3O-wen">
<rect key="frame" x="20" y="476" width="126" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<animations/>
<buttonCell key="cell" type="roundRect" title="Copy to Pasteboard" bezelStyle="roundedRect" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="YUH-mE-ilV">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/>
Expand All @@ -44,7 +43,6 @@
<textView drawsBackground="NO" importsGraphics="NO" findStyle="panel" allowsUndo="YES" usesRuler="YES" usesFontPanel="YES" verticallyResizable="YES" allowsNonContiguousLayout="YES" quoteSubstitution="YES" dashSubstitution="YES" spellingCorrection="YES" smartInsertDelete="YES" id="DdJ-zl-cNn" customClass="LyricsEditView" customModule="LyricsX" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="392" height="428"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="407" height="428"/>
<size key="maxSize" width="463" height="10000000"/>
Expand All @@ -53,25 +51,20 @@
<size key="maxSize" width="463" height="10000000"/>
</textView>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="0.0" colorSpace="calibratedWhite"/>
</clipView>
<animations/>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="Cja-Fy-Z5Q">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
<animations/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="88f-K2-53Z">
<rect key="frame" x="392" y="1" width="16" height="428"/>
<autoresizingMask key="autoresizingMask"/>
<animations/>
</scroller>
</scrollView>
<button verticalHuggingPriority="750" id="Zab-TL-zie">
<rect key="frame" x="302" y="12" width="53" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<animations/>
<buttonCell key="cell" type="roundRect" title="Cancel" bezelStyle="roundedRect" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="M2J-kq-dWj">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/>
Expand All @@ -83,7 +76,6 @@
<button verticalHuggingPriority="750" id="zeA-LU-YJy">
<rect key="frame" x="376" y="12" width="53" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<animations/>
<buttonCell key="cell" type="roundRect" title="OK" bezelStyle="roundedRect" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Pnh-dj-Jao">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/>
Expand All @@ -93,7 +85,6 @@
</connections>
</button>
</subviews>
<animations/>
</view>
<point key="canvasLocation" x="442.5" y="332.5"/>
</window>
Expand Down
9 changes: 2 additions & 7 deletions Lyrics/Base.lproj/StatusMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AppController" customModule="LyricsX" customModuleProvider="target">
Expand Down Expand Up @@ -152,7 +152,6 @@
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="q88-EF-ohR">
<rect key="frame" x="18" y="6" width="92" height="17"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Lyrics Offset:" id="03a-uH-jAo">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
Expand All @@ -161,7 +160,6 @@
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Hod-ZB-daW">
<rect key="frame" x="109" y="5" width="61" height="19"/>
<animations/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" drawsBackground="YES" id="Xwr-CI-ndX">
<numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" lenient="YES" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="2000000000" id="ZW5-md-eUU">
<real key="minimum" value="-10000"/>
Expand All @@ -183,7 +181,6 @@
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QQX-LU-OA2">
<rect key="frame" x="197" y="6" width="22" height="17"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="ms" id="htP-HY-Y99">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
Expand All @@ -192,7 +189,6 @@
</textField>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lUm-Ay-pgl">
<rect key="frame" x="175" y="1" width="19" height="27"/>
<animations/>
<stepperCell key="cell" continuous="YES" alignment="left" increment="100" minValue="-10000" maxValue="10000" id="beX-Hj-1Ng"/>
<connections>
<binding destination="-2" name="value" keyPath="self.timeDly" id="RUR-nb-r1Q">
Expand All @@ -204,7 +200,6 @@
</connections>
</stepper>
</subviews>
<animations/>
<point key="canvasLocation" x="334.5" y="380"/>
</customView>
<userDefaultsController representsSharedInstance="YES" id="Ppe-ZY-ULn"/>
Expand Down
20 changes: 17 additions & 3 deletions Lyrics/LyricsWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class LyricsWindowController: NSWindowController {

backgroundLayer.anchorPoint = CGPointZero
backgroundLayer.position = CGPointMake(0, 0)
backgroundLayer.cornerRadius = 20
backgroundLayer.cornerRadius = 12

firstLyricsLayer.anchorPoint = CGPointZero
firstLyricsLayer.position = CGPointMake(0, 0)
Expand Down Expand Up @@ -333,7 +333,11 @@ class LyricsWindowController: NSWindowController {
backgroundLayer.hidden = false

let attributedStr: NSMutableAttributedString = NSMutableAttributedString(string: firstLyrics as! String, attributes: attrs)
attributedStr.addAttribute(kCTVerticalFormsAttributeName as String, value: NSNumber(bool: true), range: NSMakeRange(0, attributedStr.length))
for var i=0; i<firstLyrics?.length; ++i {
if isChinese((firstLyrics?.substringWithRange(NSMakeRange(i, 1)))!) {
attributedStr.addAttribute(kCTVerticalFormsAttributeName as String, value: NSNumber(bool: true), range: NSMakeRange(i, 1))
}
}

let strSize:NSSize = attributedStr.size()
let frameSize = NSMakeSize(strSize.width+50, strSize.height)
Expand All @@ -354,7 +358,7 @@ class LyricsWindowController: NSWindowController {
}

backgroundLayer.frame = CGRectMake(x, y, frameSize.width, frameSize.height)
firstLyricsLayer.frame = CGRectMake(0, -frameSize.height/4, frameSize.width, frameSize.height)
firstLyricsLayer.frame = CGRectMake(0, -frameSize.height * 0.1, frameSize.width, frameSize.height * 1.1)
backgroundLayer.transform = CATransform3DMakeRotation(CGFloat(-M_PI_2), 0, 0, 1)
isRotated = true
firstLyricsLayer.string=attributedStr
Expand All @@ -381,5 +385,15 @@ class LyricsWindowController: NSWindowController {
self.reflash()
}
}

//Other Methods
private func isChinese (character: NSString) -> Bool {
let char: UnsafePointer<Int8> = character.UTF8String
if strlen(char) == 3 {
return true
} else {
return false
}
}

}
2 changes: 1 addition & 1 deletion Lyrics/TextPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TextPreview: NSView {

// draw background layer
let strRect: NSRect = NSMakeRect(strOrigin.x - 25, strOrigin.y, strSize.width + 50, strSize.height)
let path:NSBezierPath = NSBezierPath(roundedRect: strRect, xRadius: 20, yRadius: 20)
let path:NSBezierPath = NSBezierPath(roundedRect: strRect, xRadius: 12, yRadius: 12)
backgroundColor.set()
path.fill()

Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Swift-based iTunes plug-in app to display lyrics on the desktop.

![lrcseeker]
(http://i67.tinypic.com/14xiccp.jpg)
* Build-In LrcMaker to make lrc by yourself
* Build-In LrcMaker to make lrc by yourself.


![lrcmaker-1]
Expand All @@ -49,15 +49,20 @@ Swift-based iTunes plug-in app to display lyrics on the desktop.
* Auto launches with iTunes or user login.

###System Requirement
* Mac OS X 10.9 (Mavericks) or above
* Mac OS X 10.9 (Mavericks) or above.

###Build Requirement
* Mac OS X 10.11 (El Capitan) or above
* Xcode 7.0 or above
* Mac OS X 10.11 (El Capitan) or above.
* Xcode 7.0 or above.

###Third Party Library & Frameworks
* [OpenCC](https://github.com/BYVoid/OpenCC)
* [DBPrefsWindowController](https://github.com/kgn/DBPrefsWindowController)

###Special Thanks
* [DynamicLyrics Project](https://github.com/MartianZ/DynamicLyrics)

###To-do List
* Using Core Text to display vertical lyrics.
* In const lyrics layout mode, you can move around lyrics window.
* Improve Two-Line mode(clip one into two when lyric is too long).

0 comments on commit e2466b8

Please sign in to comment.