summaryrefslogtreecommitdiff
path: root/frontends/cocoa/PSMTabBarControl/PSMTabDragView.m
blob: 4f6ce9131f57c68e2b568cd2ea83342cf82ce32f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
//  PSMTabDragView.m
//  PSMTabBarControl
//
//  Created by Kent Sutherland on 6/17/07.
//  Copyright 2007 Kent Sutherland. All rights reserved.
//

#import "PSMTabDragView.h"

@implementation PSMTabDragView

- (id)initWithFrame:(NSRect)frame
{
    if ((self = [super initWithFrame:frame])) {
        _alpha = 1.0;
    }
    return self;
}

- (void)drawRect:(NSRect)rect
{
    //1.0 fade means show the primary image
    //0.0 fade means show the secondary image
    CGFloat primaryAlpha = _alpha + 0.001f, alternateAlpha = 1.001f - _alpha;
    NSRect srcRect;
    srcRect.origin = NSZeroPoint;
    srcRect.size = [_image size];

    [_image drawInRect:[self bounds] fromRect:srcRect operation:NSCompositingOperationSourceOver fraction:primaryAlpha];
    srcRect.size = [_alternateImage size];
    [_alternateImage drawInRect:[self bounds] fromRect:srcRect operation:NSCompositingOperationSourceOver fraction:alternateAlpha];
}

- (void)setFadeValue:(CGFloat)value
{
    _alpha = value;
}

- (NSImage *)image
{
    return _image;
}

- (void)setImage:(NSImage *)image
{
    _image = image;
}

- (NSImage *)alternateImage
{
    return _alternateImage;
}

- (void)setAlternateImage:(NSImage *)image
{
    _alternateImage = image;
}

@end