mirror of
https://github.com/textmate/textmate.git
synced 2026-01-22 05:07:54 -05:00
Add relative window positioning to OakChooser
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user