@@ -185,32 +185,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
185185 private func setupStatusBarIcon( ) {
186186 statusItem = NSStatusBar . system. statusItem ( withLength: NSStatusItem . variableLength)
187187 if let button = statusItem. button {
188- if let originalImage = NSImage ( named: " StatusIcon " ) {
189- let targetSize = NSSize ( width: 16 , height: 16 )
190- let resizedImage = NSImage ( size: targetSize)
191-
192- resizedImage. lockFocus ( )
193- let originalSize = originalImage. size
194- let aspectRatio = originalSize. width / originalSize. height
195-
196- var drawSize = targetSize
197- if aspectRatio > 1 {
198- drawSize. height = targetSize. width / aspectRatio
199- } else {
200- drawSize. width = targetSize. height * aspectRatio
201- }
202-
203- let drawRect = NSRect (
204- x: ( targetSize. width - drawSize. width) / 2 ,
205- y: ( targetSize. height - drawSize. height) / 2 ,
206- width: drawSize. width,
207- height: drawSize. height
208- )
209-
210- originalImage. draw ( in: drawRect)
211- resizedImage. unlockFocus ( )
212- resizedImage. isTemplate = true
213- button. image = resizedImage
188+ if let image = NSImage ( named: " StatusIcon " ) {
189+ let height : CGFloat = 18
190+ let aspect = image. size. width / image. size. height
191+ image. size = NSSize ( width: height * aspect, height: height)
192+ image. isTemplate = true
193+ button. image = image
214194 }
215195 button. toolTip = " MistTray "
216196
0 commit comments