OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/cocoa/status_bubble_mac.h" | 5 #include "chrome/browser/cocoa/status_bubble_mac.h" |
6 | 6 |
7 #include "app/gfx/text_elider.h" | 7 #include "app/gfx/text_elider.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #import "chrome/browser/cocoa/bubble_view.h" | 10 #import "chrome/browser/cocoa/bubble_view.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 [window_ setFrame:window_frame display:YES]; | 175 [window_ setFrame:window_frame display:YES]; |
176 } | 176 } |
177 | 177 |
178 void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) { | 178 void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) { |
179 } | 179 } |
180 | 180 |
181 void StatusBubbleMac::Create() { | 181 void StatusBubbleMac::Create() { |
182 if (window_) | 182 if (window_) |
183 return; | 183 return; |
184 | 184 |
185 NSRect rect = [parent_ frame]; | |
186 rect.size.height = kWindowHeight; | |
187 rect.size.width = static_cast<int>(kWindowWidthPercent * rect.size.width); | |
188 // TODO(avi):fix this for RTL | 185 // TODO(avi):fix this for RTL |
189 window_ = [[NSWindow alloc] initWithContentRect:rect | 186 window_ = [[NSWindow alloc] initWithContentRect:CalculateWindowFrame() |
190 styleMask:NSBorderlessWindowMask | 187 styleMask:NSBorderlessWindowMask |
191 backing:NSBackingStoreBuffered | 188 backing:NSBackingStoreBuffered |
192 defer:YES]; | 189 defer:YES]; |
193 [window_ setMovableByWindowBackground:NO]; | 190 [window_ setMovableByWindowBackground:NO]; |
194 [window_ setBackgroundColor:[NSColor clearColor]]; | 191 [window_ setBackgroundColor:[NSColor clearColor]]; |
195 [window_ setLevel:NSNormalWindowLevel]; | 192 [window_ setLevel:NSNormalWindowLevel]; |
196 [window_ setOpaque:NO]; | 193 [window_ setOpaque:NO]; |
197 [window_ setHasShadow:NO]; | 194 [window_ setHasShadow:NO]; |
198 | 195 |
199 // We do not need to worry about the bubble outliving |parent_| because our | 196 // We do not need to worry about the bubble outliving |parent_| because our |
(...skipping 20 matching lines...) Expand all Loading... |
220 [NSAnimationContext endGrouping]; | 217 [NSAnimationContext endGrouping]; |
221 } | 218 } |
222 | 219 |
223 void StatusBubbleMac::FadeOut() { | 220 void StatusBubbleMac::FadeOut() { |
224 [NSAnimationContext beginGrouping]; | 221 [NSAnimationContext beginGrouping]; |
225 [[NSAnimationContext currentContext] setDuration:kHideFadeDuration]; | 222 [[NSAnimationContext currentContext] setDuration:kHideFadeDuration]; |
226 [[window_ animator] setAlphaValue:0.0f]; | 223 [[window_ animator] setAlphaValue:0.0f]; |
227 [NSAnimationContext endGrouping]; | 224 [NSAnimationContext endGrouping]; |
228 } | 225 } |
229 | 226 |
| 227 void StatusBubbleMac::UpdateSizeAndPosition() { |
| 228 if (!window_) |
| 229 return; |
| 230 |
| 231 [window_ setFrame:CalculateWindowFrame() display:YES]; |
| 232 } |
| 233 |
| 234 NSRect StatusBubbleMac::CalculateWindowFrame() { |
| 235 DCHECK(parent_); |
| 236 |
| 237 NSRect rect = [parent_ frame]; |
| 238 rect.size.height = kWindowHeight; |
| 239 rect.size.width = static_cast<int>(kWindowWidthPercent * rect.size.width); |
| 240 return rect; |
| 241 } |
OLD | NEW |