From 5200836d4b4ca9baf0f578f7a462f27d155abff4 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Wed, 8 Feb 2023 16:45:16 +0100 Subject: Initial Commit --- Flat Bezel/BBBackgroundView.h | 5 + Flat Bezel/BBBackgroundView.m | 24 +++++ Flat Bezel/BBFlatBezelInterface.h | 9 ++ Flat Bezel/BBFlatBezelInterface.m | 99 +++++++++++++++++++ Flat Bezel/BBFlatBezelInterface.xib | 115 ++++++++++++++++++++++ Flat Bezel/BBSearchObjectView.h | 10 ++ Flat Bezel/BBSearchObjectView.m | 176 ++++++++++++++++++++++++++++++++++ Flat Bezel/en.lproj/InfoPlist.strings | 2 + Flat Bezel/gear-black.png | Bin 0 -> 14198 bytes Flat Bezel/gear-white.png | Bin 0 -> 15108 bytes Flat Bezel/search-black.png | Bin 0 -> 13605 bytes Flat Bezel/search-white.png | Bin 0 -> 15201 bytes 12 files changed, 440 insertions(+) create mode 100644 Flat Bezel/BBBackgroundView.h create mode 100644 Flat Bezel/BBBackgroundView.m create mode 100644 Flat Bezel/BBFlatBezelInterface.h create mode 100644 Flat Bezel/BBFlatBezelInterface.m create mode 100644 Flat Bezel/BBFlatBezelInterface.xib create mode 100644 Flat Bezel/BBSearchObjectView.h create mode 100644 Flat Bezel/BBSearchObjectView.m create mode 100644 Flat Bezel/en.lproj/InfoPlist.strings create mode 100755 Flat Bezel/gear-black.png create mode 100755 Flat Bezel/gear-white.png create mode 100755 Flat Bezel/search-black.png create mode 100755 Flat Bezel/search-white.png (limited to 'Flat Bezel') diff --git a/Flat Bezel/BBBackgroundView.h b/Flat Bezel/BBBackgroundView.h new file mode 100644 index 0000000..1c699a2 --- /dev/null +++ b/Flat Bezel/BBBackgroundView.h @@ -0,0 +1,5 @@ +#import + +@interface BBBackgroundView : QSBezelBackgroundView + +@end diff --git a/Flat Bezel/BBBackgroundView.m b/Flat Bezel/BBBackgroundView.m new file mode 100644 index 0000000..7aff10b --- /dev/null +++ b/Flat Bezel/BBBackgroundView.m @@ -0,0 +1,24 @@ +#import "BBBackgroundView.h" + +@implementation BBBackgroundView + +- (void)drawRect:(NSRect)rect { + rect = [self bounds]; + + NSBezierPath *roundRect = [NSBezierPath bezierPath]; + + [roundRect appendBezierPathWithRoundedRectangle:rect withRadius:8]; + [roundRect addClip]; + + BOOL darkMode = [[NSUserDefaults standardUserDefaults] boolForKey:@"QSFlatBezelDarkMode"]; + if (darkMode) { + [[NSColor colorWithRed:.1 green:.1 blue:.1 alpha:.99] set]; + } else { + [[NSColor colorWithRed:1 green:1 blue:1 alpha:.99] set]; + } + NSRectFill(rect); + + [super drawRect:rect]; +} + +@end diff --git a/Flat Bezel/BBFlatBezelInterface.h b/Flat Bezel/BBFlatBezelInterface.h new file mode 100644 index 0000000..301542d --- /dev/null +++ b/Flat Bezel/BBFlatBezelInterface.h @@ -0,0 +1,9 @@ +@interface BBFlatBezelInterface : QSResizingInterfaceController { + NSRect standardRect; +} + +@end + +@interface NSWindow (QSBCInterfaceController) +- (NSTimeInterval)animationResizeTime:(NSRect)newWindowFrame; +@end diff --git a/Flat Bezel/BBFlatBezelInterface.m b/Flat Bezel/BBFlatBezelInterface.m new file mode 100644 index 0000000..a191f81 --- /dev/null +++ b/Flat Bezel/BBFlatBezelInterface.m @@ -0,0 +1,99 @@ +#import "BBFlatBezelInterface.h" + +@interface BBFlatBezelInterface () { + CGRect initialRect; +} +@end + +@implementation BBFlatBezelInterface + +- (id)init { + return [self initWithWindowNibName:@"BBFlatBezelInterface"]; +} + +- (void)windowDidLoad { + initialRect = centerRectInRect([[self window] frame], [[NSScreen mainScreen] frame]); + + [super windowDidLoad]; + + QSWindow *window = (QSWindow *)[self window]; + [window setLevel:NSPopUpMenuWindowLevel]; + [window setBackgroundColor:[NSColor clearColor]]; + [window setOpaque:NO]; + + [window setHideOffset:NSMakePoint(0, 0)]; + [window setShowOffset:NSMakePoint(0, 0)]; + + [window setMovableByWindowBackground:NO]; + [window setFastShow:YES]; + [window setHasShadow:YES]; + + [window setFrame:standardRect display:YES]; + + NSArray *theControls = [NSArray arrayWithObjects:dSelector, aSelector, iSelector, nil]; + for(QSSearchObjectView *theControl in theControls) { + QSObjectCell *theCell = [theControl cell]; + + [theControl setPreferredEdge:NSMinYEdge]; + [(QSWindow *)[(theControl)->resultController window] setHideOffset:NSMakePoint(0, NSMinY([iSelector frame]))]; + [(QSWindow *)[(theControl)->resultController window] setShowOffset:NSMakePoint(0, NSMinY([dSelector frame]))]; + + [theCell setBackgroundColor:[NSColor clearColor]]; + [theCell setFont:[NSFont systemFontOfSize:11 weight:NSFontWeightLight]]; + [theCell setCellRadiusFactor:8]; + + [theCell setHighlightColor:[NSColor colorWithRed:1 green:1 blue:1 alpha:.15]]; + [theCell setTextColor:[NSColor colorWithWhite:.8 alpha:1]]; + [theCell setShowDetails:NO]; + [theCell setState:NSControlStateValueOn]; + [theCell setIconSize:QSSize128]; + [theCell setImagePosition:NSImageAbove]; + } + + [self contractWindow:nil]; +} + +- (NSSize) maxIconSize { + return QSSize32; +} + +- (void)showMainWindow:(id)sender { + [[self window] setFrame:[self rectForState:[self expanded]] display:YES]; + if ([[self window] isVisible]) [[self window] pulse:self]; + [super showMainWindow:sender]; + // Does this need to be here? + [[[self window] contentView] setNeedsDisplay:YES]; +} + +- (void)expandWindow:(id)sender { + if (![self expanded]) + [[self window] setFrame:[self rectForState:YES] display:YES animate:YES]; + [super expandWindow:sender]; +} + +- (void)contractWindow:(id)sender { + if ([self expanded]) + [[self window] setFrame:[self rectForState:NO] display:YES animate:YES]; + [super contractWindow:sender]; +} + +- (NSRect)rectForState:(BOOL)shouldExpand { + NSRect newRect = initialRect; + NSRect screenRect = [[NSScreen mainScreen] frame]; + + if (!shouldExpand) { + newRect.size.width -= 208; + } + + return NSOffsetRect(centerRectInRect(newRect, screenRect), 0, (NSHeight(screenRect) / 5)); +} + +- (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect { + return NSOffsetRect(NSInsetRect(rect, 8, 0), 0, 0); +} + +- (NSTimeInterval)animationResizeTime:(NSRect)newWindowFrame { + return 0.01; +} + +@end diff --git a/Flat Bezel/BBFlatBezelInterface.xib b/Flat Bezel/BBFlatBezelInterface.xib new file mode 100644 index 0000000..75378c6 --- /dev/null +++ b/Flat Bezel/BBFlatBezelInterface.xib @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Flat Bezel/BBSearchObjectView.h b/Flat Bezel/BBSearchObjectView.h new file mode 100644 index 0000000..b60a637 --- /dev/null +++ b/Flat Bezel/BBSearchObjectView.h @@ -0,0 +1,10 @@ +#import + +@interface BBSearchObjectView : QSSearchObjectView +@end + +@interface BBCollectingSearchObjectView : QSCollectingSearchObjectView +@end + +@interface BBObjectCell : QSObjectCell +@end diff --git a/Flat Bezel/BBSearchObjectView.m b/Flat Bezel/BBSearchObjectView.m new file mode 100644 index 0000000..ba88b0b --- /dev/null +++ b/Flat Bezel/BBSearchObjectView.m @@ -0,0 +1,176 @@ +#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