]> git.r.bdr.sh - rbdr/Flat-Bezel.qsplugin/commitdiff
Port more files to swift
authorRuben Beltran del Rio <redacted>
Sat, 11 Feb 2023 12:37:20 +0000 (13:37 +0100)
committerRuben Beltran del Rio <redacted>
Sat, 11 Feb 2023 12:37:20 +0000 (13:37 +0100)
Flat Bezel.xcodeproj/project.pbxproj
Flat Bezel/BBFlatBezelInterface.xib
Flat Bezel/BBObjectCell.h [new file with mode: 0644]
Flat Bezel/BBObjectCell.m [moved from Flat Bezel/BBSearchObjectView.m with 84% similarity]
Flat Bezel/BBSearchObjectView.h [deleted file]
Flat Bezel/BackgroundView.swift
Flat Bezel/FlatBezel-Bridging-Header.h
Flat Bezel/FlatBezelCollectingSearchObjectView.swift [new file with mode: 0644]
Flat Bezel/FlatBezelObjectCell.swift [new file with mode: 0644]
Flat Bezel/FlatBezelSearchObjectView.swift [new file with mode: 0644]
Info.plist

index 4ad467799175cded13144baaa964e02388f40144..9b2a19339ae8555e5f2447c801b5942872a1dc58 100644 (file)
@@ -7,20 +7,26 @@
        objects = {
 
 /* Begin PBXBuildFile section */
        objects = {
 
 /* Begin PBXBuildFile section */
-               42447D7D19407DA00077B4B2 /* BBSearchObjectView.m in Sources */ = {isa = PBXBuildFile; fileRef = 42447D7C19407DA00077B4B2 /* BBSearchObjectView.m */; };
+               42447D7D19407DA00077B4B2 /* BBObjectCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42447D7C19407DA00077B4B2 /* BBObjectCell.m */; };
                42663058193CC1FA00C0DD31 /* BBFlatBezelInterface.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42663057193CC1FA00C0DD31 /* BBFlatBezelInterface.xib */; };
                B576D2F52993FBD400A8B645 /* BackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B576D2F42993FBD400A8B645 /* BackgroundView.swift */; };
                42663058193CC1FA00C0DD31 /* BBFlatBezelInterface.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42663057193CC1FA00C0DD31 /* BBFlatBezelInterface.xib */; };
                B576D2F52993FBD400A8B645 /* BackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B576D2F42993FBD400A8B645 /* BackgroundView.swift */; };
+               B59AD27F2997AC2F006DA797 /* FlatBezelSearchObjectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59AD27E2997AC2F006DA797 /* FlatBezelSearchObjectView.swift */; };
+               B59AD2812997AE4A006DA797 /* FlatBezelCollectingSearchObjectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59AD2802997AE4A006DA797 /* FlatBezelCollectingSearchObjectView.swift */; };
+               B59AD2852997B860006DA797 /* FlatBezelObjectCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59AD2842997B860006DA797 /* FlatBezelObjectCell.swift */; };
                E470B7E31709F3A0000169F2 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E470B7E21709F3A0000169F2 /* Cocoa.framework */; };
                E470B7E91709F3A0000169F2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = E470B7E71709F3A0000169F2 /* InfoPlist.strings */; };
                E470B7F81709F3A0000169F2 /* BBFlatBezelInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = E470B7F71709F3A0000169F2 /* BBFlatBezelInterface.m */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
                E470B7E31709F3A0000169F2 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E470B7E21709F3A0000169F2 /* Cocoa.framework */; };
                E470B7E91709F3A0000169F2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = E470B7E71709F3A0000169F2 /* InfoPlist.strings */; };
                E470B7F81709F3A0000169F2 /* BBFlatBezelInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = E470B7F71709F3A0000169F2 /* BBFlatBezelInterface.m */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
-               42447D7B19407DA00077B4B2 /* BBSearchObjectView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BBSearchObjectView.h; sourceTree = "<group>"; };
-               42447D7C19407DA00077B4B2 /* BBSearchObjectView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BBSearchObjectView.m; sourceTree = "<group>"; };
+               42447D7B19407DA00077B4B2 /* BBObjectCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BBObjectCell.h; sourceTree = "<group>"; };
+               42447D7C19407DA00077B4B2 /* BBObjectCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BBObjectCell.m; sourceTree = "<group>"; };
                42663057193CC1FA00C0DD31 /* BBFlatBezelInterface.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BBFlatBezelInterface.xib; sourceTree = "<group>"; };
                B576D2F42993FBD400A8B645 /* BackgroundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundView.swift; sourceTree = "<group>"; };
                B576D2F62993FD7500A8B645 /* FlatBezel-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FlatBezel-Bridging-Header.h"; sourceTree = "<group>"; };
                42663057193CC1FA00C0DD31 /* BBFlatBezelInterface.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BBFlatBezelInterface.xib; sourceTree = "<group>"; };
                B576D2F42993FBD400A8B645 /* BackgroundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundView.swift; sourceTree = "<group>"; };
                B576D2F62993FD7500A8B645 /* FlatBezel-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FlatBezel-Bridging-Header.h"; sourceTree = "<group>"; };
+               B59AD27E2997AC2F006DA797 /* FlatBezelSearchObjectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlatBezelSearchObjectView.swift; sourceTree = "<group>"; };
+               B59AD2802997AE4A006DA797 /* FlatBezelCollectingSearchObjectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlatBezelCollectingSearchObjectView.swift; sourceTree = "<group>"; };
+               B59AD2842997B860006DA797 /* FlatBezelObjectCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlatBezelObjectCell.swift; sourceTree = "<group>"; };
                E470B7DF1709F3A0000169F2 /* Flat Bezel.qsplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Flat Bezel.qsplugin"; sourceTree = BUILT_PRODUCTS_DIR; };
                E470B7E21709F3A0000169F2 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
                E470B7E61709F3A0000169F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
                E470B7DF1709F3A0000169F2 /* Flat Bezel.qsplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Flat Bezel.qsplugin"; sourceTree = BUILT_PRODUCTS_DIR; };
                E470B7E21709F3A0000169F2 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
                E470B7E61709F3A0000169F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
                        children = (
                                E470B7EA1709F3A0000169F2 /* Configuration */,
                                E470B7E51709F3A0000169F2 /* Supporting Files */,
                        children = (
                                E470B7EA1709F3A0000169F2 /* Configuration */,
                                E470B7E51709F3A0000169F2 /* Supporting Files */,
-                               42447D7B19407DA00077B4B2 /* BBSearchObjectView.h */,
-                               42447D7C19407DA00077B4B2 /* BBSearchObjectView.m */,
+                               42447D7B19407DA00077B4B2 /* BBObjectCell.h */,
+                               42447D7C19407DA00077B4B2 /* BBObjectCell.m */,
                                E470B7F61709F3A0000169F2 /* BBFlatBezelInterface.h */,
                                E470B7F71709F3A0000169F2 /* BBFlatBezelInterface.m */,
                                42663057193CC1FA00C0DD31 /* BBFlatBezelInterface.xib */,
                                B576D2F42993FBD400A8B645 /* BackgroundView.swift */,
                                E470B7F61709F3A0000169F2 /* BBFlatBezelInterface.h */,
                                E470B7F71709F3A0000169F2 /* BBFlatBezelInterface.m */,
                                42663057193CC1FA00C0DD31 /* BBFlatBezelInterface.xib */,
                                B576D2F42993FBD400A8B645 /* BackgroundView.swift */,
+                               B59AD27E2997AC2F006DA797 /* FlatBezelSearchObjectView.swift */,
+                               B59AD2802997AE4A006DA797 /* FlatBezelCollectingSearchObjectView.swift */,
+                               B59AD2842997B860006DA797 /* FlatBezelObjectCell.swift */,
                        );
                        path = "Flat Bezel";
                        sourceTree = "<group>";
                        );
                        path = "Flat Bezel";
                        sourceTree = "<group>";
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               B59AD2812997AE4A006DA797 /* FlatBezelCollectingSearchObjectView.swift in Sources */,
                                B576D2F52993FBD400A8B645 /* BackgroundView.swift in Sources */,
                                B576D2F52993FBD400A8B645 /* BackgroundView.swift in Sources */,
-                               42447D7D19407DA00077B4B2 /* BBSearchObjectView.m in Sources */,
+                               42447D7D19407DA00077B4B2 /* BBObjectCell.m in Sources */,
                                E470B7F81709F3A0000169F2 /* BBFlatBezelInterface.m in Sources */,
                                E470B7F81709F3A0000169F2 /* BBFlatBezelInterface.m in Sources */,
