mirror of
https://github.com/swiftbar/SwiftBar.git
synced 2024-09-11 16:05:33 +03:00
SFImage should respect width and height #245
This commit is contained in:
parent
d7ab6c15cd
commit
19bac5613e
@ -137,20 +137,25 @@ struct MenuLineParameters {
|
||||
if #available(OSX 11.0, *) {
|
||||
if let sfString = params["sfimage"] {
|
||||
let config = NSImage.SymbolConfiguration(scale: .large)
|
||||
return NSImage(systemSymbolName: sfString, accessibilityDescription: nil)?.withSymbolConfiguration(config)
|
||||
let image = NSImage(systemSymbolName: sfString, accessibilityDescription: nil)?.withSymbolConfiguration(config)
|
||||
image?.isTemplate = true
|
||||
return resizedImageIfRequested(image)
|
||||
}
|
||||
}
|
||||
|
||||
let image = NSImage.createImage(from: params["image"] ?? params["templateimage"], isTemplate: params["templateimage"] != nil)
|
||||
if let widthStr = params["width"], let width = Float(widthStr),
|
||||
let heightStr = params["height"], let height = Float(heightStr)
|
||||
{
|
||||
return image?.resizedCopy(w: CGFloat(width), h: CGFloat(height))
|
||||
}
|
||||
|
||||
return image
|
||||
return resizedImageIfRequested(image)
|
||||
}
|
||||
|
||||
private func resizedImageIfRequested(_ image: NSImage?) -> NSImage? {
|
||||
guard let widthStr = params["width"], let width = Float(widthStr),
|
||||
let heightStr = params["height"], let height = Float(heightStr) else {
|
||||
return image
|
||||
}
|
||||
return image?.resizedCopy(w: CGFloat(width), h: CGFloat(height))
|
||||
}
|
||||
|
||||
var emojize: Bool {
|
||||
params["emojize"] != "false"
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ extension NSImage {
|
||||
guard let data = newImage.tiffRepresentation,
|
||||
let result = NSImage(data: data)
|
||||
else { return NSImage() }
|
||||
|
||||
result.isTemplate = isTemplate
|
||||
return result
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user