Skip to content

Commit

Permalink
Drag drop view + theming
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-venugopal committed Jan 12, 2025
1 parent 7117242 commit 45a07d0
Show file tree
Hide file tree
Showing 14 changed files with 298 additions and 106 deletions.
12 changes: 12 additions & 0 deletions Aural.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,9 @@
3E9CF7F526A7D36D0068A21B /* ChangeHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E9CF7F426A7D36D0068A21B /* ChangeHistory.swift */; };
3E9D706F27C1DE2F00CAC4F1 /* Devices.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3E9D706E27C1DE2F00CAC4F1 /* Devices.xib */; };
3E9D707127C1E30100CAC4F1 /* DevicesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E9D707027C1E30100CAC4F1 /* DevicesViewController.swift */; };
3E9DA1952D34291B0094D6DE /* TextButtonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E9DA1942D34291B0094D6DE /* TextButtonCell.swift */; };
3E9DA1972D342B080094D6DE /* TextAndImageButtonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E9DA1962D342B080094D6DE /* TextAndImageButtonCell.swift */; };
3E9DA1992D342F6E0094D6DE /* LyricsViewController+Theming.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E9DA1982D342F6E0094D6DE /* LyricsViewController+Theming.swift */; };
3E9E590E25DB6B150064EB5F /* MenuBarAppModeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E58FF25DB6B150064EB5F /* MenuBarAppModeController.swift */; };
3E9E590F25DB6B150064EB5F /* AppModeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E590025DB6B150064EB5F /* AppModeManager.swift */; };
3E9E591025DB6B150064EB5F /* ModularAppModeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E590125DB6B150064EB5F /* ModularAppModeController.swift */; };
Expand Down Expand Up @@ -1963,6 +1966,9 @@
3E9CF7F426A7D36D0068A21B /* ChangeHistory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeHistory.swift; sourceTree = "<group>"; };
3E9D706E27C1DE2F00CAC4F1 /* Devices.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Devices.xib; sourceTree = "<group>"; };
3E9D707027C1E30100CAC4F1 /* DevicesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevicesViewController.swift; sourceTree = "<group>"; };
3E9DA1942D34291B0094D6DE /* TextButtonCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextButtonCell.swift; sourceTree = "<group>"; };
3E9DA1962D342B080094D6DE /* TextAndImageButtonCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextAndImageButtonCell.swift; sourceTree = "<group>"; };
3E9DA1982D342F6E0094D6DE /* LyricsViewController+Theming.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LyricsViewController+Theming.swift"; sourceTree = "<group>"; };
3E9E58FF25DB6B150064EB5F /* MenuBarAppModeController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuBarAppModeController.swift; sourceTree = "<group>"; };
3E9E590025DB6B150064EB5F /* AppModeManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppModeManager.swift; sourceTree = "<group>"; };
3E9E590125DB6B150064EB5F /* ModularAppModeController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModularAppModeController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4015,6 +4021,8 @@
3EAFB616267FF4C200F0DC96 /* EffectsSliderPreviewCell.swift */,
3EF172F426A989BA00BB4556 /* EffectsUnitLabels.swift */,
3EBF293626869A9300D87021 /* EffectsUnitPopupMenuCell.swift */,
3E9DA1942D34291B0094D6DE /* TextButtonCell.swift */,
3E9DA1962D342B080094D6DE /* TextAndImageButtonCell.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -5098,6 +5106,7 @@
3EAF727A2D25B24700E24245 /* LyricsViewController.swift */,
3E57443C2D262104004B5AE7 /* LyricsViewController+Static.swift */,
3E57443A2D261E28004B5AE7 /* LyricsViewController+Timed.swift */,
3E9DA1982D342F6E0094D6DE /* LyricsViewController+Theming.swift */,
3EA21A452D2763B3008B5B21 /* LyricsFileDropView.swift */,
3E719D8C2D28A105000A33B9 /* SheetView */,
3E719D8D2D28A12D000A33B9 /* Utils */,
Expand Down Expand Up @@ -6120,6 +6129,7 @@
3E6C12EF25CEBE8100BF0D07 /* DelayUnitView.swift in Sources */,
3E0218942C23490E00865AC2 /* LegacyHistoryPersistentState.swift in Sources */,
3E02182A2C23490E00865AC2 /* FavoriteTrack.swift in Sources */,
3E9DA1952D34291B0094D6DE /* TextButtonCell.swift in Sources */,
3E6C12F025CEBE8100BF0D07 /* DelayUnitViewController.swift in Sources */,
3E02198C2C23490E00865AC2 /* OrderedSetExtensions.swift in Sources */,
3E0218AD2C23490E00865AC2 /* LibraryPersistentState.swift in Sources */,
Expand Down Expand Up @@ -6158,6 +6168,7 @@
3E0218392C23490E00865AC2 /* FFmpegAudioCodec.swift in Sources */,
3E02195E2C23490E00865AC2 /* SearchType.swift in Sources */,
3E0218D52C23490E00865AC2 /* PlaybackContextProtocol.swift in Sources */,
3E9DA1972D342B080094D6DE /* TextAndImageButtonCell.swift in Sources */,
3E7E9F4E2C66B1AF0011DE8E /* WaveformWindowController.swift in Sources */,
3E02189A2C23490E00865AC2 /* MenuBarPlayerUIPersistentState.swift in Sources */,
3E02195C2C23490E00865AC2 /* SearchResults.swift in Sources */,
Expand Down Expand Up @@ -6295,6 +6306,7 @@
3ECF71A52B74EDE000FDB69B /* CompactPlayQueueContainer.swift in Sources */,
3E0218262C23490E00865AC2 /* Favorite.swift in Sources */,
3EB3A62126A773350060487C /* FontSizeStepper.swift in Sources */,
3E9DA1992D342F6E0094D6DE /* LyricsViewController+Theming.swift in Sources */,
3ECFA87F2AE1EB29001096DC /* EffectsContainerViewController.swift in Sources */,
3E91932C25E0D96A00F30F81 /* FontSchemeFontsViewController.swift in Sources */,
3E3579D026835A6A009522A0 /* GenericPresetPopupMenuController.swift in Sources */,
Expand Down
8 changes: 3 additions & 5 deletions Source/Core/TrackIO/TrackReader+Lyrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import LyricsUI

