From ee307259c4d82b0dbc160261e8a73f0cd4db7cfa Mon Sep 17 00:00:00 2001 From: Louis Pontoise Date: Sat, 9 May 2020 18:58:10 +0900 Subject: [PATCH] feat: add preference: fade out animation for the main ui (closes #234) --- resources/l10n/Localizable.strings | 3 +++ src/logic/Preferences.swift | 2 ++ src/ui/main-window/ThumbnailsPanel.swift | 6 +++++- src/ui/preferences-window/tabs/AppearanceTab.swift | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/l10n/Localizable.strings b/resources/l10n/Localizable.strings index ecd5f2bb..2114d772 100644 --- a/resources/l10n/Localizable.strings +++ b/resources/l10n/Localizable.strings @@ -64,6 +64,9 @@ /* No comment provided by engineer. */ "Don’t check for updates periodically" = "Don’t check for updates periodically"; +/* No comment provided by engineer. */ +"Fade out animation:" = "Fade out animation:"; + /* No comment provided by engineer. */ "General" = "General"; diff --git a/src/logic/Preferences.swift b/src/logic/Preferences.swift index 23123e0f..60ed568a 100644 --- a/src/logic/Preferences.swift +++ b/src/logic/Preferences.swift @@ -32,6 +32,7 @@ class Preferences { "appsToShow": "0", "spacesToShow": "0", "screensToShow": "0", + "fadeOutAnimation": "false", "hideSpaceNumberLabels": "false", "startAtLogin": "true", ] @@ -66,6 +67,7 @@ class Preferences { static var showHiddenWindows: Bool { defaults.bool("showHiddenWindows") } static var showTabsAsWindows: Bool { defaults.bool("showTabsAsWindows") } static var windowDisplayDelay: DispatchTimeInterval { DispatchTimeInterval.milliseconds(defaults.int("windowDisplayDelay")) } + static var fadeOutAnimation: Bool { defaults.bool("fadeOutAnimation") } static var hideSpaceNumberLabels: Bool { defaults.bool("hideSpaceNumberLabels") } static var startAtLogin: Bool { defaults.bool("startAtLogin") } diff --git a/src/ui/main-window/ThumbnailsPanel.swift b/src/ui/main-window/ThumbnailsPanel.swift index 11e0639c..6889e402 100644 --- a/src/ui/main-window/ThumbnailsPanel.swift +++ b/src/ui/main-window/ThumbnailsPanel.swift @@ -6,7 +6,7 @@ class ThumbnailsPanel: NSPanel { convenience init() { self.init(contentRect: .zero, styleMask: .utilityWindow, backing: .buffered, defer: true) isFloatingPanel = true - animationBehavior = .none + updateFadeOutAnimation() hidesOnDeactivate = false hasShadow = false titleVisibility = .hidden @@ -20,6 +20,10 @@ class ThumbnailsPanel: NSPanel { setAccessibilitySubrole(.unknown) } + func updateFadeOutAnimation() { + animationBehavior = Preferences.fadeOutAnimation ? .utilityWindow : .none + } + func show() { makeKeyAndOrderFront(nil) thumbnailsView.scrollView.flashScrollers() diff --git a/src/ui/preferences-window/tabs/AppearanceTab.swift b/src/ui/preferences-window/tabs/AppearanceTab.swift index 2516a7a8..bc0ad253 100644 --- a/src/ui/preferences-window/tabs/AppearanceTab.swift +++ b/src/ui/preferences-window/tabs/AppearanceTab.swift @@ -18,6 +18,7 @@ class AppearanceTab: NSViewController, PreferencePane { LabelAndControl.makeLabelWithSlider(NSLocalizedString("Window title font size:", comment: ""), "fontHeight", 0, 64, 11, false, "px"), LabelAndControl.makeLabelWithDropdown(NSLocalizedString("Show on:", comment: ""), "showOnScreen", ShowOnScreenPreference.allCases), LabelAndControl.makeLabelWithSlider(NSLocalizedString("Apparition delay:", comment: ""), "windowDisplayDelay", 0, 2000, 11, false, "ms"), + LabelAndControl.makeLabelWithCheckbox(NSLocalizedString("Fade out animation:", comment: ""), "fadeOutAnimation", extraAction: { _ in App.app.thumbnailsPanel.updateFadeOutAnimation() }), LabelAndControl.makeLabelWithCheckbox(NSLocalizedString("Hide space number labels:", comment: ""), "hideSpaceNumberLabels"), LabelAndControl.makeLabelWithCheckbox(NSLocalizedString("Show standard tabs as windows:", comment: ""), "showTabsAsWindows"), ])