Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewritten using CoreAnimation layers #1

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1,047 changes: 134 additions & 913 deletions English.lproj/MainMenu.xib

Large diffs are not rendered by default.

Binary file added OverlayMask@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SliderHandle@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SliderHandleDown@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SliderWell@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SmallSliderHandle@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SmallSliderHandleDown@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SmallSliderWellOff@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SmallSliderWellOn@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 37 additions & 22 deletions TMSliderControl.h
Expand Up @@ -8,49 +8,64 @@

#import <Cocoa/Cocoa.h>

typedef enum
typedef NS_ENUM(unsigned int, TMSliderControlState)
{
kTMSliderControlState_Inactive = 0,
kTMSliderControlState_Active = 1

}TMSliderControlState;
};

@class TMSliderControlHandle;

@interface TMSliderControl : NSControl {
NSImage *sliderWell;
NSImage *overlayMask;
NSImage *sliderHandle;
NSImage *sliderHandleDown;
TMSliderControlHandle *sliderHandleView;
@interface TMSliderControl : NSView {

// drawing
NSRect handleControlRect;
NSRect handleControlRectOn;
NSRect handleControlRectOff;
NSPoint mouseDownPosition;
CGRect handleControlRectOn;
CGRect handleControlRectOff;
CGPoint mouseDownPosition;

// state
TMSliderControlState controlState;
BOOL hasDragged;
BOOL state;

id observedObjectForState;
NSString *observedKeyPathForState;

id target;
SEL action;
id observedObjectForEnabled;
NSString *observedKeyPathForEnabled;
}

- (void)updateUI;

// events
- (void)mouseDown:(NSEvent*)theEvent;
- (void)mouseDragged:(NSEvent*)theEvent;
- (void)mouseUp:(NSEvent*)theEvent;

- (BOOL)state;
- (void)setState:(BOOL)newState;
- (IBAction)moveLeft:(id)sender;
- (IBAction)moveRight:(id)sender;

- (void)layoutHandle;
@property (nonatomic, readonly) CGFloat disabledOpacity;

@property (nonatomic, strong) CALayer *sliderWell;
@property (nonatomic, strong) CALayer *overlayMask;
@property (nonatomic, strong) NSImage *sliderHandleImage;
@property (nonatomic, strong) NSImage *sliderHandleDownImage;
@property (nonatomic, strong) CALayer *sliderHandle;

@property (nonatomic, assign) BOOL enabled;
@property (nonatomic, assign) BOOL state;
@property (nonatomic, unsafe_unretained) id target;
@property (nonatomic, assign) SEL action;

@property (nonatomic, strong) id observedObjectForState;
@property (nonatomic, copy) NSString *observedKeyPathForState;

@property (nonatomic, strong) id observedObjectForEnabled;
@property (nonatomic, copy) NSString *observedKeyPathForEnabled;

- (void)setTarget:(id)anObject;
- (id)target;
- (void)setAction:(SEL)aSelector;
- (SEL)action;
@property (nonatomic, strong) NSString *purposeDescription;
@property (nonatomic, strong) NSString *accessibilityText;

@end

Expand Down