diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-09-04 11:11:37 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-09-04 11:11:37 +0200 |
| commit | bb5daa2e90623691a5259700b9d388d2d21f46d3 (patch) | |
| tree | f5629e81bedc6cdd35ee9a79628997c5e14ffa7c /Liquid Glass Bezel/BBLiquidGlassBezelInterface.m | |
| parent | 3dfeb86c5c3b72acc59919c7a198fcf76a54c35c (diff) | |
Rename to Liquid Glass Bezel, add preferences
Diffstat (limited to 'Liquid Glass Bezel/BBLiquidGlassBezelInterface.m')
| -rw-r--r-- | Liquid Glass Bezel/BBLiquidGlassBezelInterface.m | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/Liquid Glass Bezel/BBLiquidGlassBezelInterface.m b/Liquid Glass Bezel/BBLiquidGlassBezelInterface.m new file mode 100644 index 0000000..335eacd --- /dev/null +++ b/Liquid Glass Bezel/BBLiquidGlassBezelInterface.m @@ -0,0 +1,103 @@ +#import "BBLiquidGlassBezelInterface.h" + +@interface BBLiquidGlassBezelInterface () { + CGRect initialRect; +} +@end + +@implementation BBLiquidGlassBezelInterface + +- (id)init { + return [self initWithWindowNibName:@"BBLiquidGlassBezelInterface"]; +} + +- (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:32]; + + [theCell setHighlightColor:[NSColor colorWithRed:1 green:1 blue:1 alpha:.15]]; + [theCell setTextColor:[NSColor textColor]]; + [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 -= 192; + } + + 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; +} + +- (IBAction)customize:(id)sender{ + [[NSClassFromString(@"QSPreferencesController") sharedInstance] showPaneWithIdentifier:@"BBLiquidGlassBezelPrefs"]; +} + +@end |