aboutsummaryrefslogtreecommitdiff
path: root/Liquid Glass Bezel/LiquidGlassBezelCollectingSearchObjectView.swift
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-09-04 11:11:37 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-09-04 11:11:37 +0200
commitbb5daa2e90623691a5259700b9d388d2d21f46d3 (patch)
treef5629e81bedc6cdd35ee9a79628997c5e14ffa7c /Liquid Glass Bezel/LiquidGlassBezelCollectingSearchObjectView.swift
parent3dfeb86c5c3b72acc59919c7a198fcf76a54c35c (diff)
Rename to Liquid Glass Bezel, add preferences
Diffstat (limited to 'Liquid Glass Bezel/LiquidGlassBezelCollectingSearchObjectView.swift')
-rw-r--r--Liquid Glass Bezel/LiquidGlassBezelCollectingSearchObjectView.swift38
1 files changed, 38 insertions, 0 deletions
diff --git a/Liquid Glass Bezel/LiquidGlassBezelCollectingSearchObjectView.swift b/Liquid Glass Bezel/LiquidGlassBezelCollectingSearchObjectView.swift
new file mode 100644
index 0000000..a7c8a90
--- /dev/null
+++ b/Liquid Glass Bezel/LiquidGlassBezelCollectingSearchObjectView.swift
@@ -0,0 +1,38 @@
+class LiquidGlassBezelCollectingSearchObjectView: QSCollectingSearchObjectView {
+ override static var cellClass : AnyClass? {
+ get { return BBObjectCell.self }
+ set { super.cellClass = newValue }
+ }
+
+ override func draw(_ rect: NSRect) {
+ var frame = frame
+
+ // These properties aren't available to Swift, so they need to be accessed in this way.
+ let collection = (value(forKey: "collection") as! NSMutableArray)
+ let collecting = (value(forKey: "collecting") as! Bool)
+
+ let count = collection.count
+ if self.currentEditor() == nil && count != 0 {
+ frame.origin = NSZeroPoint
+ cell?.draw(withFrame: frame, in: self)
+ let iconSize = collectionSpace() != 0 ? collectionSpace() : 16
+ let opacity = collecting ? 1.0 : 0.75
+ let totalWidth = iconSize + 2
+ for i in 0..<count {
+ let object = collection.object(at: i) as! QSObject
+ var icon = object.icon()
+ let size = NSMakeSize(16, 16)
+ icon?.size = size
+ let inRect = NSMakeRect(
+ frame.size.width - totalWidth * CGFloat(count - i),
+ frame.origin.y + 2,
+ iconSize,
+ iconSize
+ )
+ icon?.draw(in: inRect, from: rectFromSize(size), operation: .sourceOver, fraction: opacity)
+ }
+ } else {
+ super.draw(rect)
+ }
+ }
+}