+                               B59AD2852997B860006DA797 /* FlatBezelObjectCell.swift in Sources */,
+                               B59AD27F2997AC2F006DA797 /* FlatBezelSearchObjectView.swift in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index b3039c6cb4ab9ccd2b330743a2bea379672f9ebc..b6fd59e7e635a5834ce69268d53f01490cb2396f 100644 (file)
@@ -28,7 +28,7 @@
                 <rect key="frame" x="0.0" y="0.0" width="608" height="200"/>
                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                 <subviews>
                 <rect key="frame" x="0.0" y="0.0" width="608" height="200"/>
                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                 <subviews>
-                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="68" customClass="BBCollectingSearchObjectView">
+                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="68" customClass="FlatBezelCollectingSearchObjectView" customModule="Flat_Bezel" customModuleProvider="target">
                         <rect key="frame" x="8" y="8" width="184" height="184"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="184" id="SwQ-fC-3aw"/>
                         <rect key="frame" x="8" y="8" width="184" height="184"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="184" id="SwQ-fC-3aw"/>
@@ -38,7 +38,7 @@
                             <outlet property="nextKeyView" destination="69" id="105"/>
                         </connections>
                     </customView>
                             <outlet property="nextKeyView" destination="69" id="105"/>
                         </connections>
                     </customView>
-                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="69" customClass="BBSearchObjectView">
+                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="69" customClass="FlatBezelSearchObjectView" customModule="Flat_Bezel" customModuleProvider="target">
                         <rect key="frame" x="200" y="8" width="184" height="184"/>
                         <constraints>
                             <constraint firstAttribute="width" constant="184" id="O3w-M3-b05"/>
                         <rect key="frame" x="200" y="8" width="184" height="184"/>
                         <constraints>
                             <constraint firstAttribute="width" constant="184" id="O3w-M3-b05"/>
@@ -48,7 +48,7 @@
                             <outlet property="nextKeyView" destination="70" id="106"/>
                         </connections>
                     </customView>
                             <outlet property="nextKeyView" destination="70" id="106"/>
                         </connections>
                     </customView>
-                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="70" customClass="BBCollectingSearchObjectView">
+                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="70" customClass="FlatBezelCollectingSearchObjectView" customModule="Flat_Bezel" customModuleProvider="target">
                         <rect key="frame" x="392" y="8" width="184" height="184"/>
                         <constraints>
                             <constraint firstAttribute="width" constant="184" id="Jbn-VW-sSJ"/>
                         <rect key="frame" x="392" y="8" width="184" height="184"/>
                         <constraints>
                             <constraint firstAttribute="width" constant="184" id="Jbn-VW-sSJ"/>
diff --git a/Flat Bezel/BBObjectCell.h b/Flat Bezel/BBObjectCell.h
new file mode 100644 (file)
index 0000000..3fa67c6
--- /dev/null
@@ -0,0 +1,4 @@
+#import <QSInterface/QSInterface.h>
+
+@interface BBObjectCell : QSObjectCell
+@end
similarity index 84%
rename from Flat Bezel/BBSearchObjectView.m
rename to Flat Bezel/BBObjectCell.m
index 0722e0c25b38e212fb49912cee4c128b8a360666..28e79d27a7e2eaf23b5160323e77614b91692ec0 100644 (file)
@@ -1,45 +1,4 @@
-#import "BBSearchObjectView.h"
-
-@implementation BBSearchObjectView
-+ (Class)cellClass { return [BBObjectCell class]; }
-
-@end
-
-@implementation BBCollectingSearchObjectView
-+ (Class)cellClass { return [BBObjectCell class]; }
-
-- (void)drawRect:(NSRect)rect {
-    NSRect frame = [self frame];
-    NSInteger count = [collection count];
-    if (![self currentEditor] && count) {
-        frame.origin = NSZeroPoint;
-        [[self cell] drawWithFrame:frame inView:self];
-        NSInteger i;
-        CGFloat iconSize = collectionSpace?collectionSpace:16;
-        CGFloat opacity = collecting?1.0:0.75;
-        QSObject *object;
-        CGFloat totalWidth = iconSize + 2;
-        for (i = 0; i<count; i++) {
-            object = [collection objectAtIndex:i];
-            NSImage *icon = [object icon];
-            [icon setSize:QSSize16];
-            [icon drawInRect:NSMakeRect(frame.size.width-totalWidth*(count-i), frame.origin.y+2, iconSize, iconSize) fromRect:rectFromSize([icon size]) operation:NSCompositingOperationSourceOver fraction:opacity];
-        }
-    } else {
-        [super drawRect:rect];
-    }
-}
-
-- (NSRect)textEditorFrame {
-    NSRect titleFrame = [self frame];
-    NSRect editorFrame = NSInsetRect(titleFrame, 8, 8);
-    editorFrame.origin = NSMakePoint(8, 8);
-    editorFrame = NSIntegralRect(editorFrame);
-    return editorFrame;
-}
-
-
-@end
+#import "BBObjectCell.h"
 
 @implementation BBObjectCell
 
 
 @implementation BBObjectCell
 
diff --git a/Flat Bezel/BBSearchObjectView.h b/Flat Bezel/BBSearchObjectView.h
deleted file mode 100644 (file)
index b60a637..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#import <QSInterface/QSInterface.h>
-
-@interface BBSearchObjectView : QSSearchObjectView
-@end
-
-@interface BBCollectingSearchObjectView : QSCollectingSearchObjectView
-@end
-
-@interface BBObjectCell : QSObjectCell
-@end
index 041874a9c33562b26711cd18f77fb626b3691a18..789079808cd74988bd5cc2d59943a9670a3bf895 100644 (file)
@@ -1,24 +1,16 @@
-//
-//  BBBackgroundView.swift
-//  Flat Bezel
-//
-//  Created by Ruben Beltran del Rio on 2/8/23.
-//  Copyright © 2023 BRNBW. All rights reserved.
-//
-
 import Foundation
 import Cocoa
 
 class BackgroundView: QSBezelBackgroundView {
   
   override func draw(_ rect: NSRect) {
 import Foundation
 import Cocoa
 
 class BackgroundView: QSBezelBackgroundView {
   
   override func draw(_ rect: NSRect) {
-    let boundsRect = self.bounds
+    let boundsRect = bounds
     
     let roundRect = NSBezierPath()
     roundRect.appendRoundedRect(boundsRect, xRadius: 8.0, yRadius: 8.0)
     roundRect.addClip()
     
     
     let roundRect = NSBezierPath()
     roundRect.appendRoundedRect(boundsRect, xRadius: 8.0, yRadius: 8.0)
     roundRect.addClip()
     
-    let darkMode = self.effectiveAppearance.name == .darkAqua
+    let darkMode = effectiveAppearance.name == .darkAqua
     if (darkMode) {
       NSColor(red: 0.1, green: 0.1, blue: 0.1, alpha: 0.99).setFill()
     } else {
     if (darkMode) {
       NSColor(red: 0.1, green: 0.1, blue: 0.1, alpha: 0.99).setFill()
     } else {
index f41b12ce88e6ac7d7f9e806fc6ca64450d346e72..f216cf4f54d6f85e4d9d1fe66894d401ec1bf5e5 100644 (file)
@@ -1,2 +1,2 @@
 #import "Quicksilver.pch"
 #import "Quicksilver.pch"
-#import "BBSearchObjectView.h"
+#import "BBObjectCell.h"
diff --git a/Flat Bezel/FlatBezelCollectingSearchObjectView.swift b/Flat Bezel/FlatBezelCollectingSearchObjectView.swift
new file mode 100644 (file)
index 0000000..26586be
--- /dev/null
@@ -0,0 +1,38 @@
+class FlatBezelCollectingSearchObjectView: 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)
+    }
+  }
+}
diff --git a/Flat Bezel/FlatBezelObjectCell.swift b/Flat Bezel/FlatBezelObjectCell.swift
new file mode 100644 (file)
index 0000000..da38a1b
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+import Foundation
+
+class FlatBezelObjectCell: QSObjectCell {
+  override func preferredImagePosition() -> NSControl.ImagePosition {
+      return .imageAbove
+  }
+  
+  override func draw(withFrame cellFrame: NSRect, in controlView: NSView?) {
+    if let controlView {
+      
+      let isFirstResponder = controlView.window?.firstResponder == controlView && !(controlView is NSTableView)
+      let dropTarget = isHighlighted && ((highlightsBy.rawValue & NSCell.StyleMask.changeBackgroundCellMask.rawValue) != 0) && !isBezeled
+      
+      var fillColor: NSColor?
+      let strokeColor = NSColor.clear
+      
+      if isFirstResponder {
+        fillColor = self.highlightColor()
+      } else {
+        fillColor = self.backgroundColor
+      }
+      
+      if dropTarget {
+        fillColor = NSColor(red: 0.77, green: 0.91, blue: 0.96, alpha: 1)
+      }
+      
+      fillColor?.setFill()
+      strokeColor.setStroke()
+      
+      let roundRect = NSBezierPath()
+      roundRect.append(withRoundedRectangle: cellFrame, withRadius: cellRadiusFactor())
+      roundRect.fill()
+      
+      drawInterior(withFrame: drawingRect(forBounds: cellFrame), in: controlView)
+    }
+  }
+  
+  override func titleRect(forBounds _rect: NSRect) -> NSRect {
+      var rect = _rect
+      rect = NSOffsetRect(rect, 0, -4)
+      return super.titleRect(forBounds: rect)
+  }
+  
+  override func drawText(for drawObject: QSObject!, withFrame cellFrame: NSRect, in controlView: NSView!) {
+    if imagePosition == .imageOnly {
+      return
+    }
+    
+    var abbrString: String? = nil
+    
+    if controlView.responds(to: #selector(QSSearchObjectView.matchedString)) {
+      abbrString = (controlView as! QSSearchObjectView).matchedString()
+    }
+    
+    var nameString: String? = nil
+    var hitMask: NSIndexSet? = nil
+    
+    let ranker = drawObject.ranker()
+    if ranker != nil && abbrString != nil {
+      nameString = ranker?.matchedString(forAbbreviation: abbrString, hitmask: &hitMask, inContext: nil)
+    }
+    
+    if (nameString == nil) {
+      nameString = drawObject.displayName()
+    }
+    
+    let rankedStringIsName = nameString == drawObject.displayName() || nameString == nil
+    
+    if nameString == nil {
+      nameString = drawObject.identifier() ?? "Unknown"
+    }
+    
+    let useAlternateColor = controlView is NSTableView && (controlView as! NSTableView).isRowSelected((controlView as! NSTableView).row(at: cellFrame.origin))
+    let mainColor = textColor() ?? (useAlternateColor ? .alternateSelectedControlTextColor : .controlTextColor)
+    let fadedColor = mainColor.withAlphaComponent(0.50)
+    let textDrawRect = titleRect(forBounds: cellFrame)
+    
+    
+    let titleString = NSMutableAttributedString(string: nameString!)
+    let nameAttributes = (value(forKey: "nameAttributes") as? [NSAttributedString.Key : Any])
+    let detailsAttributes = (value(forKey: "detailsAttributes") as?  [NSAttributedString.Key : Any])
+    titleString.setAttributes(rankedStringIsName ? nameAttributes : detailsAttributes, range: NSMakeRange(0, titleString.length))
+    
+    if abbrString != nil && abbrString!.hasPrefix("QSActionMnemonic") {
+      titleString.addAttribute(.foregroundColor, value: rankedStringIsName ? fadedColor : fadedColor.withAlphaComponent(0.8), range: NSMakeRange(0, titleString.length))
+      
+      var hits: Int = 0
+      let count = hitMask?.getIndexes(&hits, maxCount: titleString.length, inIndexRange: nil)
+      for i in 0..<(count ?? 0) {
+        for j in 1.. {
+        }
+      }
+    }
+}
+
+    NSUInteger i = 0;
+    NSUInteger j = 0;
+    NSUInteger hits[[titleString length]];
+    NSUInteger count = [hitMask getIndexes:(NSUInteger *)&hits maxCount:[titleString length] inIndexRange:nil];
+    NSDictionary *attributes = @{
+      NSForegroundColorAttributeName:                                 rankedStringIsName ? mainColor : fadedColor
+    };
+    for(i = 0; i<count; i += j) {
+      for (j = 1; i+j<count && hits[i+j-1] +1 == hits[i+j]; j++);
+      [titleString addAttributes:attributes range:NSMakeRange(hits[i], j)];
+    }
+  } else {
+    [titleString addAttribute:NSBaselineOffsetAttributeName value:[NSNumber numberWithDouble:-1.0] range:NSMakeRange(0, [titleString length])];
+  }
+
+  if (showDetails) {
+    NSString *detailsString = [drawObject details];
+    
+    NSRange returnRange = [detailsString rangeOfString:@"\n"];
+    if (returnRange.location != NSNotFound) {
+      detailsString = [detailsString substringToIndex:returnRange.location];
+    }
+
+    detailsAttributes = [detailsAttributes mutableCopy];
+    [detailsAttributes setValue:[NSColor grayColor] forKey:NSForegroundColorAttributeName];
+    
+    if (detailsString && detailsString.length && ![detailsString isEqualToString:nameString]) {
+      [titleString appendAttributedString:[[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"\n%@",detailsString] attributes:detailsAttributes] autorelease]];
+    }
+  }
+
+  NSRect centerRect = rectFromSize([titleString size]);
+  centerRect.size.width = NSWidth(textDrawRect);
+  centerRect.size.height = MIN(NSHeight(textDrawRect), centerRect.size.height);
+  [titleString drawInRect:centerRectInRect(centerRect, textDrawRect)];
+}
+
+- (void)drawSearchPlaceholderWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
+  NSString *defaultText = NSLocalizedStringWithDefaultValue(@"Type to search", nil, [NSBundle mainBundle], @"Type to search", @"Hint that appears in the first pane of the QS interface when it's empty.");
+  NSSize textSize = [defaultText sizeWithAttributes:nameAttributes];
+  NSRect textRect = centerRectInRect(rectFromSize(textSize), cellFrame);
+  BOOL isFirstResponder = [[controlView window] firstResponder] == controlView && ![controlView isKindOfClass:[NSTableView class]];
+  
+  if (isFirstResponder && [controlView isKindOfClass:[QSSearchObjectView class]]) {
+    NSImage *find = [NSImage imageWithSystemSymbolName:@"magnifyingglass.circle.fill" accessibilityDescription:nil];
+    
+    
+    [find setSize:QSSize16];
+    NSRect findImageRect = expelRectFromRectOnEdge(centerRectInRect(rectFromSize([find size]), cellFrame), textRect, NSRectEdgeMinX, -2);
+    
+  
+    NSGraphicsContext *graphicsContext = [NSGraphicsContext currentContext];
+    [graphicsContext saveGraphicsState];
+    CGContextRef context = [graphicsContext CGContext];
+    CGContextBeginTransparencyLayerWithRect(context, findImageRect, nil);
+    CGContextSetBlendMode(context, kCGBlendModeNormal);
+    [find drawInRect:findImageRect fromRect:rectFromSize([find size]) operation:NSCompositingOperationSourceOver fraction:1];
+    CGContextSetBlendMode(context, kCGBlendModeSourceIn);
+    CGContextSetFillColorWithColor(context, [[NSColor textColor] CGColor]);
+    CGContextFillRect(context, findImageRect);
+    CGContextEndTransparencyLayer(context);
+
+    [defaultText drawInRect:textRect withAttributes:nameAttributes];
+  }
+}
+
+@end
+*/
diff --git a/Flat Bezel/FlatBezelSearchObjectView.swift b/Flat Bezel/FlatBezelSearchObjectView.swift
new file mode 100644 (file)
index 0000000..902bede
--- /dev/null
@@ -0,0 +1,6 @@
+class FlatBezelSearchObjectView: QSSearchObjectView {
+  override static var cellClass : AnyClass? {
+      get { return BBObjectCell.self }
+      set { super.cellClass = newValue }
+  }
+}
index e6b30150af575b23e8873590649e226b5f90eb8d..83b3b7501f4b3bdffa0b096dd1006f7c6713214a 100644 (file)
@@ -17,9 +17,9 @@
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>2.0</string>
+       <string>1.0.0</string>
        <key>CFBundleVersion</key>
        <key>CFBundleVersion</key>
-       <string>6</string>
+       <string>1</string>
        <key>QSRequirements</key>
        <dict>
                <key>minHostVersion</key>
        <key>QSRequirements</key>
        <dict>
                <key>minHostVersion</key>