Permalink
Browse files

Highlight current progress

  • Loading branch information...
1 parent 3e4439e commit 0c2ec13535d9440fd90ab818a99a2a69b354537c @jjgod committed Jul 17, 2012
Showing with 43 additions and 12 deletions.
  1. +9 −9 English.lproj/TTDocument.xib
  2. +1 −0 TTProgressView.h
  3. +29 −2 TTProgressView.m
  4. +4 −1 TTTextView.mm
@@ -111,7 +111,7 @@
<string key="NSFrame">{{1, 752}, {924, 15}}</string>
<reference key="NSSuperview" ref="707828383"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="591354529"/>
+ <reference key="NSNextKeyView" ref="214846958"/>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="707828383"/>
@@ -134,7 +134,7 @@
<object class="NSTextField" id="1067187668">
<reference key="NSNextResponder" ref="568628114"/>
<int key="NSvFlags">289</int>
- <string key="NSFrame">{{730, 1}, {63, 17}}</string>
+ <string key="NSFrame">{{759, 1}, {34, 17}}</string>
<reference key="NSSuperview" ref="568628114"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
@@ -157,15 +157,15 @@
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlTextColor</string>
- <object class="NSColor" key="NSColor" id="942274167">
+ <object class="NSColor" key="NSColor" id="794668281">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
- <object class="NSCustomView" id="591354529">
+ <object class="NSCustomView" id="214846958">
<reference key="NSNextResponder" ref="568628114"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{0, 1}, {767, 17}}</string>
@@ -233,14 +233,14 @@
<object class="IBOutletConnection" key="connection">
<string key="label">progressView</string>
<reference key="source" ref="793227834"/>
- <reference key="destination" ref="591354529"/>
+ <reference key="destination" ref="214846958"/>
</object>
<int key="connectionID">100049</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">statusField</string>
- <reference key="source" ref="591354529"/>
+ <reference key="source" ref="214846958"/>
<reference key="destination" ref="1067187668"/>
</object>
<int key="connectionID">100048</int>
@@ -286,7 +286,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="707828383"/>
<reference ref="1067187668"/>
- <reference ref="591354529"/>
+ <reference ref="214846958"/>
</object>
<reference key="parent" ref="275939982"/>
</object>
@@ -346,7 +346,7 @@
</object>
<object class="IBObjectRecord">
<int key="objectID">100047</int>
- <reference key="object" ref="591354529"/>
+ <reference key="object" ref="214846958"/>
<reference key="parent" ref="568628114"/>
</object>
</object>
@@ -388,7 +388,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<real value="0.0"/>
- <reference ref="942274167"/>
+ <reference ref="794668281"/>
<real value="0.0"/>
<real value="0.0"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
View
@@ -10,6 +10,7 @@
@interface TTProgressView : NSView {
IBOutlet NSTextField *statusField;
+ NSPoint currentPoint;
}
@end
View
@@ -14,27 +14,54 @@ - (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
- // Initialization code here.
+ // TODO: figure out why 50 padding is needed here
+ CGFloat width = frame.size.width + 50;
+ NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect: NSMakeRect(0, 0, width, frame.size.height)
+ options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow )
+ owner: self
+ userInfo: nil];
+ [self addTrackingArea: trackingArea];
+ [trackingArea release];
}
return self;
}
+- (void)mouseEntered:(NSEvent *)theEvent
+{
+ [[self window] setAcceptsMouseMovedEvents: YES];
+}
+
+- (void)mouseMoved:(NSEvent *)theEvent
+{
+ currentPoint = [self convertPoint: theEvent.locationInWindow fromView: nil];
+ [self setNeedsDisplay: YES];
+}
+
+- (void)mouseExited:(NSEvent *)theEvent
+{
+ [[self window] setAcceptsMouseMovedEvents: NO];
+}
+
- (void)drawRect:(NSRect)dirtyRect
{
// Drawing code here.
[[NSColor darkGrayColor] setFill];
CGFloat width = self.frame.size.width / 50;
int i;
+ CGFloat r;
int p = [statusField integerValue];
bool unread = false;
for (i = 1; i < 50; i++) {
if (p < i * 2 && !unread) {
[[NSColor lightGrayColor] setFill];
unread = true;
}
+ r = 3;
+ if (ABS(currentPoint.x - i * width) < 5)
+ r = 6;
// Create our circle path
- NSRect rect = NSMakeRect(i * width, 7, 3, 3);
+ NSRect rect = NSMakeRect(i * width - r / 2, 8.5 - r / 2, r, r);
NSBezierPath *circlePath = [NSBezierPath bezierPath];
[circlePath appendBezierPathWithOvalInRect: rect];
[circlePath fill];
View
@@ -86,8 +86,11 @@ - (void) invalidateLayout
for (start = 0; start < text.length; start += length) {
length = CTTypesetterSuggestLineBreak(typesetter, start, frameRect.size.width);
- if (length == 1 && CFStringGetCharacterAtIndex(str, start) == '\n')
+
+ UniChar startChar = CFStringGetCharacterAtIndex(str, start);
+ if (length == 1 && startChar == '\n')
continue;
+
lineData.line = CTTypesetterCreateLine(typesetter, CFRangeMake(start, length));
CGFloat ascent, descent, leading;
double width = CTLineGetTypographicBounds(lineData.line, &ascent, &descent, &leading);

0 comments on commit 0c2ec13

Please sign in to comment.