From 208ee4f98c3a08faf0e35a9033a95d8994ad45d2 Mon Sep 17 00:00:00 2001 From: Louis Pontoise Date: Wed, 26 Aug 2020 23:39:03 +0900 Subject: [PATCH] feat: improve the 3 colored buttons when hovering (closes #516) --- alt-tab-macos.xcodeproj/project.pbxproj | 26 +++++++++++++--- resources/icons/window-controls/close@2x.png | Bin 0 -> 1507 bytes .../icons/window-controls/fullscreen@2x.png | Bin 0 -> 1235 bytes .../icons/window-controls/minimize@2x.png | Bin 0 -> 1146 bytes ...con_to_image.sh => convert_font_to_png.sh} | 0 scripts/convert_svg_to_png.sh | 27 +++++++++++++++++ .../{subset_fonticon.sh => subset_font.sh} | 0 src/api-wrappers/HelperExtensions.swift | 13 ++++++++ src/logic/Screen.swift | 2 +- src/ui/main-window/ThumbnailView.swift | 28 +++++++++++++----- src/ui/main-window/WindowControlView.swift | 24 +++++++++++++++ 11 files changed, 108 insertions(+), 12 deletions(-) create mode 100644 resources/icons/window-controls/close@2x.png create mode 100644 resources/icons/window-controls/fullscreen@2x.png create mode 100644 resources/icons/window-controls/minimize@2x.png rename scripts/{fonticon_to_image.sh => convert_font_to_png.sh} (100%) create mode 100755 scripts/convert_svg_to_png.sh rename scripts/{subset_fonticon.sh => subset_font.sh} (100%) create mode 100644 src/ui/main-window/WindowControlView.swift diff --git a/alt-tab-macos.xcodeproj/project.pbxproj b/alt-tab-macos.xcodeproj/project.pbxproj index 3a28697bf..2cad42128 100644 --- a/alt-tab-macos.xcodeproj/project.pbxproj +++ b/alt-tab-macos.xcodeproj/project.pbxproj @@ -15,8 +15,12 @@ BF0C829583ED47E458528F3A /* accessibility@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BF0C889529FF19620EDAC295 /* accessibility@2x.png */; }; BF0C83E902F75A97E8FD374A /* menubar-2@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BF0C8D3333653ACAEF730DD8 /* menubar-2@2x.png */; }; BF0C8406805BDEC5B69E8803 /* screen-recording@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BF0C8E25373671B528AD448D /* screen-recording@2x.png */; }; + BF0C8477850829E15FD4DD43 /* close@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BF0C8F9CE1699644A22EAF2C /* close@2x.png */; }; BF0C852D28E458CDD6FA3E44 /* app.icns in Resources */ = {isa = PBXBuildFile; fileRef = BF0C84E11784B3B0900D0963 /* app.icns */; }; + BF0C89DF22C7B7D0C27DA2A4 /* WindowControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF0C884157B87BF0E17EF7F8 /* WindowControlView.swift */; }; BF0C8C9CA44285E493918A74 /* menubar-3@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BF0C8E54658B4DAEA0528200 /* menubar-3@2x.png */; }; + BF0C8CB668FFABBCA23880B6 /* minimize@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BF0C817D9C335EE4A0536601 /* minimize@2x.png */; }; + BF0C8F80281B50D57C95ECCF /* fullscreen@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BF0C83BD867F6A874F9953C9 /* fullscreen@2x.png */; }; BF0C8FA2D756D3258E3A16B6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = BF0C81DF55C6B0A279CE0FE1 /* Localizable.strings */; }; D04BA004884A273D4D2D3EF1 /* HelperExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BAD91161791D42FEC4A60 /* HelperExtensions.swift */; }; D04BA0182F4734A5C8BB63DC /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D04BA5461DAEE9B5350C3020 /* Localizable.strings */; }; @@ -124,13 +128,17 @@ 481FE54624D2D387001032F1 /* alt-tab-macos-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "alt-tab-macos-Bridging-Header.h"; sourceTree = ""; }; 59DD4BE63D42EEFF1182BA7F /* Pods-alt-tab-macos.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-alt-tab-macos.release.xcconfig"; path = "Target Support Files/Pods-alt-tab-macos/Pods-alt-tab-macos.release.xcconfig"; sourceTree = ""; }; 672F94799CC7C90282AEB3EA /* Pods-alt-tab-macos.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-alt-tab-macos.debug.xcconfig"; path = "Target Support Files/Pods-alt-tab-macos/Pods-alt-tab-macos.debug.xcconfig"; sourceTree = ""; }; + BF0C817D9C335EE4A0536601 /* minimize@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "minimize@2x.png"; sourceTree = ""; }; BF0C81B8A30416D774B5B60E /* fullscreen.svg */ = {isa = PBXFileReference; lastKnownFileType = file.svg; path = fullscreen.svg; sourceTree = ""; }; BF0C81C1B55A0519C3272B09 /* close.svg */ = {isa = PBXFileReference; lastKnownFileType = file.svg; path = close.svg; sourceTree = ""; }; BF0C828AF7BCC4F47E70B28F /* menubar-2.svg */ = {isa = PBXFileReference; lastKnownFileType = file.svg; path = "menubar-2.svg"; sourceTree = ""; }; BF0C833D471343CEA3DEFE56 /* icon_512x512@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_512x512@2x.png"; sourceTree = ""; }; + BF0C83BD867F6A874F9953C9 /* fullscreen@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fullscreen@2x.png"; sourceTree = ""; }; BF0C843C2EDF4EF3A7A2C64A /* app.svg */ = {isa = PBXFileReference; lastKnownFileType = file.svg; path = app.svg; sourceTree = ""; }; BF0C84E11784B3B0900D0963 /* app.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = app.icns; sourceTree = ""; }; + BF0C86370093A080DD5974D8 /* convert_svg_to_png.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = convert_svg_to_png.sh; sourceTree = ""; }; BF0C87B913292EE53EDE4220 /* menubar-1.svg */ = {isa = PBXFileReference; lastKnownFileType = file.svg; path = "menubar-1.svg"; sourceTree = ""; }; + BF0C884157B87BF0E17EF7F8 /* WindowControlView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowControlView.swift; sourceTree = ""; }; BF0C889529FF19620EDAC295 /* accessibility@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "accessibility@2x.png"; sourceTree = ""; }; BF0C88BF67CF4D71002A60EB /* menubar-1@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "menubar-1@2x.png"; sourceTree = ""; }; BF0C88D6043B83B535BEAAA2 /* no */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = no; path = Localizable.strings; sourceTree = ""; }; @@ -140,6 +148,7 @@ BF0C8E54658B4DAEA0528200 /* menubar-3@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "menubar-3@2x.png"; sourceTree = ""; }; BF0C8F0D1F5E9980C2E1A073 /* no */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = no; path = InfoPlist.strings; sourceTree = ""; }; BF0C8F88F4326C82F16FD738 /* minimize.svg */ = {isa = PBXFileReference; lastKnownFileType = file.svg; path = minimize.svg; sourceTree = ""; }; + BF0C8F9CE1699644A22EAF2C /* close@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "close@2x.png"; sourceTree = ""; }; C0712B3BEA2B3780398C0999 /* Pods_alt_tab_macos.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_alt_tab_macos.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D04BA015A45DE7AFDC9794FE /* Window.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Window.swift; sourceTree = ""; }; D04BA03200F5A8FC0CD03607 /* CGWindowID.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGWindowID.swift; sourceTree = ""; }; @@ -162,7 +171,7 @@ D04BA123744B0C27E9F54B05 /* codesign_sparkle_embedded_apps.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = codesign_sparkle_embedded_apps.sh; sourceTree = ""; }; D04BA18724DC58FA95DB33DB /* Podfile.lock */ = {isa = PBXFileReference; lastKnownFileType = file.lock; path = Podfile.lock; sourceTree = ""; }; D04BA18B55AA6C9EE41985D0 /* Contributing.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = Contributing.md; sourceTree = ""; }; - D04BA19E22F2B73DB785E5DB /* subset_fonticon.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = subset_fonticon.sh; sourceTree = ""; }; + D04BA19E22F2B73DB785E5DB /* subset_font.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = subset_font.sh; sourceTree = ""; }; D04BA1B438BF3E65044D1138 /* ControlsTab.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlsTab.swift; sourceTree = ""; }; D04BA1D80F4EEF2A91BAD29C /* release.config.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = release.config.js; sourceTree = ""; }; D04BA1DF8CAB2FAB7FE9244B /* ThumbnailFontIconView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThumbnailFontIconView.swift; sourceTree = ""; }; @@ -297,7 +306,7 @@ D04BACE22DC907F03D193075 /* GeneralTab.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralTab.swift; sourceTree = ""; }; D04BACEE8D430B8CAAD8C4CD /* BoldLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoldLabel.swift; sourceTree = ""; }; D04BAD1297730B191E96E7FE /* ThumbnailTitleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThumbnailTitleView.swift; sourceTree = ""; }; - D04BAD19B495AC18AC782A39 /* fonticon_to_image.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = fonticon_to_image.sh; sourceTree = ""; }; + D04BAD19B495AC18AC782A39 /* convert_font_to_png.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = convert_font_to_png.sh; sourceTree = ""; }; D04BAD215A8F61F2D9952181 /* Introduction.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = Introduction.md; sourceTree = ""; }; D04BAD241A6928F45355B315 /* es */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = es; path = Localizable.strings; sourceTree = ""; }; D04BAD2A5EFA477F1BC436B4 /* import_certificate_into_new_keychain.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = import_certificate_into_new_keychain.sh; sourceTree = ""; }; @@ -418,6 +427,9 @@ BF0C81C1B55A0519C3272B09 /* close.svg */, BF0C8F88F4326C82F16FD738 /* minimize.svg */, BF0C81B8A30416D774B5B60E /* fullscreen.svg */, + BF0C8F9CE1699644A22EAF2C /* close@2x.png */, + BF0C817D9C335EE4A0536601 /* minimize@2x.png */, + BF0C83BD867F6A874F9953C9 /* fullscreen@2x.png */, ); path = "window-controls"; sourceTree = ""; @@ -699,6 +711,7 @@ D04BA1DF8CAB2FAB7FE9244B /* ThumbnailFontIconView.swift */, D04BA258B56193958D60978A /* ThumbnailView.swift */, D04BAA998119CAA8B70A2B67 /* ThumbnailsView.swift */, + BF0C884157B87BF0E17EF7F8 /* WindowControlView.swift */, ); path = "main-window"; sourceTree = ""; @@ -723,7 +736,7 @@ D04BAD6700415D6F7C8B2BEE /* travis.sh */, D04BA81B25C166EFB3223639 /* extract_l10n_strings.sh */, D04BA4FB0047656BEA21F1BE /* codesign */, - D04BA19E22F2B73DB785E5DB /* subset_fonticon.sh */, + D04BA19E22F2B73DB785E5DB /* subset_font.sh */, D04BA48E6F24E0948C4CB4F7 /* import_l10n_strings_from_poeditor.sh */, D04BAA5ECAE8BB8F8656DEDF /* update_contributors.sh */, D04BAD65AA870A49D2F89DBC /* ensure_generated_files_are_up_to_date.sh */, @@ -731,8 +744,9 @@ D04BAAE6E6823304D66B74F8 /* update_website.sh */, D04BA7A758026814667273DC /* convert_iconset_to_icns.sh */, D04BA6ED38651224DB117A5A /* upload_symbols_to_appcenter.sh */, - D04BAD19B495AC18AC782A39 /* fonticon_to_image.sh */, + D04BAD19B495AC18AC782A39 /* convert_font_to_png.sh */, D04BA59FD487D0DEBBA66A94 /* createicns */, + BF0C86370093A080DD5974D8 /* convert_svg_to_png.sh */, ); path = scripts; sourceTree = ""; @@ -1120,6 +1134,9 @@ BF0C8C9CA44285E493918A74 /* menubar-3@2x.png in Resources */, BF0C829583ED47E458528F3A /* accessibility@2x.png in Resources */, BF0C8406805BDEC5B69E8803 /* screen-recording@2x.png in Resources */, + BF0C8477850829E15FD4DD43 /* close@2x.png in Resources */, + BF0C8CB668FFABBCA23880B6 /* minimize@2x.png in Resources */, + BF0C8F80281B50D57C95ECCF /* fullscreen@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1252,6 +1269,7 @@ D04BADA3F2DAB820D6FC6E75 /* AppCenterApplication.m in Sources */, D04BAA16F21AC41A23DDA63D /* ControlsTab.swift in Sources */, D04BADE4DDF7597749FB13BD /* PreferencesWindow.swift in Sources */, + BF0C89DF22C7B7D0C27DA2A4 /* WindowControlView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/resources/icons/window-controls/close@2x.png b/resources/icons/window-controls/close@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..ad115dbee853cc376dab2e82f238dddd97a98708 GIT binary patch literal 1507 zcmV<91swW`P)_*<>wm^chnBvD0FO6jnE2y-}T;y`EO+4YHx4G_w+Gic-nScH{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}K>l$mMP=YOTb6o0+k`mq22002ovPDHLkV1i;YKn4H+ literal 0 HcmV?d00001 diff --git a/resources/icons/window-controls/minimize@2x.png b/resources/icons/window-controls/minimize@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..4065bd44783a698dc62c4b597ba3683744a85961 GIT binary patch literal 1146 zcmV-=1cm#FP)v0dGPIlT;!6k33?Re2(Sy-07L=>g*(8o;%>yz z-1V;0_kz_tSDv)s?{9kc8mH$$PXNhe5_}&#D;T4wgE$uA7%CMdiU266$mMF%|M>Zn zw`TvBfvGD8vq92c0M1$~$!u0hr3KHdY&eRbTvkd&a7rGP3p?(PelF*5t2Qvd>+g-H zM>?}YrVZqYv1-OSC>Co*6s`qQd2|2U;}4%`U}B)>Wi{?mxr{>TJu+9UwS?++e2Q6Cq8 zdtdiPoV%HKkn!oz1A?WrT=yjm5Zg4vYrW9 zEGc1#!{~eUu|`L{G} zK>#z;3h3a@zR^z>&NY2zY&|(vQX3tMBK>)CvX(4QOR=Qn^NLd)4E_zzES_Js3;FZY zeZIfZ|5D&oIwN#;)NZe}5QZ>2t5hl|$oZXpqvw`e_t-W_6}dln=!7B{Mc9{4*E*R- zGqDWL)r!pATqAlvV0eGwJ72YdI=_7JQetbSaz@azKu^7yunENos0vPNwY^%c`B0G| zqg<*VwUt;?BRDb8eE{PfRiPJU56}+8z$`GX%5V~IX#1&=$<;pdKaU8O{#-jKN&o-= M07*qoM6N<$f|LpxmjD0& literal 0 HcmV?d00001 diff --git a/scripts/fonticon_to_image.sh b/scripts/convert_font_to_png.sh similarity index 100% rename from scripts/fonticon_to_image.sh rename to scripts/convert_font_to_png.sh diff --git a/scripts/convert_svg_to_png.sh b/scripts/convert_svg_to_png.sh new file mode 100755 index 000000000..c377b2841 --- /dev/null +++ b/scripts/convert_svg_to_png.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -exu + +# needed because of macOS SIP (see https://stackoverflow.com/a/35570229) +export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib" + +currentDir="$(pwd)" +size=16 + +function convert() { + # magick convert \ + # -background none \ + # -density 144 \ + # -resize 24x24 \ + # "resources/icons/window-controls/$1.svg" \ + # "resources/icons/window-controls/$1-magik.png" + /Applications/Inkscape.app/Contents/Resources/bin/inkscape \ + -z \ + -w "$((size * 2))" -h "$((size * 2))" \ + "$currentDir/resources/icons/window-controls/$1.svg" \ + -e "$currentDir/resources/icons/window-controls/$1@2x.png" +} + +convert "close" +convert "fullscreen" +convert "minimize" diff --git a/scripts/subset_fonticon.sh b/scripts/subset_font.sh similarity index 100% rename from scripts/subset_fonticon.sh rename to scripts/subset_font.sh diff --git a/src/api-wrappers/HelperExtensions.swift b/src/api-wrappers/HelperExtensions.swift index 91bb9f0ca..50b2e885b 100644 --- a/src/api-wrappers/HelperExtensions.swift +++ b/src/api-wrappers/HelperExtensions.swift @@ -158,4 +158,17 @@ extension NSImage { img.unlockFocus() return img } + + func tinted(_ tint: NSColor) -> NSImage { + let dimmed = copy() as! NSImage + let scaling = Screen.withMouse()?.backingScaleFactor ?? 1 + let scaledSize = NSSize(width: (size.width * scaling).rounded(), height: (size.height * scaling).rounded()) + dimmed.size = scaledSize + dimmed.lockFocus() + tint.set() + let imageRect = NSRect(origin: .zero, size: scaledSize) + imageRect.fill(using: .sourceAtop) + dimmed.unlockFocus() + return dimmed + } } diff --git a/src/logic/Screen.swift b/src/logic/Screen.swift index 7b1967273..fd8efd022 100644 --- a/src/logic/Screen.swift +++ b/src/logic/Screen.swift @@ -14,7 +14,7 @@ class Screen { } } - private static func withMouse() -> NSScreen? { + static func withMouse() -> NSScreen? { return NSScreen.screens.first { NSMouseInRect(NSEvent.mouseLocation, $0.frame, false) } } diff --git a/src/ui/main-window/ThumbnailView.swift b/src/ui/main-window/ThumbnailView.swift index 860c19338..0601d0b8e 100644 --- a/src/ui/main-window/ThumbnailView.swift +++ b/src/ui/main-window/ThumbnailView.swift @@ -10,9 +10,9 @@ class ThumbnailView: NSStackView { var hiddenIcon = ThumbnailFontIconView(.circledSlashSign) var spaceIcon = ThumbnailFontIconView(.circledNumber0) var dockLabelIcon = ThumbnailFilledFontIconView(ThumbnailFontIconView(.filledCircledNumber0, (Preferences.fontIconSize * 0.7).rounded(), NSColor(srgbRed: 1, green: 0.30, blue: 0.25, alpha: 1), nil), NSColor.white, true) - var closeIcon = ThumbnailFilledFontIconView(ThumbnailFontIconView(.filledCircledMultiplySign, Preferences.fontIconSize, NSColor(srgbRed: 1, green: 0.35, blue: 0.32, alpha: 1), nil), NSColor(srgbRed: 0.64, green: 0.03, blue: 0.02, alpha: 1)) - var minimizeIcon = ThumbnailFilledFontIconView(ThumbnailFontIconView(.filledCircledMinusSign, Preferences.fontIconSize, NSColor(srgbRed: 0.91, green: 0.75, blue: 0.16, alpha: 1), nil), NSColor(srgbRed: 0.71, green: 0.55, blue: 0.09, alpha: 1)) - var maximizeIcon = ThumbnailFilledFontIconView(ThumbnailFontIconView(.filledCircledPlusSign, Preferences.fontIconSize, NSColor(srgbRed: 0.32, green: 0.76, blue: 0.17, alpha: 1), nil), NSColor(srgbRed: 0.04, green: 0.39, blue: 0.02, alpha: 1)) + var closeIcon = WindowControlView("close", 16) + var minimizeIcon = WindowControlView("minimize", 16) + var maximizeIcon = WindowControlView("fullscreen", 16) var hStackView: NSStackView! var mouseUpCallback: (() -> Void)! var mouseMovedCallback: (() -> Void)! @@ -54,11 +54,11 @@ class ThumbnailView: NSStackView { thumbnail.addSubview(closeIcon, positioned: .above, relativeTo: nil) thumbnail.addSubview(minimizeIcon, positioned: .above, relativeTo: nil) thumbnail.addSubview(maximizeIcon, positioned: .above, relativeTo: nil) - let windowsControlSpacing = CGFloat(3) [closeIcon, minimizeIcon, maximizeIcon].forEach { - $0.topAnchor.constraint(equalTo: thumbnail.topAnchor, constant: 1).isActive = true + $0.topAnchor.constraint(equalTo: thumbnail.topAnchor, constant: 2).isActive = true } - closeIcon.leftAnchor.constraint(equalTo: thumbnail.leftAnchor).isActive = true + closeIcon.leftAnchor.constraint(equalTo: thumbnail.leftAnchor, constant: 3).isActive = true + let windowsControlSpacing = CGFloat(6) minimizeIcon.leftAnchor.constraint(equalTo: closeIcon.rightAnchor, constant: windowsControlSpacing).isActive = true maximizeIcon.leftAnchor.constraint(equalTo: minimizeIcon.rightAnchor, constant: windowsControlSpacing).isActive = true [closeIcon, minimizeIcon, maximizeIcon].forEach { $0.isHidden = true } @@ -192,11 +192,25 @@ class ThumbnailView: NSStackView { if !isHighlighted { mouseMovedCallback() } + hoverWindowControls() + } + + func hoverWindowControls() { + let controls = [closeIcon, minimizeIcon, maximizeIcon] + if let target = thumbnail.hitTest(convert(window!.convertPoint(fromScreen: NSEvent.mouseLocation), from: nil)), + target is NSImageView { + if let control = (controls.first { $0 == target }) { + control.hovered(true) + controls.filter { $0 != control }.forEach { $0.hovered(false) } + } else { + controls.forEach { $0.hovered(false) } + } + } } override func mouseUp(with event: NSEvent) { if event.clickCount >= 1 { - let target = thumbnail.hitTest(convert(event.locationInWindow, from: nil))?.superview + let target = thumbnail.hitTest(convert(event.locationInWindow, from: nil)) if target == closeIcon { window_!.close() } else if target == minimizeIcon { diff --git a/src/ui/main-window/WindowControlView.swift b/src/ui/main-window/WindowControlView.swift new file mode 100644 index 000000000..be5312cb9 --- /dev/null +++ b/src/ui/main-window/WindowControlView.swift @@ -0,0 +1,24 @@ +import Cocoa + +class WindowControlView: NSImageView { + var originalImage: NSImage! + var hoveredImage: NSImage! + var size: NSSize! + + convenience init(_ imageName: String, _ size_: Int) { + self.init() + translatesAutoresizingMaskIntoConstraints = false + size = NSSize(width: size_, height: size_) + let image = NSImage.initCopy(imageName) + image.size = size + originalImage = image + hoveredImage = image.tinted(.init(white: 0, alpha: 0.25)) + hovered(false) + } + + func hovered(_ isHovered: Bool) { + image = isHovered ? hoveredImage : originalImage + image!.size = size + frame.size = size + } +}