Skip to content

Commit

Permalink
Theme init
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-venugopal committed Apr 30, 2024
1 parent d5653ec commit 3562e43
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 46 deletions.
19 changes: 17 additions & 2 deletions macOS/Source/UI/Effects/AudioUnits/AudioUnitsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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()
}
}

Expand All @@ -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)
}
}
14 changes: 13 additions & 1 deletion macOS/Source/UI/Effects/Filter/BandEditor/FilterBandView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class FilterBandView: NSView {

self.band = band
self.bandIndex = index

}

override func awakeFromNib() {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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(_:))
}

// ------------------------------------------------------------------------
Expand Down Expand Up @@ -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() {
Expand Down
17 changes: 17 additions & 0 deletions macOS/Source/UI/Effects/Filter/FilterUnitViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ class FilterUnitViewController: EffectsUnitViewController {
override func fontSchemeChanged() {

super.fontSchemeChanged()

bandsTableView.reloadAllRows(columns: [0, 2, 3])
filterUnitView.redrawChart()
}

override func colorSchemeChanged() {
Expand Down Expand Up @@ -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()
}
}
1 change: 0 additions & 1 deletion macOS/Source/UI/Effects/Reverb/ReverbUnitView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class ReverbUnitView: NSView {

if let popupMenuCell = reverbSpaceMenu.cell as? EffectsUnitPopupMenuCell {
popupMenuCell.tintColor = newColor
// popupMenuCell.tintColor = systemColorScheme.colorForEffectsUnitState(audioGraphDelegate.reverbUnit.state)
}
}
}
11 changes: 11 additions & 0 deletions macOS/Source/UI/Effects/Reverb/ReverbUnitViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,14 @@ class ReverbUnitViewController: EffectsUnitViewController {
}
}
}

extension ReverbUnitViewController: ThemeInitialization {

func initTheme() {

super.fontSchemeChanged()
super.colorSchemeChanged()

reverbUnitView.updatePopupMenuColor(systemColorScheme.colorForEffectsUnitState(reverbUnit.state))
}
}
5 changes: 2 additions & 3 deletions macOS/Source/UI/Library/Playlists/Playlists.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22689"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22689"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -30,7 +29,7 @@
<rect key="frame" x="0.0" y="0.0" width="480" height="277"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6Qg-wa-NmT" userLabel="Caption Label" customClass="BottomTextLabel" customModule="Aural" customModuleProvider="target">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6Qg-wa-NmT" userLabel="Caption Label" customClass="BottomTextLabel" customModule="Aural" customModuleProvider="target">
<rect key="frame" x="-2" y="249" width="214" height="25"/>
<constraints>
<constraint firstAttribute="height" constant="25" id="BhC-xE-2Qn"/>
Expand All @@ -42,7 +41,7 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qh5-Oc-XC2" userLabel="Tracks summary" customClass="BottomTextLabel" customModule="Aural" customModuleProvider="target">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qh5-Oc-XC2" userLabel="Tracks summary" customClass="BottomTextLabel" customModule="Aural" customModuleProvider="target">
<rect key="frame" x="3" y="5" width="214" height="25"/>
<constraints>
<constraint firstAttribute="height" constant="25" id="Inl-Po-hbL"/>
Expand All @@ -54,7 +53,7 @@
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TpK-re-N34" userLabel="Duration summary" customClass="BottomTextLabel" customModule="Aural" customModuleProvider="target">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TpK-re-N34" userLabel="Duration summary" customClass="BottomTextLabel" customModule="Aural" customModuleProvider="target">
<rect key="frame" x="263" y="5" width="204" height="25"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="U57-F3-x6M"/>
Expand Down Expand Up @@ -541,7 +540,7 @@
<action selector="changeSortOrderAction:" target="KYr-e8-u6v" id="1R9-Fw-wHI"/>
</connections>
</button>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="UTN-VE-T7S">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="UTN-VE-T7S">
<rect key="frame" x="11" y="1" width="86" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Sort order:" id="bVa-pg-Y0h">
Expand Down
22 changes: 22 additions & 0 deletions macOS/Source/UI/Search/SearchViewController+Theming.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
11 changes: 0 additions & 11 deletions macOS/Source/UI/Utils/Extensions/NSTableViewExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,6 @@ extension NSTableView: ColorSchemePropertyChangeReceiver {
// }
}

extension NSTableView: FontSchemeObserver {

func fontSchemeChanged() {
reloadData()
}

func fontChanged(to newFont: PlatformFont, forProperty property: KeyPath<FontScheme, PlatformFont>) {
reloadData()
}
}

extension NSOutlineView {

func isItemSelected(_ item: Any) -> Bool {
Expand Down

0 comments on commit 3562e43

Please sign in to comment.