summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2024-03-17 23:59:03 +0100
committerder richter <der.richter@gmx.de>2024-03-18 20:29:27 +0100
commitd7cc5cdec14b943ad7009376291e6134d2370aab (patch)
treedfb69b2b396b9b1e666dab817b6738abb4d26171
parentef82ef0bb5823e2cc1eb74acb34b4d2315d40369 (diff)
downloadmpv-d7cc5cdec14b943ad7009376291e6134d2370aab.tar.bz2
mpv-d7cc5cdec14b943ad7009376291e6134d2370aab.tar.xz
mac/touchbar: optimise constraint calculation
-rw-r--r--osdep/mac/touch_bar.swift8
1 files changed, 3 insertions, 5 deletions
diff --git a/osdep/mac/touch_bar.swift b/osdep/mac/touch_bar.swift
index daffc4ccb0..39aed1d35b 100644
--- a/osdep/mac/touch_bar.swift
+++ b/osdep/mac/touch_bar.swift
@@ -266,12 +266,10 @@ class TouchBar: NSTouchBar, NSTouchBarDelegate {
func applyConstraintFrom(string: String, identifier: NSTouchBarItem.Identifier) {
guard let text = configs[identifier]?.view as? NSTextField else { return }
- let fString = string.components(separatedBy: .decimalDigits).joined(separator: "0")
- let textField = NSTextField(labelWithString: fString)
- let size = textField.frame.size
-
+ let fullString = string.components(separatedBy: .decimalDigits).joined(separator: "0")
+ let textField = NSTextField(labelWithString: fullString)
let con = NSLayoutConstraint(item: text, attribute: .width, relatedBy: .equal, toItem: nil,
- attribute: .notAnAttribute, multiplier: 1.0, constant: ceil(size.width * 1.1))
+ attribute: .notAnAttribute, multiplier: 1.1, constant: ceil(textField.frame.size.width))
text.addConstraint(con)
configs[identifier]?.constraint = con
}