-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7117242
commit 45a07d0
Showing
14 changed files
with
298 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.