Skip to content
Browse files

full-navigation UI updated.

- sel-box is re-implemented as a subview.
- sel-box has texture from FrontRow. (but, it's ugly impl.)
- selected item's name can be scrolled horizontally if needed.

NewVersionChecker is renamed to UpdateChecker.



git-svn-id: http://movist.googlecode.com/svn/trunk@98 9988c26d-9134-0410-b5bb-5778289bb252
  • Loading branch information...
1 parent 825b212 commit 3d0bdc847ed5021ee66e93bf86fd8b1a553e2bf4 cocoable committed Dec 19, 2007
View
18 AppController.m
@@ -21,7 +21,7 @@
//
#import "AppController.h"
-#import "NewVersionChecker.h"
+#import "UpdateChecker.h"
#import "UserDefaults.h"
#import "MMovie_FFMPEG.h"
@@ -291,12 +291,12 @@ - (void)checkForUpdates:(BOOL)manual
[_movieView display];
NSError* error;
- NewVersionChecker* checker = [[NewVersionChecker alloc] init];
- int ret = [checker checkNewVersion:&error];
+ UpdateChecker* checker = [[UpdateChecker alloc] init];
+ int ret = [checker checkUpdate:&error];
[_defaults setObject:[NSDate date] forKey:MLastUpdateCheckTimeKey];
[_preferenceController updateLastUpdateCheckTimeTextField];
- if (ret == NEW_VERSION_CHECK_FAILED) {
+ if (ret == UPDATE_CHECK_FAILED) {
NSString* s = [NSString stringWithFormat:@"%@", error];
if (manual) { // only for manual checking
NSRunAlertPanel([NSApp localizedAppName], s,
@@ -306,8 +306,8 @@ - (void)checkForUpdates:(BOOL)manual
[_movieView setMessage:s];
}
}
- else if (ret == NEW_VERSION_NONE) {
- NSString* s = NSLocalizedString(@"No new version", nil);
+ else if (ret == NO_UPDATE_AVAILABLE) {
+ NSString* s = NSLocalizedString(@"No update available.", nil);
if (manual) { // only for manual checking
NSRunAlertPanel([NSApp localizedAppName], s,
NSLocalizedString(@"OK", nil), nil, nil);
@@ -316,15 +316,15 @@ - (void)checkForUpdates:(BOOL)manual
[_movieView setMessage:s];
}
}
- else if (ret == NEW_VERSION_IS_AVAILABLE) {
+ else if (ret == NEW_VERSION_AVAILABLE) {
// new version alert always show.
NSString* newVersion = [checker newVersion];
NSURL* newVersionURL = [checker newVersionURL];
NSString* s = [NSString stringWithFormat:
- NSLocalizedString(@"New version is available. (v%@)", nil),
+ NSLocalizedString(@"New version %@ is available.", nil),
newVersion];
ret = NSRunAlertPanel([NSApp localizedAppName], s,
- NSLocalizedString(@"Show New Version", nil),
+ NSLocalizedString(@"Show Updates", nil),
NSLocalizedString(@"Cancel", nil), nil);
if (ret == NSAlertDefaultReturn) {
[[NSWorkspace sharedWorkspace] openURL:newVersionURL];
View
7 English.lproj/Localizable.strings
@@ -1,13 +1,12 @@
/* App General */
-"Unsupported OS Version Warning" = "Movist supports only Mac OS X 10.4 or higher";
"Cancel" = "Cancel";
"Decoder" = "Decoder";
/* Check for Updates */
"Checking for Updates..." = "Checking for Updates...";
-"No new version" = "No new version";
-"New version is available. (v%@)" = "New version is available. (v%@)";
-"Show New Version" = "Show New Version";
+"No update available." = "No update available.";
+"New version %@ is available." = "New version %@ is available.";
+"Show Updates" = "Show Updates";
/* MainMenu: File */
"Opening with %@..." = "Opening with %@...";
View
19 FullNavListView.h
@@ -21,23 +21,34 @@
//
#import "Movist.h"
+#import <QuartzCore/QuartzCore.h>
@class FullNavList;
@interface FullNavListView : NSView
{
FullNavList* _list;
- int _listItemHeight;
- NSWindow* _selBox;
+ float _itemHeight;
+ NSView* _selBox;
NSViewAnimation* _animation;
+
+ // list vscroll-fade gradation
+ CIFilter* _tFilter;
+ CIFilter* _bFilter;
+
+ // item hscroll-fade gradation
+ CIFilter* _lFilter;
+ CIFilter* _rFilter;
+ NSTimer* _itemScrollTimer;
+ NSRect _itemScrollRect;
+ float _itemScrollSize;
}
- (id)initWithFrame:(NSRect)frame window:(NSWindow*)window;
- (void)setNavList:(FullNavList*)list;
-- (void)showSelBox;
-- (void)hideSelBox;
+- (NSView*)createSelBox;
- (void)slideSelBox;
@end
View
415 FullNavListView.m
@@ -25,83 +25,68 @@
#import "FullNavView.h"
#import "FullNavItems.h"
-@interface FullNavSelBox : NSWindow
-{
-}
+@interface FullNavItem (Drawing)
+
+- (void)drawInRect:(NSRect)rect withAttributes:(NSDictionary*)attrs;
+- (void)drawInRect:(NSRect)rect withAttributes:(NSDictionary*)attrs
+ scrollSize:(float)scrollSize
+ nameSize:(NSSize*)nameSize nameRect:(NSRect*)nameRect;
@end
-@implementation FullNavSelBox
+@implementation FullNavItem (Drawing)
-- (id)initWithFrameRect:(NSRect)frameRect window:(NSWindow*)window
+- (void)drawInRect:(NSRect)rect withAttributes:(NSDictionary*)attrs
{
- TRACE(@"%s", __PRETTY_FUNCTION__);
- unsigned int styleMask = NSBorderlessWindowMask;
-#if defined(AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER)
- styleMask |= NSUnscaledWindowMask;
-#endif
- if (self = [super initWithContentRect:frameRect
- styleMask:styleMask
- backing:NSBackingStoreBuffered
- defer:FALSE
- screen:[window screen]]) {
- [self setLevel:[window level] + 1];
- //[self setHasShadow:TRUE];
- [self setOpaque:FALSE];
- [self setAlphaValue:1.0];
-
- NSRect rect = [[self contentView] bounds];
- NSSize bgSize = rect.size;
- NSImage* bg = [[[NSImage alloc] initWithSize:bgSize] autorelease];
- [bg lockFocus];
-
- NSBezierPath* path = [NSBezierPath bezierPathWithRect:rect];
- [path setLineWidth:5.0];
- [[NSColor yellowColor] set];
- [path stroke];
-
- [bg unlockFocus];
-
- [self setBackgroundColor:[NSColor colorWithPatternImage:bg]];
- }
- return self;
+ [self drawInRect:rect withAttributes:attrs
+ scrollSize:0 nameSize:nil nameRect:nil];
}
-/*
-- (void)dealloc
-{
- TRACE(@"%s", __PRETTY_FUNCTION__);
- [super dealloc];
-}
-*/
-@end
-
-////////////////////////////////////////////////////////////////////////////////
-#pragma mark
-
-@interface FullNavItem (ListView)
-- (void)drawInListRect:(NSRect)rect withAttributes:(NSDictionary*)attrs;
-
-@end
-
-@implementation FullNavItem (ListView)
-
-- (void)drawInListRect:(NSRect)rect withAttributes:(NSDictionary*)attrs
+- (void)drawInRect:(NSRect)rect withAttributes:(NSDictionary*)attrs
+ scrollSize:(float)scrollSize
+ nameSize:(NSSize*)nameSize nameRect:(NSRect*)nameRect
{
- //TRACE(@"%s name=\"%@\"", __PRETTY_FUNCTION__, _name);
float LEFT_MARGIN = 0;
- float CONTAINER_MARK_WIDTH = (float)(int)(rect.size.width * 0.085);
+ float CONTAINER_MARK_WIDTH = (float)(int)(rect.size.width * 0.05);
NSSize size = [_name sizeWithAttributes:attrs];
- NSRect rc;
- rc.origin.x = rect.origin.x + LEFT_MARGIN;
- rc.origin.y = rect.origin.y + (rect.size.height - size.height) / 2;
- rc.size.width = rect.size.width - LEFT_MARGIN - CONTAINER_MARK_WIDTH;
- rc.size.height = size.height;
- [_name drawInRect:rc withAttributes:attrs];
+ NSRect rc = NSMakeRect(rect.origin.x + LEFT_MARGIN,
+ rect.origin.y + (rect.size.height - size.height) / 2,
+ rect.size.width - LEFT_MARGIN,
+ size.height);
+ if ([self hasSubContents]) {
+ rc.size.width -= CONTAINER_MARK_WIDTH;
+ }
+ if (nameSize) {
+ *nameSize = size;
+ }
+ if (nameRect) {
+ *nameRect = rc;
+ //[[NSColor cyanColor] set];
+ //NSFrameRect(*nameRect);
+ }
+ float unitSize = size.width + 100; // gap between name & name
+ if (unitSize < scrollSize) {
+ scrollSize -= unitSize;
+ }
+ if (0 == scrollSize) {
+ [_name drawInRect:rc withAttributes:attrs];
+ }
+ else {
+ rc.origin.x -= scrollSize;
+ rc.size.width += scrollSize;
+ [_name drawInRect:rc withAttributes:attrs];
+
+ if (unitSize < rc.size.width) {
+ rc.origin.x += unitSize;
+ rc.size.width -= unitSize;
+ [_name drawInRect:rc withAttributes:attrs];
+ }
+ }
+ // container mark
if ([self hasSubContents]) {
rc.size.width = CONTAINER_MARK_WIDTH;
- rc.origin.x = NSMaxX(rect) - rc.size.width;
+ rc.origin.x = NSMaxX(rect) - rc.size.width + 5;
[@">" drawInRect:rc withAttributes:attrs];
}
//[[NSColor greenColor] set];
@@ -113,63 +98,56 @@ - (void)drawInListRect:(NSRect)rect withAttributes:(NSDictionary*)attrs
////////////////////////////////////////////////////////////////////////////////
#pragma mark
-@interface FullNavListView (Private)
+@interface FullNavSelBox : NSView
+{
+ NSImage* _bgImage;
+}
-- (int)topIndex;
-- (NSRect)listViewRect;
-- (NSRect)selBoxRect;
+- (id)initWithFrame:(NSRect)frame;
@end
-@implementation FullNavListView (Private)
+@implementation FullNavSelBox
-- (int)topIndex
+- (id)initWithFrame:(NSRect)frame
{
- NSRect rc = [[self superview] bounds];
- int visibleCount = rc.size.height / _listItemHeight;
- int halfCount = visibleCount / 2 - ((visibleCount % 2) ? 0 : 1);
- int sel = [_list selectedIndex];
- if ([_list count] <= visibleCount || sel <= halfCount) {
- return 0;
- }
- else if (sel < [_list count] - visibleCount / 2) {
- return sel - halfCount;
- }
- else {
- return [_list count] - visibleCount;
+ if (self = [super initWithFrame:frame]) {
+ NSSize size = frame.size;
+ _bgImage = [[NSImage alloc] initWithSize:size];
+ [_bgImage lockFocus];
+ NSImage* lImage = [NSImage imageNamed:@"FSNavSelBoxLeft"];
+ NSImage* cImage = [NSImage imageNamed:@"FSNavSelBoxCenter"];
+ NSImage* rImage = [NSImage imageNamed:@"FSNavSelBoxRight"];
+ NSRect rc;
+ rc.origin.x = 0, rc.size.width = [lImage size].width;
+ rc.origin.y = 0, rc.size.height = size.height;
+ [lImage drawInRect:rc fromRect:NSZeroRect
+ operation:NSCompositeSourceOver fraction:1.0];
+ rc.origin.x = size.width - [rImage size].width;
+ rc.size.width = [rImage size].width;
+ [rImage drawInRect:rc fromRect:NSZeroRect
+ operation:NSCompositeSourceOver fraction:1.0];
+ rc.origin.x = [lImage size].width;
+ rc.size.width = size.width - [lImage size].width - [rImage size].width;
+ [cImage drawInRect:rc fromRect:NSZeroRect
+ operation:NSCompositeSourceOver fraction:1.0];
+ //[[NSColor redColor] set];
+ //NSFrameRect([self bounds]);
+ [_bgImage unlockFocus];
}
+ return self;
}
-- (NSRect)listViewRect
+- (void)dealloc
{
- float height = [_list count] * _listItemHeight;
-
- NSRect rc = [[self superview] bounds];
- rc.origin.y = NSMaxY(rc) - height;
- rc.size.height = height;
-
- rc.origin.y += [self topIndex] * _listItemHeight;
- TRACE(@"listViewRect=%@", NSStringFromRect(rc));
- return rc;
+ [_bgImage release];
+ [super dealloc];
}
-#define SEL_BOX_MARGIN(rc) (float)(int)(rc.size.width * 0.05)
-
-- (NSRect)selBoxRect
+- (void)drawRect:(NSRect)rect
{
- if ([_list count] == 0) {
- return NSZeroRect;
- }
- else {
- NSRect rc = [[self superview] bounds];
- float margin = SEL_BOX_MARGIN(rc);
- rc.origin.x -= margin;
- rc.size.width += margin * 2;
- rc.origin.y = NSMaxY(rc) - _listItemHeight -
- ([_list selectedIndex] - [self topIndex]) * _listItemHeight;
- rc.size.height = _listItemHeight;
- return [[self superview] convertRect:rc toView:nil];
- }
+ [_bgImage drawInRect:[self bounds] fromRect:NSZeroRect
+ operation:NSCompositePlusLighter fraction:1.0];
}
@end
@@ -179,25 +157,62 @@ - (NSRect)selBoxRect
@implementation FullNavListView
+#define ITEM_HSCROLL_FADE_SIZE _itemHeight
+
- (id)initWithFrame:(NSRect)frame window:(NSWindow*)window
{
if (self = [super initWithFrame:frame]) {
- _listItemHeight = frame.size.height / 10;
-
- NSRect rc = [self bounds];
- rc.size.width += SEL_BOX_MARGIN(rc) * 2;
- rc.size.height = _listItemHeight;
- _selBox = [[FullNavSelBox alloc] initWithFrameRect:rc window:window];
+ _itemHeight = (float)(int)(frame.size.height / 10);
+
+ CIColor* c0 = [CIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
+ CIColor* c1 = [CIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
+ CIVector* p0 = [CIVector vectorWithX:0 Y:_itemHeight];
+ CIVector* p1 = [CIVector vectorWithX:0 Y:0];
+ _tFilter = [[CIFilter filterWithName:@"CILinearGradient"] retain];
+ [_tFilter setValue:p0 forKey:@"inputPoint0"];
+ [_tFilter setValue:p1 forKey:@"inputPoint1"];
+ [_tFilter setValue:c0 forKey:@"inputColor0"];
+ [_tFilter setValue:c1 forKey:@"inputColor1"];
+
+ p0 = [CIVector vectorWithX:0 Y:0];
+ p1 = [CIVector vectorWithX:0 Y:_itemHeight];
+ _bFilter = [[CIFilter filterWithName:@"CILinearGradient"] retain];
+ [_bFilter setValue:p0 forKey:@"inputPoint0"];
+ [_bFilter setValue:p1 forKey:@"inputPoint1"];
+ [_bFilter setValue:c0 forKey:@"inputColor0"];
+ [_bFilter setValue:c1 forKey:@"inputColor1"];
+
+ p0 = [CIVector vectorWithX:0 Y:0];
+ p1 = [CIVector vectorWithX:ITEM_HSCROLL_FADE_SIZE Y:0];
+ _lFilter = [[CIFilter filterWithName:@"CILinearGradient"] retain];
+ [_lFilter setValue:p0 forKey:@"inputPoint0"];
+ [_lFilter setValue:p1 forKey:@"inputPoint1"];
+ [_lFilter setValue:c0 forKey:@"inputColor0"];
+ [_lFilter setValue:c1 forKey:@"inputColor1"];
+
+ p0 = [CIVector vectorWithX:ITEM_HSCROLL_FADE_SIZE Y:0];
+ p1 = [CIVector vectorWithX:0 Y:0];
+ _rFilter = [[CIFilter filterWithName:@"CILinearGradient"] retain];
+ [_rFilter setValue:p0 forKey:@"inputPoint0"];
+ [_rFilter setValue:p1 forKey:@"inputPoint1"];
+ [_rFilter setValue:c0 forKey:@"inputColor0"];
+ [_rFilter setValue:c1 forKey:@"inputColor1"];
}
return self;
}
- (void)dealloc
{
- [self hideSelBox];
+ [_rFilter release];
+ [_lFilter release];
+ [_bFilter release];
+ [_tFilter release];
[super dealloc];
}
+////////////////////////////////////////////////////////////////////////////////
+#pragma mark
+
- (void)drawRect:(NSRect)rect
{
//TRACE(@"%s rect=%@", __PRETTY_FUNCTION__, NSStringFromRect(rect));
@@ -215,59 +230,161 @@ - (void)drawRect:(NSRect)rect
[attrs setObject:[NSFont boldSystemFontOfSize:38 * br.size.width / 640.0]
forKey:NSFontAttributeName];
- NSRect r;
+ CIContext* ciContext = [[NSGraphicsContext currentContext] CIContext];
+
+ NSSize ns;
+ NSRect r, nr;
r.size.width = br.size.width;
- r.size.height = _listItemHeight;
+ r.size.height = _itemHeight;
r.origin.x = br.origin.x;
- r.origin.y = NSMaxY(br) - _listItemHeight;
+ r.origin.y = NSMaxY(br) - _itemHeight;
+ CGPoint fadePoint;
+ CGRect fadeRect = CGRectMake(0, 0, ITEM_HSCROLL_FADE_SIZE, r.size.height);
int i, count = [_list count];
for (i = 0; i < count; i++) {
if (NSIntersectsRect(rect, r)) {
- if (i == [_list selectedIndex]) {
- [attrs setObject:[NSColor yellowColor]
- forKey:NSForegroundColorAttributeName];
- [[_list itemAtIndex:i] drawInListRect:r withAttributes:attrs];
+ if (i != [_list selectedIndex]) {
+ [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
+ [[_list itemAtIndex:i] drawInRect:r withAttributes:attrs];
}
else {
- [attrs setObject:[NSColor colorWithDeviceWhite:0.95 alpha:1.0]
- forKey:NSForegroundColorAttributeName];
- [[_list itemAtIndex:i] drawInListRect:r withAttributes:attrs];
+ [paragraphStyle setLineBreakMode:NSLineBreakByClipping];
+ [[_list itemAtIndex:i] drawInRect:r withAttributes:attrs
+ scrollSize:_itemScrollSize
+ nameSize:&ns nameRect:&nr];
+
+ if (nr.size.width < ns.width) {
+ fadePoint.y = NSMinY(r);
+ fadePoint.x = NSMinX(nr);
+ if (0 < _itemScrollSize) {
+ [ciContext drawImage:[_lFilter valueForKey:@"outputImage"]
+ atPoint:fadePoint fromRect:fadeRect];
+ }
+ fadePoint.x = NSMaxX(nr) - ITEM_HSCROLL_FADE_SIZE;
+ [ciContext drawImage:[_rFilter valueForKey:@"outputImage"]
+ atPoint:fadePoint fromRect:fadeRect];
+ if (_itemScrollRect.size.width == 0) {
+ _itemScrollRect = nr;
+ [NSTimer scheduledTimerWithTimeInterval:1.0
+ target:self selector:@selector(startScrollTimer:)
+ userInfo:nil repeats:FALSE];
+ }
+ }
}
}
r.origin.y -= r.size.height;
}
+ rect = [self visibleRect];
+ if (rect.size.height < _itemHeight * count) { // vertical scrollable
+ NSRect fr = [self frame];
+ if (rect.size.height < NSMaxY(fr)) {
+ [ciContext drawImage:[_tFilter valueForKey:@"outputImage"]
+ atPoint:CGPointMake(NSMinX(rect), NSMaxY(rect) - _itemHeight)
+ fromRect:CGRectMake(0, 0, rect.size.width, _itemHeight)];
+ }
+ if (fr.origin.y < 0) {
+ [ciContext drawImage:[_bFilter valueForKey:@"outputImage"]
+ atPoint:CGPointMake(NSMinX(rect), NSMinY(rect))
+ fromRect:CGRectMake(0, 0, rect.size.width, _itemHeight)];
+ }
+ }
+
//[[NSColor yellowColor] set];
//NSFrameRect(br);
}
-- (void)setNavList:(FullNavList*)list
+////////////////////////////////////////////////////////////////////////////////
+#pragma mark
+
+- (void)startScrollTimer:(NSTimer*)timer
+{
+ if (0 < _itemScrollRect.size.width) {
+ _itemScrollSize = 0;
+ _itemScrollTimer = [NSTimer scheduledTimerWithTimeInterval:0.01
+ target:self selector:@selector(scrollItemName:)
+ userInfo:nil repeats:TRUE];
+ }
+}
+
+- (void)scrollItemName:(NSTimer*)timer
+{
+ _itemScrollSize++;
+ [self setNeedsDisplayInRect:_itemScrollRect];
+}
+
+- (void)resetItemScroll
{
TRACE(@"%s", __PRETTY_FUNCTION__);
- _list = list; // no retain
+ _itemScrollRect.size.width = 0;
+ _itemScrollSize = 0;
+ [_itemScrollTimer invalidate];
+ _itemScrollTimer = nil;
+}
- [self setFrame:[self listViewRect]];
- [_selBox setFrame:[self selBoxRect] display:TRUE];
- [_selBox orderFront:self];
- [[self superview] display];
- [self display];
+- (int)topIndex
+{
+ NSRect rc = [[self superview] bounds];
+ int visibleCount = rc.size.height / _itemHeight;
+ int halfCount = visibleCount / 2 - ((visibleCount % 2) ? 0 : 1);
+ int sel = [_list selectedIndex];
+ if ([_list count] <= visibleCount || sel <= halfCount) {
+ return 0;
+ }
+ else if (sel < [_list count] - visibleCount / 2) {
+ return sel - halfCount;
+ }
+ else {
+ return [_list count] - visibleCount;
+ }
}
-- (void)showSelBox
+- (NSRect)calcViewRect
{
- [_selBox orderFront:self];
- [[self window] addChildWindow:_selBox ordered:NSWindowAbove];
+ float height = [_list count] * _itemHeight;
+
+ NSRect rc = [[self superview] bounds];
+ rc.origin.y = NSMaxY(rc) - height;
+ rc.size.height = height;
+
+ rc.origin.y += [self topIndex] * _itemHeight;
+ //TRACE(@"listViewRect=%@", NSStringFromRect(rc));
+ return rc;
}
-- (void)hideSelBox
+#define SEL_BOX_HMARGIN 60
+#define SEL_BOX_VMARGIN 37
+
+- (NSView*)createSelBox
{
- [[self window] removeChildWindow:_selBox];
- [_selBox orderOut:self];
+ // cannot use -selBoxRect here because it refers _selBox.
+ NSRect frame = [self bounds];
+ frame.size.width += SEL_BOX_HMARGIN * 2;
+ frame.size.height = _itemHeight + SEL_BOX_VMARGIN * 2;
+ _selBox = [[FullNavSelBox alloc] initWithFrame:frame];
+ return _selBox;
+}
+
+- (NSRect)selBoxRect
+{
+ if ([_list count] == 0) {
+ return NSZeroRect;
+ }
+ else {
+ NSRect rc = [[self superview] bounds];
+ rc.origin.y = NSMaxY(rc) - _itemHeight -
+ ([_list selectedIndex] - [self topIndex]) * _itemHeight;
+ rc.size.height = _itemHeight;
+ rc = NSInsetRect(rc, -SEL_BOX_HMARGIN, -SEL_BOX_VMARGIN);
+ return [[self superview] convertRect:rc toView:[_selBox superview]];
+ }
}
- (void)slideSelBox
{
TRACE(@"%s", __PRETTY_FUNCTION__);
+ [self resetItemScroll];
+
if (_animation && [_animation isAnimating]) {
[_animation stopAnimation];/*
NSArray* array = [_animation viewAnimations];
@@ -277,13 +394,13 @@ - (void)slideSelBox
[self display];
dict = [array objectAtIndex:1];
value = [dict objectForKey:NSViewAnimationEndFrameKey];
- [_selBox setFrame:[value rectValue] display:TRUE];*/
+ [_selBox setFrame:[value rectValue]];*/
[_animation release];
}
- NSRect frame = [self listViewRect];
+ NSRect frame = [self calcViewRect];
NSRect selBoxRect = [self selBoxRect];
-
+
NSArray* array = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
self, NSViewAnimationTargetKey,
@@ -314,4 +431,20 @@ - (void)animatioinDidEnd:(NSAnimation*)animation
}
}
+////////////////////////////////////////////////////////////////////////////////
+#pragma mark
+
+- (void)setNavList:(FullNavList*)list
+{
+ TRACE(@"%s", __PRETTY_FUNCTION__);
+ [self resetItemScroll];
+
+ _list = list; // no retain
+
+ [self setFrame:[self calcViewRect]];
+ [[self superview] display];
+ [_selBox setFrame:[self selBoxRect]];
+ [[_selBox superview] display];
+}
+
@end
View
1 FullNavView.h
@@ -36,6 +36,7 @@
FullNavTitleView* _titleView;
FullNavListView* _listView;
+ NSDate* _lastUpDownKeyTime;
}
- (id)initWithFrame:(NSRect)rect movieView:(MMovieView*)movieView;
View
49 FullNavView.m
@@ -121,6 +121,9 @@ - (void)drawRect:(NSRect)rect
@implementation FullNavView
+#define SEL_BOX_HMARGIN 60
+#define SEL_BOX_VMARGIN 16
+
- (id)initWithFrame:(NSRect)rect movieView:(MMovieView*)movieView
{
if (self = [super initWithFrame:rect]) {
@@ -130,16 +133,21 @@ - (id)initWithFrame:(NSRect)rect movieView:(MMovieView*)movieView
float gap = (float)(int)(rect.size.height * 0.025);
float listHeight = (float)(int)(rect.size.height * 0.66);
float BOTTOM_MARGIN = (float)(int)(rect.size.height * 0.115);
+ float LEFT_MARGIN = (float)(int)(rect.size.width * 0.075);
+ float RIGHT_MARGIN = (float)(int)(rect.size.width * 0.195);
- // list view
+ // list view & sel-box
rect = [self bounds];
+ rect.origin.x += LEFT_MARGIN;
+ rect.size.width -= LEFT_MARGIN + RIGHT_MARGIN;
rect.origin.y = BOTTOM_MARGIN;
rect.size.height = listHeight;
NSView* lcv = [[FullNavListContainerView alloc] initWithFrame:rect];
_listView = [[FullNavListView alloc] initWithFrame:[lcv bounds]
window:[movieView window]];
- [self addSubview:[lcv autorelease]];
[lcv addSubview:_listView];
+ [self addSubview:[lcv autorelease]];
+ [self addSubview:[_listView createSelBox]];
// title view
rect.origin.y += listHeight + gap;
@@ -167,32 +175,36 @@ - (void)drawRect:(NSRect)rect
NSFrameRect([self bounds]);
}
*/
-- (void)setHidden:(BOOL)hidden
-{
- (hidden) ? [_listView hideSelBox] : [_listView showSelBox];
- [super setHidden:hidden];
-}
-
- (void)keyDown:(NSEvent*)event
{
//TRACE(@"%s \"%@\" (modifierFlags=%u)", __PRETTY_FUNCTION__,
// [event characters], [event modifierFlags]);
unichar key = [[event characters] characterAtIndex:0];
//unsigned int modifierFlags = [event modifierFlags] &
// (NSCommandKeyMask | NSAlternateKeyMask | NSControlKeyMask | NSShiftKeyMask);
+ NSDate* now = [NSDate date];
switch (key) {
case NSUpArrowFunctionKey : // up arrow
- [self selectUpper];
- break;
case NSDownArrowFunctionKey : // down arrow
- [self selectLower];
+ if (!_lastUpDownKeyTime ||
+ 0.02 <= [now timeIntervalSinceDate:_lastUpDownKeyTime]) {
+ if (key == NSUpArrowFunctionKey) {
+ [self selectUpper];
+ }
+ else {
+ [self selectLower];
+ }
+ _lastUpDownKeyTime = [now retain];
+ }
break;
+
case ' ' : // space: toggle play/pause
case NSCarriageReturnCharacter : // return : toggle full-screen
case NSEnterCharacter : // enter (in keypad)
//case NSRightArrowFunctionKey : // right arrow
[self openCurrent];
break;
+
case 27 : // ESC
//case NSBackspaceCharacter : // backsapce
//case NSLeftArrowFunctionKey : // left arrow
@@ -203,6 +215,19 @@ - (void)keyDown:(NSEvent*)event
}
}
+- (void)keyUp:(NSEvent*)event
+{
+ //TRACE(@"%s \"%@\"", __PRETTY_FUNCTION__, [event characters]);
+ unichar key = [[event characters] characterAtIndex:0];
+ switch (key) {
+ case NSUpArrowFunctionKey : // up arrow
+ case NSDownArrowFunctionKey : // down arrow
+ [_lastUpDownKeyTime release];
+ _lastUpDownKeyTime = nil;
+ break;
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark list
@@ -375,7 +400,6 @@ - (void)openCurrentMovie:(FullNavItem*)item
[self hidePreview];
}
[self setHidden:TRUE];
- [_listView hideSelBox];
[_movieView hideLogo];
[movie gotoBeginning];
@@ -415,7 +439,6 @@ - (void)closeCurrentMovie
[_movieView setFrame:[self previewRect]];
[_movieView updateSubtitle];
[_movieView setHidden:FALSE];
- [_listView showSelBox];
[window makeFirstResponder:self];
[window flushWindow];
View
6 FullWindow.m
@@ -132,11 +132,7 @@ - (void)setMovieView:(MMovieView*)movieView
// enter into navigation mode
NSRect rc = [[self contentView] bounds];
rc.size.width /= 2;
-
- float IN_MARGIN = (float)(int)(rc.size.width * 0.075);
- float OUT_MARGIN = (float)(int)(rc.size.width * 0.195);
- rc.origin.x += rc.size.width + IN_MARGIN;
- rc.size.width -= IN_MARGIN + OUT_MARGIN;
+ rc.origin.x += rc.size.width;
_navView = [[FullNavView alloc] initWithFrame:rc movieView:_movieView];
[[self contentView] addSubview:_navView];
[self makeFirstResponder:_navView];
View
BIN Images/FSNavSelBoxCenter.tiff
Binary file not shown.
View
BIN Images/FSNavSelBoxLeft.tiff
Binary file not shown.
View
BIN Images/FSNavSelBoxRight.tiff
Binary file not shown.
View
BIN Korean.lproj/Localizable.strings
Binary file not shown.
View
24 Movist.xcodeproj/project.pbxproj
@@ -82,7 +82,6 @@
AF5143170C3C252C00BDACB7 /* FSSeekSliderLeft.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AF5143140C3C252C00BDACB7 /* FSSeekSliderLeft.tiff */; };
AF5143180C3C252C00BDACB7 /* FSSeekSliderRight.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AF5143150C3C252C00BDACB7 /* FSSeekSliderRight.tiff */; };
AF5143190C3C252C00BDACB7 /* FSSeekSliderCenter.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AF5143160C3C252C00BDACB7 /* FSSeekSliderCenter.tiff */; };
- AF51FF320D0BBA47005824F1 /* NewVersionChecker.m in Sources */ = {isa = PBXBuildFile; fileRef = AF51FF300D0BBA47005824F1 /* NewVersionChecker.m */; };
AF5A29430C2CEC0D00483AEB /* AppController_Open.m in Sources */ = {isa = PBXBuildFile; fileRef = AF5A29420C2CEC0D00483AEB /* AppController_Open.m */; };
AF5A29930C2CF05000483AEB /* AppController_Subtitle.m in Sources */ = {isa = PBXBuildFile; fileRef = AF5A29920C2CF05000483AEB /* AppController_Subtitle.m */; };
AF5A29970C2CF14A00483AEB /* AppController_Playlist.m in Sources */ = {isa = PBXBuildFile; fileRef = AF5A29960C2CF14A00483AEB /* AppController_Playlist.m */; };
@@ -106,6 +105,10 @@
AF76EF180BF60AE3000995C9 /* Playlist.nib in Resources */ = {isa = PBXBuildFile; fileRef = AF76EF160BF60AE2000995C9 /* Playlist.nib */; };
AF76EF260BF60B11000995C9 /* PlaylistController.m in Sources */ = {isa = PBXBuildFile; fileRef = AF76EF250BF60B11000995C9 /* PlaylistController.m */; };
AF9569820BFEEABF002A60BE /* Movist.m in Sources */ = {isa = PBXBuildFile; fileRef = AF9569810BFEEABF002A60BE /* Movist.m */; };
+ AFA41E0E0D18E956009DBF15 /* UpdateChecker.m in Sources */ = {isa = PBXBuildFile; fileRef = AFA41E0D0D18E956009DBF15 /* UpdateChecker.m */; };
+ AFADAB4C0D16F11C001686FA /* FSNavSelBoxCenter.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AFADAB490D16F11C001686FA /* FSNavSelBoxCenter.tiff */; };
+ AFADAB4D0D16F11C001686FA /* FSNavSelBoxLeft.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AFADAB4A0D16F11C001686FA /* FSNavSelBoxLeft.tiff */; };
+ AFADAB4E0D16F11C001686FA /* FSNavSelBoxRight.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AFADAB4B0D16F11C001686FA /* FSNavSelBoxRight.tiff */; };
AFAE79670C0A69FA005A988C /* MainPause.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AFAE79520C0A69FA005A988C /* MainPause.tiff */; };
AFAE79680C0A69FA005A988C /* MainPausePressed.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AFAE79530C0A69FA005A988C /* MainPausePressed.tiff */; };
AFAE79690C0A69FA005A988C /* MainPlaylist.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AFAE79540C0A69FA005A988C /* MainPlaylist.tiff */; };
@@ -263,8 +266,6 @@
AF5143140C3C252C00BDACB7 /* FSSeekSliderLeft.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = FSSeekSliderLeft.tiff; path = Images/FSSeekSliderLeft.tiff; sourceTree = "<group>"; };
AF5143150C3C252C00BDACB7 /* FSSeekSliderRight.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = FSSeekSliderRight.tiff; path = Images/FSSeekSliderRight.tiff; sourceTree = "<group>"; };
AF5143160C3C252C00BDACB7 /* FSSeekSliderCenter.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = FSSeekSliderCenter.tiff; path = Images/FSSeekSliderCenter.tiff; sourceTree = "<group>"; };
- AF51FF300D0BBA47005824F1 /* NewVersionChecker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewVersionChecker.m; sourceTree = "<group>"; };
- AF51FF310D0BBA47005824F1 /* NewVersionChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewVersionChecker.h; sourceTree = "<group>"; };
AF5A29420C2CEC0D00483AEB /* AppController_Open.m */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.objc; path = AppController_Open.m; sourceTree = "<group>"; };
AF5A29920C2CF05000483AEB /* AppController_Subtitle.m */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.objc; path = AppController_Subtitle.m; sourceTree = "<group>"; };
AF5A29960C2CF14A00483AEB /* AppController_Playlist.m */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.objc; path = AppController_Playlist.m; sourceTree = "<group>"; };
@@ -289,6 +290,11 @@
AF76EF240BF60B11000995C9 /* PlaylistController.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; path = PlaylistController.h; sourceTree = "<group>"; };
AF76EF250BF60B11000995C9 /* PlaylistController.m */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.objc; path = PlaylistController.m; sourceTree = "<group>"; };
AF9569810BFEEABF002A60BE /* Movist.m */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.objc; path = Movist.m; sourceTree = "<group>"; };
+ AFA41E0C0D18E956009DBF15 /* UpdateChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UpdateChecker.h; sourceTree = "<group>"; };
+ AFA41E0D0D18E956009DBF15 /* UpdateChecker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UpdateChecker.m; sourceTree = "<group>"; };
+ AFADAB490D16F11C001686FA /* FSNavSelBoxCenter.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = FSNavSelBoxCenter.tiff; path = Images/FSNavSelBoxCenter.tiff; sourceTree = "<group>"; };
+ AFADAB4A0D16F11C001686FA /* FSNavSelBoxLeft.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = FSNavSelBoxLeft.tiff; path = Images/FSNavSelBoxLeft.tiff; sourceTree = "<group>"; };
+ AFADAB4B0D16F11C001686FA /* FSNavSelBoxRight.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = FSNavSelBoxRight.tiff; path = Images/FSNavSelBoxRight.tiff; sourceTree = "<group>"; };
AFAE79520C0A69FA005A988C /* MainPause.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = MainPause.tiff; path = Images/MainPause.tiff; sourceTree = "<group>"; };
AFAE79530C0A69FA005A988C /* MainPausePressed.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = MainPausePressed.tiff; path = Images/MainPausePressed.tiff; sourceTree = "<group>"; };
AFAE79540C0A69FA005A988C /* MainPlaylist.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = MainPlaylist.tiff; path = Images/MainPlaylist.tiff; sourceTree = "<group>"; };
@@ -555,6 +561,9 @@
AFF80E1F0C31E16A00ADFD22 /* FSPlaylist.tiff */,
AF5E2FBA0D12E0EB00F49909 /* FSFFMPEG.tiff */,
AF5E2FBB0D12E0EB00F49909 /* FSQuickTime.tiff */,
+ AFADAB4A0D16F11C001686FA /* FSNavSelBoxLeft.tiff */,
+ AFADAB4B0D16F11C001686FA /* FSNavSelBoxRight.tiff */,
+ AFADAB490D16F11C001686FA /* FSNavSelBoxCenter.tiff */,
AF3492C20C48915C00CBDA34 /* ControlPanel_PrevMovie.tiff */,
AF3492BB0C48915C00CBDA34 /* ControlPanel_Beginning.tiff */,
AF3492C00C48915C00CBDA34 /* ControlPanel_Prev0.tiff */,
@@ -630,8 +639,8 @@
AF5A29EA0C2CF84F00483AEB /* AppController_Audio.m */,
AF5A29AE0C2CF64D00483AEB /* AppController_Video.m */,
AF0C4F0F0C5CAC9800199932 /* AppController_Remote.m */,
- AF51FF310D0BBA47005824F1 /* NewVersionChecker.h */,
- AF51FF300D0BBA47005824F1 /* NewVersionChecker.m */,
+ AFA41E0C0D18E956009DBF15 /* UpdateChecker.h */,
+ AFA41E0D0D18E956009DBF15 /* UpdateChecker.m */,
AFF4A8650C1B1E3F00B4F481 /* UserDefaults.h */,
AFF4A8660C1B1E3F00B4F481 /* UserDefaults.m */,
);
@@ -818,6 +827,9 @@
AF5E31E90D13905200F49909 /* MainPauseTiger.tiff in Resources */,
AF5E31EA0D13905200F49909 /* MainPlayPressedTiger.tiff in Resources */,
AF5E31EB0D13905200F49909 /* MainPlayTiger.tiff in Resources */,
+ AFADAB4C0D16F11C001686FA /* FSNavSelBoxCenter.tiff in Resources */,
+ AFADAB4D0D16F11C001686FA /* FSNavSelBoxLeft.tiff in Resources */,
+ AFADAB4E0D16F11C001686FA /* FSNavSelBoxRight.tiff in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -883,8 +895,8 @@
AF3568F60CF1D6AB00C0621A /* FullNavItems.m in Sources */,
AF3568F70CF1D6AB00C0621A /* FullNavListView.m in Sources */,
AFEE91F70CFC706800DB5C7A /* SubtitleRenderer.m in Sources */,
- AF51FF320D0BBA47005824F1 /* NewVersionChecker.m in Sources */,
AFDCCCCF0D0CC5330098206C /* MMovie_FFMPEG_Index.m in Sources */,
+ AFA41E0E0D18E956009DBF15 /* UpdateChecker.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
10 NewVersionChecker.h → UpdateChecker.h
@@ -22,11 +22,11 @@
#import "Movist.h"
-#define NEW_VERSION_CHECK_FAILED 0
-#define NEW_VERSION_IS_AVAILABLE 1
-#define NEW_VERSION_NONE 2
+#define UPDATE_CHECK_FAILED 0
+#define NO_UPDATE_AVAILABLE 1
+#define NEW_VERSION_AVAILABLE 2
-@interface NewVersionChecker : NSObject
+@interface UpdateChecker : NSObject
{
NSString* CURRENT_VERSION;
NSString* _newVersion;
@@ -36,6 +36,6 @@
- (NSString*)newVersion;
- (NSURL*)newVersionURL;
-- (int)checkNewVersion:(NSError**)error;
+- (int)checkUpdate:(NSError**)error;
@end
View
12 NewVersionChecker.m → UpdateChecker.m
@@ -20,10 +20,10 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#import "NewVersionChecker.h"
+#import "UpdateChecker.h"
#import "MSubtitle.h" // for NSString (MSubtitleParser) extension
-@implementation NewVersionChecker
+@implementation UpdateChecker
- (id)init
{
@@ -50,14 +50,14 @@ - (void)dealloc
- (NSString*)newVersion { return _newVersion; }
- (NSURL*)newVersionURL { return _newVersionURL; }
-- (int)checkNewVersion:(NSError**)error
+- (int)checkUpdate:(NSError**)error
{
NSString* address = @"http://code.google.com/p/movist/downloads/list";
NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:address]
options:NSMappedRead | NSUncachedRead
error:error];
if (!data || [data length] == 0) {
- return NEW_VERSION_CHECK_FAILED;
+ return UPDATE_CHECK_FAILED;
}
[_newVersion release], _newVersion = nil;
@@ -128,9 +128,9 @@ - (int)checkNewVersion:(NSError**)error
TRACE(@"new version=\"%@\":\"%@\"", newVersion, newVersionURLString);
_newVersion = [newVersion retain];
_newVersionURL = [[NSURL URLWithString:newVersionURLString] retain];
- return NEW_VERSION_IS_AVAILABLE;
+ return NEW_VERSION_AVAILABLE;
}
- return NEW_VERSION_NONE;
+ return NO_UPDATE_AVAILABLE;
}
@end

0 comments on commit 3d0bdc8

Please sign in to comment.
Something went wrong with that request. Please try again.