Moved legacy font substitution to nib2cib to avoid any side effects, linted NSTableColumn, NSTableColumn now uses cibFontForNibFont, finished test app

This commit is contained in:
Aparajita Fishman
2011-03-10 18:13:35 -05:00
parent 10bfeaf8f7
commit 627566465e
14 changed files with 2252 additions and 3224 deletions
-9
View File
@@ -311,15 +311,6 @@ var CPFontNameKey = @"CPFontNameKey",
isBold = [aCoder decodeBoolForKey:CPFontIsBoldKey],
isItalic = [aCoder decodeBoolForKey:CPFontIsItalicKey];
// Substitute configured font for legacy font
if (fontName === _CPFontDefaultSystemFontFace && _CPFontDefaultSystemFontFace !== _CPFontSystemFontFace)
{
fontName = _CPFontSystemFontFace;
if (size === _CPFontDefaultSystemFontSize)
size = _CPFontSystemFontSize;
}
return [self _initWithName:fontName size:size bold:isBold italic:isItalic];
}
@@ -0,0 +1,125 @@
/*
* AppController.j
* test
*
* Created by aparajita on March 9, 2011.
* Copyright 2011, Victory-Heart Productions All rights reserved.
*/
@import <Foundation/CPObject.j>
var fontLabelField = nil,
defaultFontLabelText = @"";
@implementation AppController : CPObject
{
CPWindow theWindow; //this "outlet" is connected automatically by the Cib
CPTextField label1;
CPTextField fontLabel;
CPTableView theTableView;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
}
- (void)awakeFromCib
{
// This is called when the cib is done loading.
// You can implement this method on any object instantiated from a Cib.
// It's a useful hook for setting up current UI values, and other things.
// In this case, we want the window from Cib to become our full browser window
[theWindow setFullPlatformWindow:NO];
fontLabelField = fontLabel;
defaultFontLabelText = [fontLabelField stringValue];
}
- (int)numberOfRowsInTableView:(id)aTableView
{
return 7;
}
- (id)tableView:(id)tableView objectValueForTableColumn:(CPTableColumn)aColumn row:(int)aRow
{
return ["one", "two", "three"][parseInt([aColumn identifier], 10)];
}
@end
@implementation CPView (testApp)
- (void)doMouseEntered
{
[fontLabelField setStringValue:@"View font: " + [[self font] cssString]];
}
- (void)doMouseExited
{
[fontLabelField setStringValue:defaultFontLabelText];
}
@end
@implementation CPControl (testApp)
- (void)awakeFromCib
{
[super awakeFromCib];
var size = [self frameSize],
lineHeight = [[self font] defaultLineHeightForFont],
inset = [self themeAttribute:@"content-inset"],
minSize = [self themeAttribute:@"min-size"],
height = lineHeight + (inset ? inset.top + inset.bottom : 0);
if (minSize)
height = MAX(height, minSize.height);
[self setFrameSize:CGSizeMake(size.width, MAX(size.height, height))];
}
- (void)mouseEntered:(CPEvent)anEvent
{
[self doMouseEntered];
}
- (void)mouseExited:(CPEvent)anEvent
{
[self doMouseExited];
}
- (id)themeAttribute:(CPString)aName
{
try
{
return [self currentValueForThemeAttribute:aName];
}
catch (e)
{
return nil;
}
}
@end
@implementation CPTabView (testApp)
- (void)mouseEntered:(CPEvent)anEvent
{
[_tabs doMouseEntered];
}
- (void)mouseExited:(CPEvent)anEvent
{
[_tabs doMouseExited];
}
@end
@@ -5,6 +5,8 @@
<key>Main cib file base name</key>
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>FontEnhancements</string>
<string>test</string>
<key>CPSystemFontFace</key>
<string>Lucida Grande</string>
</dict>
</plist>
@@ -1,8 +1,8 @@
/*
* Jakefile
* FontEnhancements
* test
*
* Created by aparajita on March 8, 2011.
* Created by aparajita on March 9, 2011.
* Copyright 2011, Victory-Heart Productions All rights reserved.
*/
@@ -15,17 +15,17 @@ var ENV = require("system").env,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os");
app ("FontEnhancements", function(task)
app ("test", function(task)
{
task.setBuildIntermediatesPath(FILE.join("Build", "FontEnhancements.build", configuration));
task.setBuildIntermediatesPath(FILE.join("Build", "test.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("FontEnhancements");
task.setIdentifier("com.aparajitaworld.FontEnhancements");
task.setProductName("test");
task.setIdentifier("com.aparajitaworld.test");
task.setVersion("1.0");
task.setAuthor("Victory-Heart Productions");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("FontEnhancements");
task.setSummary("test");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
@@ -38,7 +38,7 @@ app ("FontEnhancements", function(task)
task.setCompilerFlags("-O");
});
task ("default", ["FontEnhancements"], function()
task ("default", ["test"], function()
{
printResults(configuration);
});
@@ -59,36 +59,36 @@ task ("release", function()
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", "FontEnhancements", "index.html")]);
OS.system(["open", FILE.join("Build", "Debug", "test", "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", "FontEnhancements", "index.html")]);
OS.system(["open", FILE.join("Build", "Release", "test", "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", "FontEnhancements"));
OS.system(["press", "-f", FILE.join("Build", "Release", "FontEnhancements"), FILE.join("Build", "Deployment", "FontEnhancements")]);
FILE.mkdirs(FILE.join("Build", "Deployment", "test"));
OS.system(["press", "-f", FILE.join("Build", "Release", "test"), FILE.join("Build", "Deployment", "test")]);
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", "FontEnhancements"));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "FontEnhancements"), FILE.join("Build", "Desktop", "FontEnhancements", "FontEnhancements.app"));
FILE.mkdirs(FILE.join("Build", "Desktop", "test"));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "test"), FILE.join("Build", "Desktop", "test", "test.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", "FontEnhancements", "FontEnhancements.app", "Contents", "MacOS", "NativeHost"), "-i"]);
OS.system([FILE.join("Build", "Desktop", "test", "test.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, "FontEnhancements"));
print(configuration+" app built at path: "+FILE.join("Build", configuration, "test"));
print("----------------------------");
}
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -4,9 +4,9 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index-debug.html
FontEnhancements
test
Created by aparajita on March 8, 2011.
Created by aparajita on March 9, 2011.
Copyright 2011, Victory-Heart Productions All rights reserved.
-->
<head>
@@ -19,8 +19,9 @@
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<link href='http://fonts.googleapis.com/css?family=Ubuntu,Cabin' rel='stylesheet' type='text/css' />
<title>FontEnhancements</title>
<title>test</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
@@ -77,7 +78,7 @@
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading FontEnhancements...</p></div>");
"Loading test...</p></div>");
</script>
<noscript>
@@ -4,9 +4,9 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index.html
FontEnhancements
test
Created by aparajita on March 8, 2011.
Created by aparajita on March 9, 2011.
Copyright 2011, Victory-Heart Productions All rights reserved.
-->
<head>
@@ -19,8 +19,9 @@
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<link href='http://fonts.googleapis.com/css?family=Ubuntu,Cabin' rel='stylesheet' type='text/css' />
<title>FontEnhancements</title>
<title>test</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
@@ -51,7 +52,7 @@
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading FontEnhancements...</p></div>");
"Loading test...</p></div>");
</script>
<noscript>
@@ -1,8 +1,8 @@
/*
* AppController.j
* FontEnhancements
* test
*
* Created by aparajita on March 8, 2011.
* Created by aparajita on March 9, 2011.
* Copyright 2011, Victory-Heart Productions All rights reserved.
*/
@@ -1,32 +0,0 @@
/*
* AppController.j
* FontEnhancements
*
* Created by aparajita on March 8, 2011.
* Copyright 2011, Victory-Heart Productions All rights reserved.
*/
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
CPWindow theWindow; //this "outlet" is connected automatically by the Cib
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
}
- (void)awakeFromCib
{
// This is called when the cib is done loading.
// You can implement this method on any object instantiated from a Cib.
// It's a useful hook for setting up current UI values, and other things.
// In this case, we want the window from Cib to become our full browser window
[theWindow setFullPlatformWindow:YES];
}
@end
File diff suppressed because it is too large Load Diff
+16 -1
View File
@@ -56,9 +56,24 @@
if (![cibFont isEqual:nibFont])
{
var source = "";
if (!cibFont)
{
cibFont = [theme valueForAttributeWithName:@"font" inState:[object themeState] forClass:[object class]];
if ([cibFont familyName] === "Arial, sans-serif")
{
var size = [cibFont size];
cibFont = [cibFont isBold] ? [CPFont boldSystemFontOfSize:size] : [CPFont systemFontOfSize:size];
source = " (from theme)"
}
}
[object setFont:cibFont];
CPLog.debug("%s: substituted <%s> for <%fpx %s>", [object className], cibFont ? [cibFont cssString] : "theme default", [nibFont size], [nibFont familyName]);
CPLog.debug("%s: substituted <%s>%s for <%fpx %s>", [object className], cibFont ? [cibFont cssString] : "theme default", source, [nibFont size], [nibFont familyName]);
}
}
+10 -7
View File
@@ -45,26 +45,29 @@
else
{
_dataView = [[CPTextField alloc] initWithFrame:CPRectMakeZero()];
var font = [dataViewCell font],
selectedFont = nil;
if (font)
font = [NSFont cibFontForNibFont:font];
if (!font)
font = [CPFont systemFontOfSize:[CPFont systemFontSize]];
var selectedFont = [CPFont boldFontWithName:[font familyName] size:[font size]];
[_dataView setFont:font];
[_dataView setValue:selectedFont forThemeAttribute:@"font" inState:CPThemeStateSelectedDataView];
[_dataView setLineBreakMode:CPLineBreakByTruncatingTail];
[_dataView setValue:CPCenterVerticalTextAlignment forThemeAttribute:@"vertical-alignment"];
[_dataView setValue:CGInsetMake(0.0, 5.0, 0.0, 5.0) forThemeAttribute:@"content-inset"];
var textColor = [dataViewCell textColor],
defaultColor = [_dataView currentValueForThemeAttribute:@"text-color"];
// Don't change the text color if it is not the default, that messes up the theme lookups later
if (![textColor isEqual:defaultColor])
[_dataView setTextColor:[dataViewCell textColor]];