-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathYLImageView.m
More file actions
97 lines (77 loc) · 2.35 KB
/
YLImageView.m
File metadata and controls
97 lines (77 loc) · 2.35 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// YLImageView.m
// MacBlueTelnet
//
// Created by Jjgod Jiang on 3/27/08.
// Copyright 2008 Jjgod Jiang. All rights reserved.
//
#import "YLImageView.h"
#import "YLController.h"
enum {
kFloatRectWidth = 100,
kFloatRectHeight = 60,
};
@implementation YLImageView
@synthesize tiffData;
- (id) initWithFrame: (NSRect)frame previewer: (YLImagePreviewer *)thePreviewer
{
if ([super initWithFrame: frame])
{
tipsState = kShowTipsGray;
tipsRect = NSMakeRect((frame.size.width - kFloatRectWidth) / 2, 10, kFloatRectWidth, kFloatRectHeight);
previewer = thePreviewer;
[self addTrackingRect: frame
owner: self
userData: nil
assumeInside: NO];
indicator = [[YLFloatingView alloc] initWithFrame: tipsRect];
[indicator setWantsLayer: YES];
[indicator setAlphaValue: 0.0];
[self addSubview: indicator];
}
return self;
}
- (void) dealloc
{
[indicator release];
[super dealloc];
}
- (void) keyDown: (NSEvent *)event
{
if ([[event characters] isEqual: @"i"])
{
NSBitmapImageRep *rep = [[[self image] representations] objectAtIndex: 0];
NSDictionary *exif = [rep valueForProperty: NSImageEXIFData];
// NSLog(@"exif = %@", exif);
YLController *controller = [NSApp delegate];
YLExifController *exifController = [controller exifController];
NSString *makeName = [tiffData objectForKey:(NSString *) kCGImagePropertyTIFFMake];
NSString *modelName = [tiffData objectForKey: (NSString *) kCGImagePropertyTIFFModel];
// NSLog(@"tiff = %@, modelName = %@", tiff, modelName);
[exifController setExifData: exif];
[exifController setModelName: [NSString stringWithFormat: @"%@ %@", makeName, modelName]];
[exifController showExifPanel];
}
}
- (void) mouseMoved: (NSEvent *)event
{
[[indicator animator] setAlphaValue: 0.8];
[[self window] setAcceptsMouseMovedEvents: NO];
}
- (void) mouseEntered: (NSEvent *)event
{
[[indicator animator] setAlphaValue: 0.8];
}
- (void) mouseExited: (NSEvent *)event
{
[[indicator animator] setAlphaValue: 0.0];
}
- (void) setPreviewer: (YLImagePreviewer *)thePreviewer
{
previewer = thePreviewer;
}
- (YLImagePreviewer *) previewer
{
return previewer;
}
@end