aboutsummaryrefslogtreecommitdiff
path: root/Flat Bezel
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2023-02-09 22:51:47 +0100
committerRuben Beltran del Rio <ruben@unlimited.pizza>2023-02-09 22:51:47 +0100
commit953623b990fb65a0a9676071022ae8ce50436d53 (patch)
treed5135717f0e63bdd760a69cedf6703638b517095 /Flat Bezel
parentfc2c05420021064af5e322f5e59cf0995239349a (diff)
Improve drawing, add padding to bezel
Diffstat (limited to 'Flat Bezel')
-rw-r--r--Flat Bezel/BBFlatBezelInterface.m2
-rw-r--r--Flat Bezel/BBFlatBezelInterface.xib36
-rw-r--r--Flat Bezel/BBSearchObjectView.m31
-rw-r--r--Flat Bezel/FlatBezelObjectCell.swift133
-rw-r--r--Flat Bezel/FlatBezelSearchObjectView.swift16
-rwxr-xr-xFlat Bezel/gear-black.pngbin14198 -> 0 bytes
-rwxr-xr-xFlat Bezel/gear-white.pngbin15108 -> 0 bytes
-rwxr-xr-xFlat Bezel/search-black.pngbin13605 -> 0 bytes
-rwxr-xr-xFlat Bezel/search-white.pngbin15201 -> 0 bytes
9 files changed, 196 insertions, 22 deletions
diff --git a/Flat Bezel/BBFlatBezelInterface.m b/Flat Bezel/BBFlatBezelInterface.m
index a05a924..e430de8 100644
--- a/Flat Bezel/BBFlatBezelInterface.m
+++ b/Flat Bezel/BBFlatBezelInterface.m
@@ -82,7 +82,7 @@
NSRect screenRect = [[NSScreen mainScreen] frame];
if (!shouldExpand) {
- newRect.size.width -= 208;
+ newRect.size.width -= 192;
}
return NSOffsetRect(centerRectInRect(newRect, screenRect), 0, (NSHeight(screenRect) / 5));
diff --git a/Flat Bezel/BBFlatBezelInterface.xib b/Flat Bezel/BBFlatBezelInterface.xib
index dae6222..3aa05ea 100644
--- a/Flat Bezel/BBFlatBezelInterface.xib
+++ b/Flat Bezel/BBFlatBezelInterface.xib
@@ -22,51 +22,51 @@
<window title="Bezel Interface" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="9" userLabel="mainWindow" customClass="QSBorderlessWindow">
<windowStyleMask key="styleMask" titled="YES" closable="YES" nonactivatingPanel="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
- <rect key="contentRect" x="530" y="653" width="648" height="200"/>
+ <rect key="contentRect" x="530" y="653" width="608" height="200"/>
<rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
<value key="minSize" type="size" width="440" height="200"/>
<view key="contentView" id="6" customClass="BackgroundView" customModule="Flat_Bezel" customModuleProvider="target">
- <rect key="frame" x="0.0" y="0.0" width="648" height="200"/>
+ <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">
- <rect key="frame" x="0.0" y="0.0" width="200" height="200"/>
+ <rect key="frame" x="8" y="8" width="184" height="184"/>
<constraints>
- <constraint firstAttribute="height" constant="200" id="SwQ-fC-3aw"/>
- <constraint firstAttribute="width" constant="200" id="Zol-hr-3Bk"/>
+ <constraint firstAttribute="height" constant="184" id="SwQ-fC-3aw"/>
+ <constraint firstAttribute="width" constant="184" id="Zol-hr-3Bk"/>
</constraints>
<connections>
<outlet property="nextKeyView" destination="69" id="105"/>
</connections>
</customView>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="69" customClass="BBSearchObjectView">
- <rect key="frame" x="208" y="0.0" width="200" height="200"/>
+ <rect key="frame" x="200" y="8" width="184" height="184"/>
<constraints>
- <constraint firstAttribute="width" constant="200" id="O3w-M3-b05"/>
- <constraint firstAttribute="height" constant="200" id="XPL-72-l7r"/>
+ <constraint firstAttribute="width" constant="184" id="O3w-M3-b05"/>
+ <constraint firstAttribute="height" constant="184" id="XPL-72-l7r"/>
</constraints>
<connections>
<outlet property="nextKeyView" destination="70" id="106"/>
</connections>
</customView>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="70" customClass="BBCollectingSearchObjectView">
- <rect key="frame" x="416" y="0.0" width="200" height="200"/>
+ <rect key="frame" x="392" y="8" width="184" height="184"/>
<constraints>
- <constraint firstAttribute="width" constant="200" id="Jbn-VW-sSJ"/>
- <constraint firstAttribute="height" constant="200" id="X3X-S6-KrY"/>
+ <constraint firstAttribute="width" constant="184" id="Jbn-VW-sSJ"/>
+ <constraint firstAttribute="height" constant="184" id="X3X-S6-KrY"/>
</constraints>
<connections>
<outlet property="nextKeyView" destination="68" id="104"/>
</connections>
</customView>
<progressIndicator horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="100" displayedWhenStopped="NO" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="192">
- <rect key="frame" x="624" y="8" width="16" height="16"/>
+ <rect key="frame" x="584" y="8" width="16" height="16"/>
<constraints>
<constraint firstAttribute="width" constant="16" id="Py4-hV-7HG"/>
</constraints>
</progressIndicator>
<button translatesAutoresizingMaskIntoConstraints="NO" id="209" customClass="QSMenuButton">
- <rect key="frame" x="624" y="176" width="16" height="16"/>
+ <rect key="frame" x="584" y="176" width="16" height="16"/>
<constraints>
<constraint firstAttribute="height" constant="16" id="cvg-xh-bvD"/>
<constraint firstAttribute="width" constant="16" id="w12-Bf-x2f"/>
@@ -78,7 +78,7 @@
<color key="contentTintColor" name="labelColor" catalog="System" colorSpace="catalog"/>
</button>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="191">
- <rect key="frame" x="622" y="176" width="20" height="16"/>
+ <rect key="frame" x="582" y="176" width="20" height="16"/>
<constraints>
<constraint firstAttribute="height" constant="16" id="Yy8-MR-Hc2"/>
<constraint firstAttribute="width" constant="16" id="coj-vh-kaj"/>
@@ -98,11 +98,11 @@
<constraint firstAttribute="trailing" secondItem="192" secondAttribute="trailing" constant="8" id="S36-iH-Apn"/>
<constraint firstItem="69" firstAttribute="leading" secondItem="68" secondAttribute="trailing" constant="8" id="VOZ-kp-hVQ"/>
<constraint firstAttribute="trailing" secondItem="209" secondAttribute="trailing" constant="8" id="ZBS-80-x88"/>
- <constraint firstItem="69" firstAttribute="top" secondItem="6" secondAttribute="top" id="Zec-BE-M9X"/>
- <constraint firstItem="70" firstAttribute="top" secondItem="6" secondAttribute="top" id="jQN-Vd-Qm0"/>
+ <constraint firstItem="69" firstAttribute="top" secondItem="6" secondAttribute="top" constant="8" id="Zec-BE-M9X"/>
+ <constraint firstItem="70" firstAttribute="top" secondItem="6" secondAttribute="top" constant="8" id="jQN-Vd-Qm0"/>
<constraint firstItem="191" firstAttribute="top" secondItem="209" secondAttribute="bottom" constant="-16" id="jqz-xK-7Wg"/>
- <constraint firstItem="68" firstAttribute="leading" secondItem="6" secondAttribute="leading" id="m72-ls-RGc"/>
- <constraint firstItem="68" firstAttribute="top" secondItem="6" secondAttribute="top" id="msf-m2-n1U"/>
+ <constraint firstItem="68" firstAttribute="leading" secondItem="6" secondAttribute="leading" constant="8" id="m72-ls-RGc"/>
+ <constraint firstItem="68" firstAttribute="top" secondItem="6" secondAttribute="top" constant="8" id="msf-m2-n1U"/>
</constraints>
</view>
<connections>
diff --git a/Flat Bezel/BBSearchObjectView.m b/Flat Bezel/BBSearchObjectView.m
index ba88b0b..0722e0c 100644
--- a/Flat Bezel/BBSearchObjectView.m
+++ b/Flat Bezel/BBSearchObjectView.m
@@ -169,8 +169,33 @@
[titleString drawInRect:centerRectInRect(centerRect, textDrawRect)];
}
-@end
-
-
+- (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/FlatBezelObjectCell.swift b/Flat Bezel/FlatBezelObjectCell.swift
new file mode 100644
index 0000000..211f332
--- /dev/null
+++ b/Flat Bezel/FlatBezelObjectCell.swift
@@ -0,0 +1,133 @@
+//
+// FlatBezelObjectCell.swift
+// Flat Bezel
+//
+// Created by Ruben Beltran del Rio on 2/8/23.
+// Copyright © 2023 BRNBW. All rights reserved.
+//
+/*
+import Foundation
+import Cocoa
+
+class FlatBezelObjectCell: QSObjectCell {
+ let preferredImagePosition: NSControl.ImagePosition = .imageAbove
+
+ override func draw(withFrame cellFrame: NSRect, in controlView: NSView!) {
+ let isFirstResponder = controlView.window?.firstResponder == controlView && !controlView.isKind(of: NSTableView.self)
+
+ let dropTarget = self.isHighlighted && self.highlightsBy.contains(NSCell.StyleMask.changeBackgroundCellMask) && !self.isBezeled
+
+ var fillColor: NSColor = self.backgroundColor ?? .textBackgroundColor
+ if (isFirstResponder) {
+ fillColor = self.highlightColor()
+ }
+ if (dropTarget) {
+ fillColor = NSColor(red: 0.77, green: 0.91, blue: 0.96, alpha: 1)
+ }
+
+ var strokeColor: NSColor = .clear
+
+ fillColor.setFill()
+ strokeColor.setStroke()
+
+ let roundRect = NSBezierPath()
+ roundRect.appendRoundedRect(cellFrame, xRadius: cellRadiusFactor(), yRadius: cellRadiusFactor())
+ roundRect.fill()
+
+ self.drawInterior(withFrame: self.drawingRect(forBounds: cellFrame), in: controlView)
+ }
+
+ override func titleRect(forBounds rect: NSRect) -> NSRect {
+ super.titleRect(forBounds: rect.offsetBy(dx: 0, dy: -4))
+ }
+
+ override func drawText(for drawObject: QSObject!, withFrame cellFrame: NSRect, in controlView: NSView!) {
+ if self.imagePosition == .imageOnly {
+ return;
+ }
+
+ var abbrString: String? = nil
+ if controlView.responds(to: #selector(QSSearchObjectView.matchedString)) {
+ abbrString = (controlView as! QSSearchObjectView).matchedString()
+ }
+
+ var nameString: String? = drawObject.displayName()
+ var hitMask: AutoreleasingUnsafeMutablePointer<NSIndexSet?>? = nil
+
+ var ranker = drawObject.ranker()
+ if let ranker, let abbrString {
+ nameString = ranker.matchedString(forAbbreviation: abbrString, hitmask: hitMask, inContext: nil)
+ }
+
+ var rankedStringIsName = nameString == drawObject.displayName()
+ if nameString == nil {
+ nameString = drawObject.identifier() ?? "Unknown"
+ }
+
+ var useAlternateColor = false
+ if let controlView = controlView as? NSTableView {
+ useAlternateColor = controlView.isRowSelected(controlView.row(at: cellFrame.origin))
+ }
+
+ var mainColor: NSColor? = textColor()
+ if mainColor == nil {
+ mainColor = useAlternateColor ? .alternateSelectedControlTextColor : .controlTextColor
+ }
+
+ var fadedColor = mainColor!.withAlphaComponent(0.50)
+ var textDrawRect = titleRect(forBounds: cellFrame)
+
+ var titleString = NSMutableAttributedString(string: nameString!)
+ titleString.setAttributes(rankedStringIsName ? nameAttributes : detailAttributes, 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))
+ } else {
+ var i = 0
+ var j = 0
+ var hits: [Int] = []
+ count = hitMask?.
+ }
+ }
+}
+
+
+ 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)];
+}
+
+@end
+*/
diff --git a/Flat Bezel/FlatBezelSearchObjectView.swift b/Flat Bezel/FlatBezelSearchObjectView.swift
new file mode 100644
index 0000000..fdd88d5
--- /dev/null
+++ b/Flat Bezel/FlatBezelSearchObjectView.swift
@@ -0,0 +1,16 @@
+//
+// SearchObjectView.swift
+// Flat Bezel
+//
+// Created by Ruben Beltran del Rio on 2/8/23.
+// Copyright © 2023 BRNBW. All rights reserved.
+//
+/*
+import Foundation
+
+class FlatBezelSearchObjectView: QSSearchObjectView {
+ static func cellClass() -> AnyClass {
+ return FlatBezelObjectCell.self
+ }
+}
+*/
diff --git a/Flat Bezel/gear-black.png b/Flat Bezel/gear-black.png
deleted file mode 100755
index 3ebdfe6..0000000
--- a/Flat Bezel/gear-black.png
+++ /dev/null
Binary files differ
diff --git a/Flat Bezel/gear-white.png b/Flat Bezel/gear-white.png
deleted file mode 100755
index 169f6cb..0000000
--- a/Flat Bezel/gear-white.png
+++ /dev/null
Binary files differ
diff --git a/Flat Bezel/search-black.png b/Flat Bezel/search-black.png
deleted file mode 100755
index e85640e..0000000
--- a/Flat Bezel/search-black.png
+++ /dev/null
Binary files differ
diff --git a/Flat Bezel/search-white.png b/Flat Bezel/search-white.png
deleted file mode 100755
index e6048b7..0000000
--- a/Flat Bezel/search-white.png
+++ /dev/null
Binary files differ