Move “select base name” cell subclass to new file browser framework

This commit is contained in:
Allan Odgaard
2018-10-28 14:41:18 +07:00
parent b0262c452c
commit c8ea52f19c
2 changed files with 13 additions and 17 deletions

View File

@@ -8,8 +8,18 @@
- (id)initWithCloseAction:(SEL)closeAction target:(id)target;
@end
// Implemented in OakFileBrowser/FSOutlineViewDelegate.mm
@interface OakSelectBasenameCell : NSTextFieldCell
@interface FileItemSelectBasenameCell : NSTextFieldCell
@end
@implementation FileItemSelectBasenameCell
- (void)selectWithFrame:(NSRect)aRect inView:(NSView*)aView editor:(NSText*)aText delegate:(id)someDelegate start:(NSInteger)start length:(NSInteger)length
{
NSString* path = self.stringValue;
if([self.objectValue respondsToSelector:@selector(firstObject)])
path = [self.objectValue firstObject];
NSString* basename = [path stringByDeletingPathExtension];
[super selectWithFrame:aRect inView:aView editor:aText delegate:someDelegate start:start length:(start == 0 && basename ? MIN(basename.length, length) : length)];
}
@end
@implementation FileItem (FileItemWrapper)
@@ -79,7 +89,7 @@
_itemInfoButtons = [[OakItemButtonsView alloc] initWithCloseAction:@selector(didClickCloseButton:) target:self];
NSTextField* textField = OakCreateLabel(@"", [NSFont controlContentFontOfSize:0]);
textField.cell = [[OakSelectBasenameCell alloc] initTextCell:@""];
textField.cell = [[FileItemSelectBasenameCell alloc] initTextCell:@""];
[textField.cell setWraps:NO];
[textField.cell setLineBreakMode:NSLineBreakByTruncatingMiddle];
textField.formatter = [[FileItemFormatter alloc] initWithTableCellView:self];

View File

@@ -1,20 +1,6 @@
#import <OakAppKit/OakFinderTag.h>
#import <OakAppKit/OakUIConstructionFunctions.h>
@interface OakSelectBasenameCell : NSTextFieldCell
@end
@implementation OakSelectBasenameCell
- (void)selectWithFrame:(NSRect)aRect inView:(NSView*)aView editor:(NSText*)aText delegate:(id)someDelegate start:(NSInteger)start length:(NSInteger)length
{
NSString* path = self.stringValue;
if([self.objectValue respondsToSelector:@selector(firstObject)])
path = [self.objectValue firstObject];
NSString* basename = [path stringByDeletingPathExtension];
[super selectWithFrame:aRect inView:aView editor:aText delegate:someDelegate start:start length:(start == 0 && basename ? MIN(basename.length, length) : length)];
}
@end
@interface OakLabelSwatchView : NSView
@property (nonatomic) NSArray<OakFinderTag*>* finderTags;
@end