Font size implemented through bindings.
parent
6663d149b7
commit
7f52608e6c
|
@ -337,6 +337,11 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
|
||||||
{
|
{
|
||||||
NSMutableDictionary *userDefaultsValuesDict = [NSMutableDictionary dictionary];
|
NSMutableDictionary *userDefaultsValuesDict = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
|
// Font defaults
|
||||||
|
float fFontSize = [NSFont systemFontSizeForControlSize:NSSmallControlSize];
|
||||||
|
NSNumber *fontSize = [NSNumber numberWithFloat:fFontSize];
|
||||||
|
[userDefaultsValuesDict setObject:fontSize forKey:@"fontSize"];
|
||||||
|
|
||||||
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:35] forKey:@"hotKeyPlayKeyCode"];
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:35] forKey:@"hotKeyPlayKeyCode"];
|
||||||
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:(NSControlKeyMask|NSCommandKeyMask)] forKey:@"hotKeyPlayModifiers"];
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:(NSControlKeyMask|NSCommandKeyMask)] forKey:@"hotKeyPlayModifiers"];
|
||||||
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:'P'] forKey:@"hotKeyPlayCharacter"];
|
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:'P'] forKey:@"hotKeyPlayCharacter"];
|
||||||
|
@ -451,32 +456,10 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
|
||||||
|
|
||||||
- (void)changeFontSize:(float)size
|
- (void)changeFontSize:(float)size
|
||||||
{
|
{
|
||||||
NSFont *f = [[NSFontManager sharedFontManager] selectedFont];
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||||
float origFontSize = [[f fontDescriptor] pointSize];
|
float fCurrentSize = [defaults floatForKey:@"fontSize"];
|
||||||
|
NSNumber *newSize = [NSNumber numberWithFloat:(fCurrentSize + size)];
|
||||||
// hack to make the file drawer stay unbolded - might affect things I haven't seen
|
[defaults setObject:newSize forKey:@"fontSize"];
|
||||||
f = [[NSFontManager sharedFontManager] convertFont:f toNotHaveTrait:NSBoldFontMask];
|
|
||||||
|
|
||||||
f = [[NSFontManager sharedFontManager] convertFont:f toSize:origFontSize+size];
|
|
||||||
|
|
||||||
NSEnumerator *playlistEntries = [[playlistView tableColumns] objectEnumerator];
|
|
||||||
|
|
||||||
id c;
|
|
||||||
|
|
||||||
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
|
|
||||||
[playlistView setRowHeight:[layoutManager defaultLineHeightForFont:f]];
|
|
||||||
[layoutManager release];
|
|
||||||
|
|
||||||
while (c = [playlistEntries nextObject])
|
|
||||||
{
|
|
||||||
[[c dataCell] setFont:f];
|
|
||||||
}
|
|
||||||
|
|
||||||
// we must set the selectedFont so that we have updated font information
|
|
||||||
// next time we want to change it
|
|
||||||
[[NSFontManager sharedFontManager] setSelectedFont:f isMultiple:NO];
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)increaseFontSize:(id)sender
|
- (IBAction)increaseFontSize:(id)sender
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
56462DDA0D61D71E000AB68C /* SpotlightPlaylistView.m in Sources */ = {isa = PBXBuildFile; fileRef = 56462DD90D61D71E000AB68C /* SpotlightPlaylistView.m */; };
|
56462DDA0D61D71E000AB68C /* SpotlightPlaylistView.m in Sources */ = {isa = PBXBuildFile; fileRef = 56462DD90D61D71E000AB68C /* SpotlightPlaylistView.m */; };
|
||||||
56462EAF0D6341F6000AB68C /* SpotlightTransformers.m in Sources */ = {isa = PBXBuildFile; fileRef = 56462EAE0D6341F6000AB68C /* SpotlightTransformers.m */; };
|
56462EAF0D6341F6000AB68C /* SpotlightTransformers.m in Sources */ = {isa = PBXBuildFile; fileRef = 56462EAE0D6341F6000AB68C /* SpotlightTransformers.m */; };
|
||||||
56462EB20D634206000AB68C /* SpotlightPlaylistController.m in Sources */ = {isa = PBXBuildFile; fileRef = 56462EB10D634206000AB68C /* SpotlightPlaylistController.m */; };
|
56462EB20D634206000AB68C /* SpotlightPlaylistController.m in Sources */ = {isa = PBXBuildFile; fileRef = 56462EB10D634206000AB68C /* SpotlightPlaylistController.m */; };
|
||||||
|
56AE86C10D6901BC00B0F89B /* FontSizetoLineHeightTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 56AE86C00D6901BC00B0F89B /* FontSizetoLineHeightTransformer.m */; };
|
||||||
56C63D910D647DF300EAE25A /* NSComparisonPredicate+CogPredicate.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C63D900D647DF300EAE25A /* NSComparisonPredicate+CogPredicate.m */; };
|
56C63D910D647DF300EAE25A /* NSComparisonPredicate+CogPredicate.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C63D900D647DF300EAE25A /* NSComparisonPredicate+CogPredicate.m */; };
|
||||||
56DB084C0D6717DC00453B6A /* NSNumber+CogSort.m in Sources */ = {isa = PBXBuildFile; fileRef = 56DB084B0D6717DC00453B6A /* NSNumber+CogSort.m */; };
|
56DB084C0D6717DC00453B6A /* NSNumber+CogSort.m in Sources */ = {isa = PBXBuildFile; fileRef = 56DB084B0D6717DC00453B6A /* NSNumber+CogSort.m */; };
|
||||||
56DB08550D67185300453B6A /* NSArray+CogSort.m in Sources */ = {isa = PBXBuildFile; fileRef = 56DB08540D67185300453B6A /* NSArray+CogSort.m */; };
|
56DB08550D67185300453B6A /* NSArray+CogSort.m in Sources */ = {isa = PBXBuildFile; fileRef = 56DB08540D67185300453B6A /* NSArray+CogSort.m */; };
|
||||||
|
@ -625,6 +626,8 @@
|
||||||
56462EB00D634206000AB68C /* SpotlightPlaylistController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SpotlightPlaylistController.h; path = Spotlight/SpotlightPlaylistController.h; sourceTree = "<group>"; };
|
56462EB00D634206000AB68C /* SpotlightPlaylistController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SpotlightPlaylistController.h; path = Spotlight/SpotlightPlaylistController.h; sourceTree = "<group>"; };
|
||||||
56462EB10D634206000AB68C /* SpotlightPlaylistController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SpotlightPlaylistController.m; path = Spotlight/SpotlightPlaylistController.m; sourceTree = "<group>"; };
|
56462EB10D634206000AB68C /* SpotlightPlaylistController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SpotlightPlaylistController.m; path = Spotlight/SpotlightPlaylistController.m; sourceTree = "<group>"; };
|
||||||
566D32160D538550004466A5 /* APL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = APL.xcodeproj; path = Plugins/APL/APL.xcodeproj; sourceTree = "<group>"; };
|
566D32160D538550004466A5 /* APL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = APL.xcodeproj; path = Plugins/APL/APL.xcodeproj; sourceTree = "<group>"; };
|
||||||
|
56AE86BF0D6901BC00B0F89B /* FontSizetoLineHeightTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSizetoLineHeightTransformer.h; sourceTree = "<group>"; };
|
||||||
|
56AE86C00D6901BC00B0F89B /* FontSizetoLineHeightTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FontSizetoLineHeightTransformer.m; sourceTree = "<group>"; };
|
||||||
56C63D8F0D647DF300EAE25A /* NSComparisonPredicate+CogPredicate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSComparisonPredicate+CogPredicate.h"; path = "Spotlight/NSComparisonPredicate+CogPredicate.h"; sourceTree = "<group>"; };
|
56C63D8F0D647DF300EAE25A /* NSComparisonPredicate+CogPredicate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSComparisonPredicate+CogPredicate.h"; path = "Spotlight/NSComparisonPredicate+CogPredicate.h"; sourceTree = "<group>"; };
|
||||||
56C63D900D647DF300EAE25A /* NSComparisonPredicate+CogPredicate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSComparisonPredicate+CogPredicate.m"; path = "Spotlight/NSComparisonPredicate+CogPredicate.m"; sourceTree = "<group>"; };
|
56C63D900D647DF300EAE25A /* NSComparisonPredicate+CogPredicate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSComparisonPredicate+CogPredicate.m"; path = "Spotlight/NSComparisonPredicate+CogPredicate.m"; sourceTree = "<group>"; };
|
||||||
56DB084A0D6717DC00453B6A /* NSNumber+CogSort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSNumber+CogSort.h"; path = "Spotlight/NSNumber+CogSort.h"; sourceTree = "<group>"; };
|
56DB084A0D6717DC00453B6A /* NSNumber+CogSort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSNumber+CogSort.h"; path = "Spotlight/NSNumber+CogSort.h"; sourceTree = "<group>"; };
|
||||||
|
@ -859,6 +862,8 @@
|
||||||
07E18DF20D62B38400BB0E11 /* NSArray+ShuffleUtils.m */,
|
07E18DF20D62B38400BB0E11 /* NSArray+ShuffleUtils.m */,
|
||||||
17E78CAF0D68D46F005C5A59 /* StringToURLTransformer.h */,
|
17E78CAF0D68D46F005C5A59 /* StringToURLTransformer.h */,
|
||||||
17E78CB00D68D46F005C5A59 /* StringToURLTransformer.m */,
|
17E78CB00D68D46F005C5A59 /* StringToURLTransformer.m */,
|
||||||
|
56AE86BF0D6901BC00B0F89B /* FontSizetoLineHeightTransformer.h */,
|
||||||
|
56AE86C00D6901BC00B0F89B /* FontSizetoLineHeightTransformer.m */,
|
||||||
);
|
);
|
||||||
path = Utils;
|
path = Utils;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -1688,6 +1693,7 @@
|
||||||
17211A780D68B79700911CA9 /* PathNode.m in Sources */,
|
17211A780D68B79700911CA9 /* PathNode.m in Sources */,
|
||||||
17211A790D68B79700911CA9 /* SmartFolderNode.m in Sources */,
|
17211A790D68B79700911CA9 /* SmartFolderNode.m in Sources */,
|
||||||
17E78CB10D68D46F005C5A59 /* StringToURLTransformer.m in Sources */,
|
17E78CB10D68D46F005C5A59 /* StringToURLTransformer.m in Sources */,
|
||||||
|
56AE86C10D6901BC00B0F89B /* FontSizetoLineHeightTransformer.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -23,26 +23,19 @@
|
||||||
[[self menu] setAutoenablesItems:NO];
|
[[self menu] setAutoenablesItems:NO];
|
||||||
|
|
||||||
NSControlSize s = NSSmallControlSize;
|
NSControlSize s = NSSmallControlSize;
|
||||||
NSEnumerator *oe = [[self tableColumns] objectEnumerator];
|
|
||||||
NSFont *f = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:s]];
|
NSFont *f = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:s]];
|
||||||
NSFont *bf = [[NSFontManager sharedFontManager] convertFont:f toHaveTrait:NSBoldFontMask];
|
// NSFont *bf = [[NSFontManager sharedFontManager] convertFont:f toHaveTrait:NSBoldFontMask];
|
||||||
|
|
||||||
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
|
for(NSTableColumn *col in [self tableColumns])
|
||||||
[self setRowHeight:[layoutManager defaultLineHeightForFont:bf]];
|
|
||||||
[layoutManager release];
|
|
||||||
|
|
||||||
//Resize the fonts
|
|
||||||
id c;
|
|
||||||
while (c = [oe nextObject])
|
|
||||||
{
|
{
|
||||||
[[c dataCell] setControlSize:s];
|
[[col dataCell] setControlSize:s];
|
||||||
|
[[col dataCell] setFont:f];
|
||||||
//Using the bold font defined from the default system font with the bold trait added seems to fix problems related to bold display with some fonts.
|
[col bind:@"fontSize"
|
||||||
[[c dataCell] setFont:bf];
|
toObject:[NSUserDefaultsController sharedUserDefaultsController]
|
||||||
|
withKeyPath:@"values.fontSize"
|
||||||
|
options:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[NSFontManager sharedFontManager] setSelectedFont:bf isMultiple:NO];
|
|
||||||
|
|
||||||
NSTableHeaderView *currentTableHeaderView = [self headerView];
|
NSTableHeaderView *currentTableHeaderView = [self headerView];
|
||||||
PlaylistHeaderView *customTableHeaderView = [[PlaylistHeaderView alloc] init];
|
PlaylistHeaderView *customTableHeaderView = [[PlaylistHeaderView alloc] init];
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,18 +11,4 @@
|
||||||
|
|
||||||
@implementation SpotlightPlaylistView
|
@implementation SpotlightPlaylistView
|
||||||
|
|
||||||
- (void)awakeFromNib
|
|
||||||
{
|
|
||||||
[super awakeFromNib];
|
|
||||||
|
|
||||||
// We don't want the font to be bold
|
|
||||||
NSFontManager *fontManager = [NSFontManager sharedFontManager];
|
|
||||||
|
|
||||||
for(NSTableColumn *c in self.tableColumns)
|
|
||||||
{
|
|
||||||
[c.dataCell setFont:[fontManager convertFont:[c.dataCell font]
|
|
||||||
toHaveTrait:NSUnboldFontMask]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
//
|
||||||
|
// FontSizetoLineHeightTransformer.h
|
||||||
|
// Cog
|
||||||
|
//
|
||||||
|
// Created by Matthew Grinshpun on 18/02/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
|
||||||
|
@interface FontSizetoLineHeightTransformer : NSValueTransformer {}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,34 @@
|
||||||
|
//
|
||||||
|
// FontSizetoLineHeightTransformer.m
|
||||||
|
// Cog
|
||||||
|
//
|
||||||
|
// Created by Matthew Grinshpun on 18/02/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "FontSizetoLineHeightTransformer.h"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation FontSizetoLineHeightTransformer
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
NSValueTransformer *fontSizetoLineHeightTransformer =
|
||||||
|
[[[FontSizetoLineHeightTransformer alloc] init]autorelease];
|
||||||
|
[NSValueTransformer setValueTransformer:fontSizetoLineHeightTransformer
|
||||||
|
forName:@"FontSizetoLineHeightTransformer"];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (Class)transformedValueClass { return [NSNumber class]; }
|
||||||
|
+ (BOOL)allowsReverseTransformation { return NO; }
|
||||||
|
|
||||||
|
// Convert from font size to height in playlist view
|
||||||
|
- (id)transformedValue:(id)value {
|
||||||
|
NSFont *font = [NSFont systemFontOfSize:[(NSNumber *)value floatValue]];
|
||||||
|
NSLayoutManager *layoutManager = [[NSLayoutManager alloc]init];
|
||||||
|
float fRowSize = [layoutManager defaultLineHeightForFont:font];
|
||||||
|
[layoutManager release];
|
||||||
|
return [NSNumber numberWithFloat: fRowSize];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in New Issue