OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ui/message_center/cocoa/status_item_view.h" | 5 #import "ui/message_center/cocoa/status_item_view.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 unreadCount_ = unreadCount; | 48 unreadCount_ = unreadCount; |
49 [self setNeedsDisplay:YES]; | 49 [self setNeedsDisplay:YES]; |
50 } | 50 } |
51 | 51 |
52 - (void)setHighlight:(BOOL)highlight { | 52 - (void)setHighlight:(BOOL)highlight { |
53 highlight_ = highlight; | 53 highlight_ = highlight; |
54 [self setNeedsDisplay:YES]; | 54 [self setNeedsDisplay:YES]; |
55 } | 55 } |
56 | 56 |
57 - (void)mouseDown:(NSEvent*)event { | 57 - (void)mouseDown:(NSEvent*)event { |
58 DCHECK(!inMouseEventSequence_); | |
59 inMouseEventSequence_ = YES; | 58 inMouseEventSequence_ = YES; |
60 [self setNeedsDisplay:YES]; | 59 [self setNeedsDisplay:YES]; |
61 | 60 |
62 if (callback_) | 61 if (callback_) |
63 callback_.get()(); | 62 callback_.get()(); |
64 } | 63 } |
65 | 64 |
66 - (void)mouseUp:(NSEvent*)event { | 65 - (void)mouseUp:(NSEvent*)event { |
67 DCHECK(inMouseEventSequence_); | |
68 inMouseEventSequence_ = NO; | 66 inMouseEventSequence_ = NO; |
69 [self setNeedsDisplay:YES]; | 67 [self setNeedsDisplay:YES]; |
70 } | 68 } |
71 | 69 |
| 70 - (void)rightMouseDown:(NSEvent*)event { |
| 71 [self mouseDown:event]; |
| 72 } |
| 73 |
| 74 - (void)rightMouseUp:(NSEvent*)event { |
| 75 [self mouseUp:event]; |
| 76 } |
| 77 |
| 78 - (void)otherMouseDown:(NSEvent*)event { |
| 79 [self mouseDown:event]; |
| 80 } |
| 81 |
| 82 - (void)otherMouseUp:(NSEvent*)event { |
| 83 [self mouseUp:event]; |
| 84 } |
| 85 |
72 - (void)drawRect:(NSRect)dirtyRect { | 86 - (void)drawRect:(NSRect)dirtyRect { |
73 NSRect frame = [self bounds]; | 87 NSRect frame = [self bounds]; |
74 | 88 |
75 // Draw the background color. | 89 // Draw the background color. |
76 BOOL highlight = highlight_ || inMouseEventSequence_; | 90 BOOL highlight = highlight_ || inMouseEventSequence_; |
77 [statusItem_ drawStatusBarBackgroundInRect:frame | 91 [statusItem_ drawStatusBarBackgroundInRect:frame |
78 withHighlight:highlight]; | 92 withHighlight:highlight]; |
79 | 93 |
80 // Draw the icon. | 94 // Draw the icon. |
81 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 95 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 NSPoint countPoint = NSMakePoint( | 127 NSPoint countPoint = NSMakePoint( |
114 floorf(NSMinX(textSlice) + (NSWidth(textSlice) - stringSize.width) / 2), | 128 floorf(NSMinX(textSlice) + (NSWidth(textSlice) - stringSize.width) / 2), |
115 floorf(NSMinY(textSlice) + | 129 floorf(NSMinY(textSlice) + |
116 (NSHeight(textSlice) - stringSize.height) / 2)); | 130 (NSHeight(textSlice) - stringSize.height) / 2)); |
117 | 131 |
118 [count drawAtPoint:countPoint withAttributes:attributes]; | 132 [count drawAtPoint:countPoint withAttributes:attributes]; |
119 } | 133 } |
120 } | 134 } |
121 | 135 |
122 @end | 136 @end |
OLD | NEW |