Jonathan del Strother
unread,Nov 16, 2009, 5:01:49 AM11/16/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gitx
---
PBGitDefaults.h | 2 ++
PBGitDefaults.m | 13 +++++++++++++
PBGitHistoryController.h | 3 +++
PBGitHistoryController.m | 11 +++++++++--
PBGitRevisionCell.h | 1 +
PBGitRevisionCell.m | 12 +++++++++---
6 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/PBGitDefaults.h b/PBGitDefaults.h
index fec2430..8660e51 100644
--- a/PBGitDefaults.h
+++ b/PBGitDefaults.h
@@ -19,5 +19,7 @@
+ (BOOL)showWhitespaceDifferences;
+ (BOOL)openCurDirOnLaunch;
+ (BOOL)showOpenPanelOnLaunch;
++ (CGFloat)historyFontSize;
++ (void)setHistoryFontSize:(CGFloat)newSize;
@end
diff --git a/PBGitDefaults.m b/PBGitDefaults.m
index dc9cfd1..c7738fe 100644
--- a/PBGitDefaults.m
+++ b/PBGitDefaults.m
@@ -17,6 +17,7 @@
#define kShowWhitespaceDifferences @"PBShowWhitespaceDifferences"
#define kOpenCurDirOnLaunch @"PBOpenCurDirOnLaunch"
#define kShowOpenPanelOnLaunch @"PBShowOpenPanelOnLaunch"
+#define kHistoryFontSize @"PBHistoryFontSize"
@implementation PBGitDefaults
@@ -39,6 +40,8 @@ + (void)initialize
forKey:kOpenCurDirOnLaunch];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:kShowOpenPanelOnLaunch];
+ [defaultValues setObject:[NSNumber numberWithFloat:[NSFont systemFontSize]]
+ forKey:kHistoryFontSize];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
}
@@ -82,4 +85,14 @@ + (BOOL)showOpenPanelOnLaunch
return [[NSUserDefaults standardUserDefaults]
boolForKey:kShowOpenPanelOnLaunch];
}
++ (CGFloat)historyFontSize
+{
+ return [[NSUserDefaults standardUserDefaults] floatForKey:kHistoryFontSize];
+}
+
++ (void)setHistoryFontSize:(CGFloat)newSize
+{
+ [[NSUserDefaults standardUserDefaults] setFloat:newSize
forKey:kHistoryFontSize];
+}
+
@end
diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h
index fadb6cd..de44e18 100644
--- a/PBGitHistoryController.h
+++ b/PBGitHistoryController.h
@@ -27,12 +27,15 @@
PBGitCommit* webCommit;
PBGitCommit* rawCommit;
PBGitCommit* realCommit;
+
+ CGFloat fontSize;
}
@property (assign) int selectedTab;
@property (retain) PBGitCommit *webCommit, *rawCommit;
@property (retain) PBGitTree* gitTree;
@property (readonly) NSArrayController *commitController;
+@property (assign) CGFloat fontSize;
- (IBAction) setDetailedView: sender;
- (IBAction) setRawView: sender;
diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m
index a9fde36..0488b65 100644
--- a/PBGitHistoryController.m
+++ b/PBGitHistoryController.m
@@ -11,14 +11,16 @@
#import "PBGitGrapher.h"
#import "PBGitRevisionCell.h"
#import "PBCommitList.h"
+#import "PBGitDefaults.h"
#define QLPreviewPanel NSClassFromString(@"QLPreviewPanel")
-
@implementation PBGitHistoryController
-@synthesize selectedTab, webCommit, rawCommit, gitTree, commitController;
+@synthesize selectedTab, webCommit, rawCommit, gitTree,
commitController, fontSize;
- (void)awakeFromNib
{
+ self.fontSize = [PBGitDefaults historyFontSize];
+
self.selectedTab = [[NSUserDefaults standardUserDefaults]
integerForKey:@"Repository Window Selected Tab Index"];;
[commitController addObserver:self forKeyPath:@"selection"
options:(NSKeyValueObservingOptionNew,NSKeyValueObservingOptionOld)
context:@"commitChange"];
[treeController addObserver:self forKeyPath:@"selection" options:0
context:@"treeChange"];
@@ -78,6 +80,11 @@ - (void) setSelectedTab: (int) number
[self updateKeys];
}
+-(void)setFontSize:(CGFloat)newSize {
+ fontSize = newSize;
+ [commitList setRowHeight:ceil(fontSize*1.3)];
+}
+
- (void) observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object change:(NSDictionary *)change context:(void
*)context
{
if ([(NSString *)context isEqualToString: @"commitChange"]) {
diff --git a/PBGitRevisionCell.h b/PBGitRevisionCell.h
index d6aa4ed..f0072ab 100644
--- a/PBGitRevisionCell.h
+++ b/PBGitRevisionCell.h
@@ -16,6 +16,7 @@
PBGitCommit *objectValue;
PBGraphCellInfo *cellInfo;
NSTextFieldCell *textCell;
+ CGFloat fontSize;
IBOutlet PBGitHistoryController *controller;
IBOutlet id<PBRefContextDelegate> contextMenuDelegate;
}
diff --git a/PBGitRevisionCell.m b/PBGitRevisionCell.m
index 98f978b..87c187a 100644
--- a/PBGitRevisionCell.m
+++ b/PBGitRevisionCell.m
@@ -62,7 +62,8 @@ - (void) drawCircleInRect: (NSRect) r
NSPoint origin = r.origin;
NSPoint columnOrigin = { origin.x + columnWidth * c, origin.y};
- NSRect oval = { columnOrigin.x - 5, columnOrigin.y + r.size.height *
0.5 - 5, 10, 10};
+ CGFloat radius = fontSize*0.4;
+ NSRect oval = { columnOrigin.x - radius, columnOrigin.y +
r.size.height * 0.5 - radius, radius*2, radius*2};
NSBezierPath * path = [NSBezierPath bezierPathWithOvalInRect:oval];
@@ -70,7 +71,8 @@ - (void) drawCircleInRect: (NSRect) r
[[NSColor blackColor] set];
[path fill];
- NSRect smallOval = { columnOrigin.x - 3, columnOrigin.y +
r.size.height * 0.5 - 3, 6, 6};
+ CGFloat smallRadius = radius*0.6;
+ NSRect smallOval = { columnOrigin.x - smallRadius, columnOrigin.y +
r.size.height * 0.5 - smallRadius, smallRadius*2, smallRadius*2};
[[NSColor whiteColor] set];
path = [NSBezierPath bezierPathWithOvalInRect:smallOval];
[path fill];
@@ -115,7 +117,7 @@ - (NSMutableDictionary*)
attributesForRefLabelSelected: (BOOL) selected
[style setAlignment:NSCenterTextAlignment];
[attributes setObject:style forKey:NSParagraphStyleAttributeName];
- [attributes setObject:[NSFont fontWithName:@"Helvetica" size:9]
forKey:NSFontAttributeName];
+ [attributes setObject:[NSFont fontWithName:@"Helvetica"
size:ceil(fontSize*0.75)] forKey:NSFontAttributeName];
//if (selected)
// [attributes setObject:[NSColor alternateSelectedControlTextColor]
forKey:NSForegroundColorAttributeName];
@@ -236,6 +238,10 @@ - (void) drawWithFrame: (NSRect) rect inView:(NSView *)view
[textCell setHighlighted: [self isHighlighted]];
[textCell drawWithFrame:rect inView: view];
}
+-(void)setFont:(NSFont*)font {
+ fontSize = font.pointSize;
+ [textCell setFont:font];
+}
- (void) setObjectValue: (PBGitCommit*)object {
[super setObjectValue:[NSValue valueWithNonretainedObject:object]];
--
1.6.5.rc1.44.ga1675.dirty