extension TrackReader {

func loadExternalLyrics(for track: Track) {
func loadExternalLyrics(for track: Track, immediate: Bool) {

guard track.externalTimedLyrics == nil else {return}
guard track.externalOrEmbeddedTimedLyrics == nil else {return}

// Load lyrics from previously assigned external file
if let externalLyricsFile = track.metadata.externalLyricsFile, externalLyricsFile.exists,
Expand All @@ -45,7 +45,7 @@ extension TrackReader {
// Online search
guard onlineSearchEnabled else {return}

Task.detached(priority: .userInitiated) {
Task.detached(priority: immediate ? .userInitiated : .utility) {

guard let bestLyrics = await LyricsSearchService().searchLyrics(for: track) else {return}

Expand Down Expand Up @@ -112,8 +112,6 @@ extension TrackReader {

func searchForLyricsOnline(for track: Track, uiUpdateBlock: @escaping (TimedLyrics) -> Void) async {

guard onlineSearchEnabled else {return}

Task.detached(priority: .userInitiated) {

guard let bestLyrics = await LyricsSearchService().searchLyrics(for: track) else {return}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/TrackIO/TrackReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class TrackReader {
DispatchQueue.global(qos: immediate ? .userInteractive : .utility).async {

self.loadArt(for: track)
self.loadExternalLyrics(for: track)
self.loadExternalLyrics(for: track, immediate: immediate)
}
}

Expand Down
44 changes: 44 additions & 0 deletions Source/UI/Effects/Views/TextAndImageButtonCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// TextAndImageButtonCell.swift
// Aural
//
// Copyright © 2025 Kartik Venugopal. All rights reserved.
//
// This software is licensed under the MIT software license.
// See the file "LICENSE" in the project root directory for license terms.
//

import AppKit

@IBDesignable
class TextAndImageButtonCell: NSButtonCell {

var rectRadius: CGFloat {4}

@IBInspectable var imgWidth: Int = 14
@IBInspectable var imgHeight: Int = 14

var borderColor: NSColor {systemColorScheme.buttonColor}
var titleFont: NSFont {systemFontScheme.normalFont}
var titleColor: NSColor {systemColorScheme.primaryTextColor}

override func draw(withFrame cellFrame: NSRect, in controlView: NSView) {

NSBezierPath.strokeRoundedRect(cellFrame.insetBy(dx: 0.5, dy: 0.5), radius: rectRadius, withColor: borderColor)

title.drawCentered(in: cellFrame,
withFont: titleFont, andColor: titleColor, yOffset: 1)

let imgWidth = CGFloat(self.imgWidth)
let imgHeight = CGFloat(self.imgHeight)

let imgX = cellFrame.maxX - imgWidth - 5
let imgY = cellFrame.maxY - imgHeight - ((cellFrame.height - imgHeight) / 2)

let imgRect = NSMakeRect(imgX, imgY, imgWidth, imgHeight)

if let image = self.image?.tintedWithColor(titleColor) {
image.draw(in: imgRect)
}
}
}
28 changes: 28 additions & 0 deletions Source/UI/Effects/Views/TextButtonCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// TextButtonCell.swift
// Aural
//
// Copyright © 2025 Kartik Venugopal. All rights reserved.
//
// This software is licensed under the MIT software license.
// See the file "LICENSE" in the project root directory for license terms.
//

import AppKit

class TextButtonCell: NSButtonCell {

var rectRadius: CGFloat {4}

var borderColor: NSColor {systemColorScheme.buttonColor}
var titleFont: NSFont {systemFontScheme.normalFont}
var titleColor: NSColor {systemColorScheme.primaryTextColor}

override func drawInterior(withFrame cellFrame: NSRect, in controlView: NSView) {

NSBezierPath.strokeRoundedRect(cellFrame.insetBy(dx: 0.5, dy: 0.5), radius: rectRadius, withColor: borderColor)

title.drawCentered(in: cellFrame,
withFont: titleFont, andColor: titleColor, yOffset: 1)
}
}
7 changes: 3 additions & 4 deletions Source/UI/Library/BuildProgress/LibraryBuildProgress.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="22154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22154"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand All @@ -18,7 +17,7 @@
<windowStyleMask key="styleMask" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="283" y="305" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
<rect key="screenRect" x="0.0" y="0.0" width="3440" height="1415"/>
<view key="contentView" id="gXG-E1-q9p">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down
Loading

0 comments on commit 45a07d0

Please sign in to comment.