Skip to content

Commit

Permalink
Right align multiline text on the right side of screen, fix text clip…
Browse files Browse the repository at this point in the history
…ping issue on margins, better time text
  • Loading branch information
glouel committed Oct 29, 2018
1 parent c70f442 commit 985dd07
Show file tree
Hide file tree
Showing 13 changed files with 166 additions and 146 deletions.
3 changes: 1 addition & 2 deletions Aerial.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@
0395835121807D1F008E8F9C /* [email protected] */,
FAC36F3A1BE1756D007F2A20 /* PreferencesWindow.xib */,
);
name = Resources;
path = Aerial/Resources;
path = Resources;
sourceTree = "<group>";
};
FAC36F3C1BE1756D007F2A20 /* Source */ = {
Expand Down
6 changes: 3 additions & 3 deletions Aerial/App/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.4test2</string>
<string>1.4.4beta4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand All @@ -31,12 +31,12 @@
</dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 John Coates. All rights reserved.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Aerial uses location services to calculate Sunset and Sunrise times from your position</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Aerial uses location services to calculate Sunset and Sunrise times from your position</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Aerial uses location services to calculate Sunset and Sunrise times from your position</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
Expand Down
10 changes: 7 additions & 3 deletions Aerial/Source/Models/Time/TimeManagement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,14 @@ class TimeManagement : NSObject {
default:
sunriseString = dateFormatter.string(from: (solar?.astronomicalSunrise)!)
sunsetString = dateFormatter.string(from: (solar?.astronomicalSunset)!)
}

if preferences.solarMode == Preferences.SolarMode.official.rawValue ||
preferences.solarMode == Preferences.SolarMode.strict.rawValue {
return(true, "Today’s sunrise: " + sunriseString + " Today’s sunset: " + sunsetString)
} else {
return(true, "Today’s dawn: " + sunriseString + " Today’s dusk: " + sunsetString)
}

return(true, "Today's Sunrise: " + sunriseString + " Today's Sunset: " + sunsetString)
}
}

Expand Down Expand Up @@ -219,7 +223,7 @@ class TimeManagement : NSObject {
let sunriseString = dateFormatter.string(from: sunriseDate!)
let sunsetString = dateFormatter.string(from: sunsetDate!)

return (true,"Today's Sunrise: " + sunriseString + " Today's Sunset: " + sunsetString)
return (true,"Today’s sunrise: " + sunriseString + " Today’s sunset: " + sunsetString)

} else {
isNightShiftDataCached = true
Expand Down
23 changes: 19 additions & 4 deletions Aerial/Source/Views/AerialView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,17 @@ class AerialView: ScreenSaverView {
fontSize = 12
}

// We get the horizontal margin
var mx = CGFloat(preferences.marginX!)

if !preferences.overrideMargins {
mx = 50
}
if isPreview {
mx = 10
}
let boundingRect = CGSize(width: layer!.visibleRect.size.width-2*mx, height: layer!.visibleRect.size.height)

// Get font with a fallback in case
var font = NSFont(name: "Helvetica Neue Medium", size: 28)
if let tryFont = NSFont(name: preferences.fontName!,size: fontSize) {
Expand All @@ -735,13 +746,13 @@ class AerialView: ScreenSaverView {
// Calculate bounding box
let s = NSAttributedString(string: string, attributes: attributes)

var rect = s.boundingRect(with: layer!.visibleRect.size, options: [.truncatesLastVisibleLine, .usesLineFragmentOrigin])
var rect = s.boundingRect(with: boundingRect, options: [.truncatesLastVisibleLine, .usesLineFragmentOrigin])
// Last line won't appear if we don't adjust
rect = CGRect(x: rect.origin.x, y: rect.origin.y, width: rect.width, height: rect.height+10)

// Rebind frame
self.textLayer.frame = rect

// At the position the user wants
if preferences.descriptionCorner == Preferences.DescriptionCorner.random.rawValue {
// Randomish, we still want something different
Expand Down Expand Up @@ -1026,15 +1037,19 @@ class AerialView: ScreenSaverView {
if (position == Preferences.DescriptionCorner.topLeft.rawValue) {
self.textLayer.anchorPoint = CGPoint(x: 0, y: 1)
self.textLayer.position = CGPoint(x: mx, y: layer!.bounds.height-my)
self.textLayer.alignmentMode = .left
} else if (position == Preferences.DescriptionCorner.bottomLeft.rawValue) {
self.textLayer.anchorPoint = CGPoint(x: 0, y: 0)
self.textLayer.position = CGPoint(x: mx, y: my)
self.textLayer.alignmentMode = .left
} else if (position == Preferences.DescriptionCorner.topRight.rawValue) {
self.textLayer.anchorPoint = CGPoint(x: 1, y: 1)
self.textLayer.position = CGPoint(x: layer!.bounds.width-mx, y: layer!.bounds.height-my)
self.textLayer.alignmentMode = .right
} else if (position == Preferences.DescriptionCorner.bottomRight.rawValue) {
self.textLayer.anchorPoint = CGPoint(x: 1, y: 0)
self.textLayer.position = CGPoint(x: layer!.bounds.width-mx, y: my)
self.textLayer.alignmentMode = .right
}
}

Expand All @@ -1044,10 +1059,10 @@ class AerialView: ScreenSaverView {
fadeAnimation.values = [0, 0, 1, 1, 0] as [NSNumber]
fadeAnimation.keyTimes = [0, Double( 1/duration ), Double( (1+AerialView.textFadeDuration)/duration ), Double( 1-AerialView.textFadeDuration/duration ), 1] as [NSNumber]
fadeAnimation.duration = duration

return fadeAnimation
}


// Create a move animation
func createMoveAnimation(layer : CALayer, to: CGPoint, duration: Double) -> CABasicAnimation {
let moveAnimation = CABasicAnimation(keyPath: "position")
moveAnimation.fromValue = layer.position
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions Aerial/Resources/Info.plist → Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSApplicationCategoryType</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -17,23 +15,25 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.4beta2</string>
<string>1.4.4beta4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.4.4beta2</string>
<string>1.4.4beta4</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSLocationAlwaysUsageDescription</key>
<string>Aerial uses location services to calculate Sunset and Sunrise times from your position</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Aerial uses location services to calculate Sunset and Sunrise times from your position</string>
<key>NSPrincipalClass</key>
<string>AerialView</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Aerial uses location services to calculate Sunset and Sunrise times from your position</string>
</dict>
</plist>
Loading

0 comments on commit 985dd07

Please sign in to comment.