Re: How to create the slider switch in the time machine preference panel in system preferences?
Re: How to create the slider switch in the time machine preference panel in system preferences?
- Subject: Re: How to create the slider switch in the time machine preference panel in system preferences?
- From: Stephane Sudre <email@hidden>
- Date: Sun, 9 Mar 2008 13:33:00 +0100
On Mar 9, 2008, at 1:40 PM, Scott.D.R wrote:
Greetings everyone.
Maybe many of us have enabled the time machine function for our
leopards. Very cool machine.
I am interested in the time machine preference panel. When you open
it, there is a slider-like switch allow you to enable or disable
the time machine function.
I am eager to how to create a UI element like that, because it can
work flawlessly with my application.
Thank you very much for any suggestion.
Here are some things I did when I implemented one:
Subclass of NSButton (maybe subclassing NSControl would be enough)
o Drawing:
I used 2 vertical gradients: one for the background, one for the
thumb. They are going in opposite direction. The frames of the
background and thumb are rounded rect made with NSBezierPath. There
are some additional enhancements for the shadow at the top of the
background.
The "most difficult" part here is to clip the drawing for the gradient.
o Tracking the thumbs:
I implemented it through the following methods:
- (void)mouseDown:(id)fp8;
- (void)mouseDragged:(id)fp8;
- (void)mouseUp:(id)fp8;
You need to consider all the potential cases for mouseDown and mouseUp:
- mouseDown and mouseUp in the background
- mouseDown and mouseUp in the thumb with no drag
- mouseDown, drag and mouseUp in the thumb
etc.
You will need to define the limits for the drag that can trigger a
status switch.
o Animation:
Done through a subclass of NSAnimation.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden