Skip to content

Commit

Permalink
Hide wind selector for imperial users
Browse files Browse the repository at this point in the history
Changed the City name in weather to multiline when the city name is veeeeery long
  • Loading branch information
glouel committed Jun 9, 2021
1 parent ef18d11 commit e2c170f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Aerial.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3062,15 +3062,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.3.9beta1;
CURRENT_PROJECT_VERSION = 2.3.4beta1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Old stuff/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 2.3.9beta1;
MARKETING_VERSION = 2.3.4beta1;
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -3090,15 +3090,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.3.9beta1;
CURRENT_PROJECT_VERSION = 2.3.4beta1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Old stuff/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 2.3.9beta1;
MARKETING_VERSION = 2.3.4beta1;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
13 changes: 13 additions & 0 deletions Aerial/Source/Views/Layers/AnimatableLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,19 @@ extension CATextLayer {
return CGRect(x: rect.origin.x, y: rect.origin.y, width: rect.width+10, height: rect.height + 10)
}

func calculateRect(string: String, font: NSFont, maxWidth: Double) -> CGRect {
let boundingRect = CGSize(width: maxWidth, height: self.frame.size.height)

// We need an attributed string to take the font into account
let attributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: font as Any]
let str = NSAttributedString(string: string, attributes: attributes)

// Calculate bounding box
let rect = str.boundingRect(with: boundingRect, options: [.truncatesLastVisibleLine, .usesLineFragmentOrigin])

return CGRect(x: rect.origin.x, y: rect.origin.y, width: rect.width+10, height: rect.height + 10)
}

// Get the font and font size
func makeFont(name: String, size: Double) -> (NSFont, CGFloat) {
let fontSize = CGFloat(size) // Mayyybe some isPreview global somewhere
Expand Down
12 changes: 7 additions & 5 deletions Aerial/Source/Views/Layers/Weather/ConditionLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ConditionLayer: CALayer {
// First we make the temperatures block (accurate and feels like)
let tempBlock = makeTemperatureBlock()
let feelsBlock = makeFeelsLikeBlock()

var cityNameBlock: CALayer
if PrefsInfo.weather.showCity {
cityNameBlock = makeCityNameBlock()
Expand Down Expand Up @@ -92,15 +93,16 @@ class ConditionLayer: CALayer {
}

func makeCityNameBlock() -> CATextLayer {
let temp = CAVCTextLayer()

let temp = CATextLayer()
temp.isWrapped = true
temp.backgroundColor = .black
temp.string = condition!.name

(temp.font, temp.fontSize) = temp.makeFont(name: PrefsInfo.weather.fontName, size: PrefsInfo.weather.fontSize/1.5)

temp.alignmentMode = .center
// ReRect the temperature
let rect = temp.calculateRect(string: temp.string as! String, font: temp.font as! NSFont)
let rect = temp.calculateRect(string: temp.string as! String, font: temp.font as! NSFont, maxWidth: 220)
temp.frame = rect

temp.contentsScale = self.contentsScale

return temp
Expand Down
18 changes: 14 additions & 4 deletions Aerial/Source/Views/PrefPanel/InfoWeatherView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,21 @@ class InfoWeatherView: NSView {
@IBOutlet var iconsPopup: NSPopUpButton!
@IBOutlet var locationLabel: NSTextField!
@IBOutlet var weatherModePopup: NSPopUpButton!

@IBOutlet var windModePopup: NSPopUpButton!

// Init(ish)
func setStates() {
locationMode.selectItem(at: PrefsInfo.weather.locationMode.rawValue)
degreePopup.selectItem(at: PrefsInfo.weather.degree.rawValue)
iconsPopup.selectItem(at: PrefsInfo.weather.icons.rawValue)
weatherModePopup.selectItem(at: PrefsInfo.weather.mode.rawValue)
windModePopup.selectItem(at: PrefsInfo.weatherWindMode.rawValue)


if PrefsInfo.weather.degree == .fahrenheit {
windModePopup.isHidden = true
}

withCity.state = PrefsInfo.weather.showCity ? .on : .off
withWind.state = PrefsInfo.weather.showWind ? .on : .off
withHumidity.state = PrefsInfo.weather.showHumidity ? .on : .off
Expand All @@ -47,7 +51,7 @@ class InfoWeatherView: NSView {
@IBAction func windModePopupChange(_ sender: NSPopUpButton) {
PrefsInfo.weatherWindMode = InfoWeatherWind(rawValue: sender.indexOfSelectedItem)!
}

@IBAction func weatherModePopupChange(_ sender: NSPopUpButton) {
PrefsInfo.weather.mode = InfoWeatherMode(rawValue: sender.indexOfSelectedItem)!
}
Expand Down Expand Up @@ -88,6 +92,12 @@ class InfoWeatherView: NSView {

@IBAction func degreePopupChange(_ sender: NSPopUpButton) {
PrefsInfo.weather.degree = InfoDegree(rawValue: sender.indexOfSelectedItem)!

if PrefsInfo.weather.degree == .fahrenheit {
windModePopup.isHidden = true
} else {
windModePopup.isHidden = false
}
}

@IBAction func locationStringChange(_ sender: NSTextField) {
Expand Down
3 changes: 0 additions & 3 deletions Resources/MainUI/Settings panels/OverlaysViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,6 @@ corner</string>
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<color key="bezelColor" red="1" green="0.2680177406" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<action selector="testLocationButtonClick:" target="cmR-hZ-0Fe" id="4FO-ev-kS6"/>
</connections>
Expand Down Expand Up @@ -1219,7 +1218,6 @@ corner</string>
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<color key="bezelColor" red="1" green="0.2680177406" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<action selector="withHumidityChange:" target="cmR-hZ-0Fe" id="1VJ-QS-Brf"/>
</connections>
Expand Down Expand Up @@ -1261,7 +1259,6 @@ corner</string>
</items>
</menu>
</popUpButtonCell>
<color key="bezelColor" red="1" green="0.2680177406" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<action selector="windModePopupChange:" target="cmR-hZ-0Fe" id="9L4-KH-j8G"/>
</connections>
Expand Down

0 comments on commit e2c170f

Please sign in to comment.