From 3562e438dee2be47e197ba4b464efa1c4c2ae6ba Mon Sep 17 00:00:00 2001 From: Kartik Venugopal Date: Tue, 30 Apr 2024 03:12:12 +0200 Subject: [PATCH] Theme init --- .../AudioUnits/AudioUnitsViewController.swift | 19 ++++++++-- .../FilterBandEditorDialogController.swift | 19 +++++++--- .../Filter/BandEditor/FilterBandView.swift | 14 +++++++- .../BandEditor/FilterBandViewController.swift | 36 ++++++++++--------- .../Filter/FilterUnitViewController.swift | 17 +++++++++ .../UI/Effects/Reverb/ReverbUnitView.swift | 1 - .../Reverb/ReverbUnitViewController.swift | 11 ++++++ .../Source/UI/Library/Playlists/Playlists.xib | 5 ++- .../SinglePlaylist/PlaylistContainer.xib | 13 ++++--- .../Search/SearchViewController+Theming.swift | 22 ++++++++++++ .../Extensions/NSTableViewExtensions.swift | 11 ------ 11 files changed, 122 insertions(+), 46 deletions(-) diff --git a/macOS/Source/UI/Effects/AudioUnits/AudioUnitsViewController.swift b/macOS/Source/UI/Effects/AudioUnits/AudioUnitsViewController.swift index 698f86b80..e93294a04 100644 --- a/macOS/Source/UI/Effects/AudioUnits/AudioUnitsViewController.swift +++ b/macOS/Source/UI/Effects/AudioUnits/AudioUnitsViewController.swift @@ -187,6 +187,20 @@ class AudioUnitsViewController: NSViewController { } } +extension AudioUnitsViewController: ThemeInitialization { + + func initTheme() { + + tableView.colorSchemeChanged() + + lblSummary.font = systemFontScheme.smallFont + lblSummary.textColor = systemColorScheme.secondaryTextColor + + btnRemove.contentTintColor = systemColorScheme.buttonColor + addAudioUnitMenuIconItem.colorChanged(systemColorScheme.buttonColor) + } +} + extension AudioUnitsViewController: FontSchemeObserver { func fontSchemeChanged() { @@ -200,10 +214,11 @@ extension AudioUnitsViewController: ColorSchemeObserver { func colorSchemeChanged() { - backgroundColorChanged(systemColorScheme.backgroundColor) + tableView.colorSchemeChanged() + btnRemove.contentTintColor = systemColorScheme.buttonColor addAudioUnitMenuIconItem.colorChanged(systemColorScheme.buttonColor) - tableView.reloadDataMaintainingSelection() + lblSummary.textColor = systemColorScheme.secondaryTextColor } diff --git a/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandEditorDialogController.swift b/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandEditorDialogController.swift index 41f74f1f4..026509d15 100644 --- a/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandEditorDialogController.swift +++ b/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandEditorDialogController.swift @@ -44,7 +44,6 @@ class FilterBandEditorDialogController: NSWindowController { colorSchemesManager.registerPropertyObserver(self, forProperty: \.backgroundColor, changeReceiver: rootContainerBox) colorSchemesManager.registerPropertyObserver(self, forProperty: \.buttonColor, handler: buttonColorChanged(_:)) colorSchemesManager.registerPropertyObserver(self, forProperty: \.primaryTextColor, handler: primaryTextColorChanged(_:)) - colorSchemesManager.registerPropertyObserver(self, forProperty: \.secondaryTextColor, handler: bandView.secondaryTextColorChanged(_:)) colorSchemesManager.registerPropertyObserver(self, forProperty: \.captionTextColor, changeReceiver: lblCaption) } @@ -53,13 +52,26 @@ class FilterBandEditorDialogController: NSWindowController { } } +extension FilterBandEditorDialogController: ThemeInitialization { + + func initTheme() { + + lblCaption.font = systemFontScheme.captionFont + lblCaption.textColor = systemColorScheme.captionTextColor + + btnDone.redraw() + + rootContainerBox.fillColor = systemColorScheme.backgroundColor + btnClose.contentTintColor = systemColorScheme.buttonColor + } +} + extension FilterBandEditorDialogController: FontSchemeObserver { func fontSchemeChanged() { lblCaption.font = systemFontScheme.captionFont btnDone.redraw() - bandView.fontSchemeChanged() } } @@ -77,12 +89,9 @@ extension FilterBandEditorDialogController: ColorSchemeObserver { btnClose.contentTintColor = newColor btnDone.redraw() - bandView.buttonColorChanged(newColor) } private func primaryTextColorChanged(_ newColor: PlatformColor) { - btnDone.redraw() - bandView.primaryTextColorChanged(newColor) } } diff --git a/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandView.swift b/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandView.swift index 314b4ee5a..591b2a63f 100644 --- a/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandView.swift +++ b/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandView.swift @@ -72,7 +72,6 @@ class FilterBandView: NSView { self.band = band self.bandIndex = index - } override func awakeFromNib() { @@ -279,6 +278,19 @@ class FilterBandView: NSView { // MARK: Theming + func initTheme() { + + let smallFont = systemFontScheme.smallFont + + functionCaptionLabels.forEach {$0.font = smallFont} + + filterTypeMenu.font = smallFont + presetRangesMenu.font = smallFont + lblFrequencies.font = smallFont + + colorSchemeChanged() + } + func fontSchemeChanged() { let smallFont = systemFontScheme.smallFont diff --git a/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandViewController.swift b/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandViewController.swift index 6e3d9ef24..4c4b9901d 100644 --- a/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandViewController.swift +++ b/macOS/Source/UI/Effects/Filter/BandEditor/FilterBandViewController.swift @@ -11,28 +11,12 @@ import Cocoa class FilterBandViewController: NSViewController { - override var nibName: String? {"FilterBand"} - - static func create(band: FilterBand, at index: Int, withButtonAction action: Selector, andTarget target: AnyObject) -> FilterBandViewController { - - let controller = FilterBandViewController() - controller.forceLoadingOfView() - - controller.initialize(band: band, at: index, withButtonAction: action, andTarget: target) - return controller - } - - // ------------------------------------------------------------------------ - // MARK: UI fields @IBOutlet weak var bandView: FilterBandView! var band: FilterBand {bandView.band} - // TODO: -// var bandState: EffectsUnitState {} - private lazy var messenger: Messenger = Messenger(for: self) private func initialize(band: FilterBand, at index: Int, withButtonAction action: Selector, andTarget target: AnyObject) { @@ -43,9 +27,15 @@ class FilterBandViewController: NSViewController { super.viewDidLoad() + fontSchemesManager.registerObserver(self) + colorSchemesManager.registerSchemeObserver(self) colorSchemesManager.registerPropertyObserver(self, forProperties: [\.activeControlColor, \.inactiveControlColor, \.suppressedControlColor], handler: unitStateColorChanged(_:)) + + colorSchemesManager.registerPropertyObserver(self, forProperty: \.buttonColor, handler: bandView.buttonColorChanged(_:)) + colorSchemesManager.registerPropertyObserver(self, forProperty: \.primaryTextColor, handler: bandView.primaryTextColorChanged(_:)) + colorSchemesManager.registerPropertyObserver(self, forProperty: \.secondaryTextColor, handler: bandView.secondaryTextColorChanged(_:)) } // ------------------------------------------------------------------------ @@ -86,6 +76,20 @@ class FilterBandViewController: NSViewController { } } +extension FilterBandViewController: ThemeInitialization { + + func initTheme() { + bandView.initTheme() + } +} + +extension FilterBandViewController: FontSchemeObserver { + + func fontSchemeChanged() { + bandView.fontSchemeChanged() + } +} + extension FilterBandViewController: ColorSchemeObserver { func colorSchemeChanged() { diff --git a/macOS/Source/UI/Effects/Filter/FilterUnitViewController.swift b/macOS/Source/UI/Effects/Filter/FilterUnitViewController.swift index 61949dff7..6059355d5 100644 --- a/macOS/Source/UI/Effects/Filter/FilterUnitViewController.swift +++ b/macOS/Source/UI/Effects/Filter/FilterUnitViewController.swift @@ -226,7 +226,9 @@ class FilterUnitViewController: EffectsUnitViewController { override func fontSchemeChanged() { super.fontSchemeChanged() + bandsTableView.reloadAllRows(columns: [0, 2, 3]) + filterUnitView.redrawChart() } override func colorSchemeChanged() { @@ -289,3 +291,18 @@ class FilterUnitViewController: EffectsUnitViewController { filterUnitView.redrawChart() } } + +extension FilterUnitViewController: ThemeInitialization { + + func initTheme() { + + super.fontSchemeChanged() + super.colorSchemeChanged() + + buttonColorChanged(systemColorScheme.buttonColor) + lblSummary.textColor = systemColorScheme.secondaryTextColor + + bandsTableView.colorSchemeChanged() + filterUnitView.redrawChart() + } +} diff --git a/macOS/Source/UI/Effects/Reverb/ReverbUnitView.swift b/macOS/Source/UI/Effects/Reverb/ReverbUnitView.swift index 89f4a64d3..6facac74e 100644 --- a/macOS/Source/UI/Effects/Reverb/ReverbUnitView.swift +++ b/macOS/Source/UI/Effects/Reverb/ReverbUnitView.swift @@ -78,7 +78,6 @@ class ReverbUnitView: NSView { if let popupMenuCell = reverbSpaceMenu.cell as? EffectsUnitPopupMenuCell { popupMenuCell.tintColor = newColor -// popupMenuCell.tintColor = systemColorScheme.colorForEffectsUnitState(audioGraphDelegate.reverbUnit.state) } } } diff --git a/macOS/Source/UI/Effects/Reverb/ReverbUnitViewController.swift b/macOS/Source/UI/Effects/Reverb/ReverbUnitViewController.swift index b0dc47cf6..abc513156 100644 --- a/macOS/Source/UI/Effects/Reverb/ReverbUnitViewController.swift +++ b/macOS/Source/UI/Effects/Reverb/ReverbUnitViewController.swift @@ -104,3 +104,14 @@ class ReverbUnitViewController: EffectsUnitViewController { } } } + +extension ReverbUnitViewController: ThemeInitialization { + + func initTheme() { + + super.fontSchemeChanged() + super.colorSchemeChanged() + + reverbUnitView.updatePopupMenuColor(systemColorScheme.colorForEffectsUnitState(reverbUnit.state)) + } +} diff --git a/macOS/Source/UI/Library/Playlists/Playlists.xib b/macOS/Source/UI/Library/Playlists/Playlists.xib index 2d40584d5..a3cb151db 100644 --- a/macOS/Source/UI/Library/Playlists/Playlists.xib +++ b/macOS/Source/UI/Library/Playlists/Playlists.xib @@ -1,8 +1,7 @@ - + - - + diff --git a/macOS/Source/UI/Library/Playlists/SinglePlaylist/PlaylistContainer.xib b/macOS/Source/UI/Library/Playlists/SinglePlaylist/PlaylistContainer.xib index 6705a937c..4ecc9c759 100644 --- a/macOS/Source/UI/Library/Playlists/SinglePlaylist/PlaylistContainer.xib +++ b/macOS/Source/UI/Library/Playlists/SinglePlaylist/PlaylistContainer.xib @@ -1,8 +1,7 @@ - + - - + @@ -30,7 +29,7 @@ - + @@ -42,7 +41,7 @@ - + @@ -54,7 +53,7 @@ - + @@ -541,7 +540,7 @@ - + diff --git a/macOS/Source/UI/Search/SearchViewController+Theming.swift b/macOS/Source/UI/Search/SearchViewController+Theming.swift index 8a0bb34a9..52788ac94 100644 --- a/macOS/Source/UI/Search/SearchViewController+Theming.swift +++ b/macOS/Source/UI/Search/SearchViewController+Theming.swift @@ -10,6 +10,28 @@ import AppKit +extension SearchViewController: ThemeInitialization { + + func initTheme() { + + searchField.font = systemFontScheme.normalFont + + captionLabels.forEach { + $0.font = systemFontScheme.smallFont + } + + checkBoxes.forEach { + $0.font = systemFontScheme.smallFont + } + + btnComparisonType.font = systemFontScheme.smallFont + + lblSummary.font = systemFontScheme.normalFont + + resultsTable.reloadDataMaintainingSelection() + } +} + extension SearchViewController: FontSchemeObserver { func fontSchemeChanged() { diff --git a/macOS/Source/UI/Utils/Extensions/NSTableViewExtensions.swift b/macOS/Source/UI/Utils/Extensions/NSTableViewExtensions.swift index d1fd6992d..b176ce966 100644 --- a/macOS/Source/UI/Utils/Extensions/NSTableViewExtensions.swift +++ b/macOS/Source/UI/Utils/Extensions/NSTableViewExtensions.swift @@ -202,17 +202,6 @@ extension NSTableView: ColorSchemePropertyChangeReceiver { // } } -extension NSTableView: FontSchemeObserver { - - func fontSchemeChanged() { - reloadData() - } - - func fontChanged(to newFont: PlatformFont, forProperty property: KeyPath) { - reloadData() - } -} - extension NSOutlineView { func isItemSelected(_ item: Any) -> Bool {