Don’t set foreground color for (file) chooser items

Initially not-matched characters were made light gray and we also had to explicitly set the color to white when the item was highlighted.

We no longer use color distinction for matched/non-matched characters, and rendering the text as highlighted is handled by the table view (NSCell setup).
This commit is contained in:
Allan Odgaard
2013-10-27 11:45:55 +01:00
parent f9349f6981
commit a18d8bd3e7
3 changed files with 5 additions and 13 deletions

View File

@@ -647,15 +647,7 @@ inline void rank_record (document_record_t& record, filter_string_t const& filte
path += " — " + text::join(v, "/");
}
NSColor* textColor = [NSColor controlTextColor];
NSColor* matchedTextColor = [NSColor controlTextColor];
if([aTableView isRowSelected:rowIndex] && [self.window isKeyWindow])
{
textColor = [NSColor alternateSelectedControlTextColor];
matchedTextColor = [NSColor alternateSelectedControlTextColor];
}
NSMutableAttributedString* str = CreateAttributedStringWithMarkedUpRanges(OakControlFont(), textColor, matchedTextColor, path, record.cover);
NSMutableAttributedString* str = CreateAttributedStringWithMarkedUpRanges(path, record.cover);
NSMutableParagraphStyle* pStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[pStyle setLineBreakMode:NSLineBreakByTruncatingMiddle];
[str addAttribute:NSParagraphStyleAttributeName value:pStyle range:NSMakeRange(0, str.length)];

View File

@@ -1,6 +1,6 @@
#include <oak/misc.h>
NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (NSFont* baseFont, NSColor* textColor, NSColor* matchedTextColor, std::string const& in, std::vector< std::pair<size_t, size_t> > const& ranges, size_t offset = 0);
NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string const& in, std::vector< std::pair<size_t, size_t> > const& ranges, size_t offset = 0);
PUBLIC @interface OakChooser : NSObject
@property (nonatomic) NSWindow* window;

View File

@@ -6,10 +6,10 @@
#import <ns/ns.h>
#import <text/ranker.h>
NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (NSFont* baseFont, NSColor* textColor, NSColor* matchedTextColor, std::string const& in, std::vector< std::pair<size_t, size_t> > const& ranges, size_t offset)
NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string const& in, std::vector< std::pair<size_t, size_t> > const& ranges, size_t offset)
{
NSDictionary* baseAttributes = @{ NSForegroundColorAttributeName : textColor, };
NSDictionary* highlightAttributes = @{ NSForegroundColorAttributeName : matchedTextColor, NSUnderlineStyleAttributeName : @1 };
NSDictionary* baseAttributes = @{ };
NSDictionary* highlightAttributes = @{ NSUnderlineStyleAttributeName : @1 };
NSMutableAttributedString* res = [[NSMutableAttributedString alloc] init];