diff --git a/Frameworks/OakFilterList/src/OakChooser.h b/Frameworks/OakFilterList/src/OakChooser.h index e4316e99..6634fb73 100644 --- a/Frameworks/OakFilterList/src/OakChooser.h +++ b/Frameworks/OakFilterList/src/OakChooser.h @@ -12,6 +12,7 @@ PUBLIC @interface OakChooser : NSObject @property (nonatomic, readonly) NSArray* selectedItems; - (void)showWindow:(id)sender; +- (void)showWindowRelativeToFrame:(NSRect)parentFrame; - (void)close; // For subclasses diff --git a/Frameworks/OakFilterList/src/OakChooser.mm b/Frameworks/OakFilterList/src/OakChooser.mm index 2a910dcb..75200e28 100644 --- a/Frameworks/OakFilterList/src/OakChooser.mm +++ b/Frameworks/OakFilterList/src/OakChooser.mm @@ -123,6 +123,21 @@ NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string [_window makeFirstResponder:_searchField]; } +- (void)showWindowRelativeToFrame:(NSRect)parentFrame +{ + if(![_window isVisible]) + { + [_window layoutIfNeeded]; + NSRect frame = [_window frame]; + NSRect parent = parentFrame; + + frame.origin.x = NSMinX(parent) + round((NSWidth(parent) - NSWidth(frame)) * 1 / 4); + frame.origin.y = NSMinY(parent) + round((NSHeight(parent) - NSHeight(frame)) * 3 / 4); + [_window setFrame:frame display:NO]; + } + [self showWindow:self]; +} + - (void)close { [_window performClose:self];