aboutsummaryrefslogtreecommitdiff
path: root/Flat Bezel/BBFlatBezelInterface.m
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2023-02-08 16:45:16 +0100
committerRuben Beltran del Rio <ruben@unlimited.pizza>2023-02-08 16:45:16 +0100
commit5200836d4b4ca9baf0f578f7a462f27d155abff4 (patch)
treed190f2782c4b0f160faaaf1226e2de7561001272 /Flat Bezel/BBFlatBezelInterface.m
Initial Commit
Diffstat (limited to 'Flat Bezel/BBFlatBezelInterface.m')
-rw-r--r--Flat Bezel/BBFlatBezelInterface.m99
1 files changed, 99 insertions, 0 deletions
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