[vlc-devel] Re: OSX progress slider (to mimic iTunes)

Derk-Jan Hartman hartman at videolan.org
Tue Jan 11 12:58:42 CET 2005


We already have something like this, like the others said.
I didn't really have a good image at hand, but here is a shot of the 
current development build. It't 260KB, but worth the look :)

http://sidekick.student.utwente.nl/videolan/vlc_osx_playlist.jpg

DJ


On 10 jan 2005, at 01:01, Ryan Stevens wrote:

> I wouldn't know where to start to get this in through proper channels 
> so here I am. Basically, the class below could replace (or be derived 
> from and used in place of) the MPSlider class.
>
> I wrote an InputManager (SIMBL) plugin that replaces it (besides doing 
> other things ;) and it looks really good but I wouldn't release such a 
> hack for obvious reasons. The knob image could maybe use a little 
> tweaking (it's slightly larger/different than the one in iTunes) but 
> it's close enough for me.
>
> I'm on shared dialup so I haven't downloaded the source or, for that 
> matter, upgraded past 0.7...maybe something like this is already in 
> the latest versions?
>
> Code...
>
> #import "ProgressSlider.h"
>
> #pragma mark Cell
> NSString *knobDataString = @"<4d4d002a 000000da 80002050 3824160d 
> 07844261 50b86436 1d0a00c0 c3f0f8a4 562c0088 c0939037 640c5d17 
> 90482320 08dc09ff 0393c0a3 b028fc86 5d0791c9 4012999c a26d2a8f 
> 4be45039 94d27d37 9ac9a393 99d44279 409fd0a9 541a64d2 560096d1 
> 66348aa5 2e934da0 53ea314a 9d5aab58 af586c00 0ad42ebb 63abda6b 
> f6ab13ae 890506c0 d996bba5 8ad96881 bf606588 5846e575 bc5db017 
> a811722f 7e815cf0 58bc0d33 0800c351 40188006 2b1b77ab e3f23928 
> 3e532d98 afe6b391 4cf60269 a2d1cbb4 b62d46a7 47ab006b 75db381e 
> 509bb480 8000000e 01000003 00000001 00130000 01010003 00000001 
> 00130000 01020003 00000004 00000188 01030003 00000001 00050000 
> 01060003 00000001 00020000 01110004 00000001 00000008 01150003 
> 00000001 00040000 01160004 00000001 000001af 01170004 00000001 
> 000000d1 011a0005 00000001 00000190 011b0005 00000001 00000198 
> 011c0003 00000001 00010000 01280003 00000001 00020000 01520003 
> 00000001 00010000 00000000 00080008 00080008 000afc80 00002710 
> 000afc80 00002710 >";
>
> @implementation ProgressSliderCell
>
> - (id)initImageCell:(NSImage *)img
> {
> 	self = [super initImageCell:img];
> 	if (self) {
> 		knobImage = [[NSImage alloc] initWithData:[knobDataString 
> propertyList]];
> 		[knobImage setFlipped:YES];
> 	}
> 	return self;
> }
>
> - (void)dealloc
> {
> 	[knobImage release];
> 	[super dealloc];
> }
>
> - (void)drawBarInside:(NSRect)aRect flipped:(BOOL)flipped
> {	[[NSColor blackColor] set];
> 	NSFrameRect(aRect);
> }
>
> - (void)drawKnob:(NSRect)aRect
> {
> 	if ([self isVertical]==-1) aRect.origin=NSZeroPoint;
>
> 	NSRect srcRect;
> 	srcRect.origin=NSZeroPoint;
> 	srcRect.size = [knobImage size];
>
> 	[knobImage drawInRect:aRect fromRect:srcRect 
> operation:NSCompositeSourceAtop fraction:1];	
> }
>
> - (NSRect)knobRectFlipped:(BOOL)flipped
> {
> 	NSRect rect = [super knobRectFlipped:flipped];
> 		rect.size.width = 9;
> 		rect.size.height = 9;
> 	return rect;
> }
>
> @end
>
> #pragma mark Control
> @implementation ProgressSlider
>
> - (id)initWithCoder:(NSCoder*)coder {
>     self = [super initWithCoder:coder];
>     if (self) {
> 	NSSliderCell *oldCell = [self cell];
> 	ProgressSliderCell *myCell = [[ProgressSliderCell alloc] 
> initImageCell:nil];
> 	
> 		// title..
> 		[myCell setTitleCell:[oldCell titleCell]];
> 		[myCell setTitle:[oldCell title]];
> 		[myCell setTitleFont:[oldCell titleFont]];
> 		[myCell setTitleColor:[oldCell titleColor]];
> 		
> 		// tick marks..
> 		[myCell setAllowsTickMarkValuesOnly:[oldCell 
> allowsTickMarkValuesOnly]];
> 		[myCell setNumberOfTickMarks:[oldCell numberOfTickMarks]];
> 		[myCell setTickMarkPosition:[oldCell tickMarkPosition]];
>
> 		[myCell setTag:[oldCell tag]]; // ?
>
> 		// the important stuff..
> 		[myCell setTarget:[oldCell target]];
> 		[myCell setAction:[oldCell action]];
> 		[myCell setContinuous:[oldCell isContinuous]];
> 		[myCell setMinValue:[oldCell minValue]];
> 		[myCell setMaxValue:[oldCell maxValue]];
> 		[myCell setControlSize:[oldCell controlSize]];
>
> 		// there's probably more we could bring over
> 		// from oldCell but I think I got most of it(/what's important)
> 		
> 	[self setCell:myCell];
>
> 		{ // size it like the one used in iTunes..
> 		NSSize size=[self frame].size;
> 			size.height = 9;
>
> 		[self setFrameSize: size];
> 		}
>
> 	}
> 	return self;
> }
>
> - (void)sizeToFit {}
>
> - (void)drawRect:(NSRect)rect
> {
> 	id cell = [self cell];
> 		[cell drawBarInside:[self bounds] flipped:[self isFlipped]];
>         [cell drawKnob];
> }
>
> @end
>
> -- 
> This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
> To unsubscribe, please read http://developers.videolan.org/lists.html
>
>
---
Universiteit Twente
Derk-Jan Hartman (d.hartman at student.utwente dot nl)
http://home.student.utwente.nl/d.hartman

-- 
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html



More information about the vlc-devel mailing list