mirror of
https://github.com/textmate/textmate.git
synced 2026-01-21 04:38:13 -05:00
Position file chooser relative to text view
This is instead of placing it relative to the entire window. The main motivation is that with the file browser on the right, I want the file chooser closer to the left edge of the window.
This commit is contained in:
@@ -1463,7 +1463,17 @@ namespace
|
||||
fc.filterString = entry.string;
|
||||
}
|
||||
|
||||
[fc showWindowRelativeToWindow:self.window];
|
||||
if(![fc.window isVisible])
|
||||
{
|
||||
NSRect frame = [fc.window frame];
|
||||
NSRect parent = [_window convertRectToScreen:[_textView convertRect:[_textView visibleRect] toView:nil]];
|
||||
|
||||
frame.origin.x = NSMinX(parent) + round((NSWidth(parent) - NSWidth(frame)) * 1 / 4);
|
||||
frame.origin.y = NSMinY(parent) + round((NSHeight(parent) - NSHeight(frame)) * 3 / 4);
|
||||
[fc.window setFrame:frame display:NO];
|
||||
}
|
||||
|
||||
[fc showWindow:self];
|
||||
}
|
||||
|
||||
- (void)fileChooserDidSelectItems:(FileChooser*)sender
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#import <scm/scm.h>
|
||||
|
||||
PUBLIC @interface FileChooser : NSObject
|
||||
@property (nonatomic) NSWindow* window;
|
||||
|
||||
@property (nonatomic) NSString* path;
|
||||
@property (nonatomic) scm::info_ptr const& scmInfo;
|
||||
|
||||
@@ -19,6 +21,5 @@ PUBLIC @interface FileChooser : NSObject
|
||||
|
||||
+ (FileChooser*)sharedInstance;
|
||||
- (void)showWindow:(id)sender;
|
||||
- (void)showWindowRelativeToWindow:(NSWindow*)parentWindow;
|
||||
- (void)close;
|
||||
@end
|
||||
|
||||
@@ -186,7 +186,6 @@ static path::glob_list_t globs_for_path (std::string const& path)
|
||||
std::vector<document_record_t> _records;
|
||||
document::scanner_ptr _scanner;
|
||||
}
|
||||
@property (nonatomic) NSWindow* window;
|
||||
@property (nonatomic) NSSearchField* searchField;
|
||||
@property (nonatomic) NSButton* allButton;
|
||||
@property (nonatomic) NSButton* openDocumentsButton;
|
||||
@@ -351,21 +350,6 @@ static path::glob_list_t globs_for_path (std::string const& path)
|
||||
[_window makeFirstResponder:_searchField];
|
||||
}
|
||||
|
||||
- (void)showWindowRelativeToWindow:(NSWindow*)parentWindow
|
||||
{
|
||||
if(parentWindow && ![_window isVisible])
|
||||
{
|
||||
NSRect frame = [_window frame];
|
||||
NSRect parent = [parentWindow frame];
|
||||
|
||||
frame.origin.x = round(NSMidX(parent) - 0.5 * NSWidth(frame));
|
||||
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