OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/info_bubble.h" | 5 #include "chrome/browser/views/info_bubble.h" |
6 | 6 |
7 #include "base/win_util.h" | 7 #include "base/win_util.h" |
8 #include "chrome/browser/browser_window.h" | 8 #include "chrome/browser/browser_window.h" |
9 #include "chrome/browser/views/frame/browser_view.h" | 9 #include "chrome/browser/views/frame/browser_view.h" |
10 #include "chrome/common/gfx/chrome_canvas.h" | 10 #include "chrome/common/gfx/chrome_canvas.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 void InfoBubble::Init(HWND parent_hwnd, | 93 void InfoBubble::Init(HWND parent_hwnd, |
94 const gfx::Rect& position_relative_to, | 94 const gfx::Rect& position_relative_to, |
95 views::View* content) { | 95 views::View* content) { |
96 HWND owning_frame_hwnd = GetAncestor(parent_hwnd, GA_ROOTOWNER); | 96 HWND owning_frame_hwnd = GetAncestor(parent_hwnd, GA_ROOTOWNER); |
97 // We should always have a frame, but there was a bug elsewhere that | 97 // We should always have a frame, but there was a bug elsewhere that |
98 // made it possible for the frame to be NULL, so we have the check. If | 98 // made it possible for the frame to be NULL, so we have the check. If |
99 // you hit this, file a bug. | 99 // you hit this, file a bug. |
100 DCHECK(BrowserView::GetBrowserViewForHWND(owning_frame_hwnd)); | 100 DCHECK(BrowserView::GetBrowserViewForHWND(owning_frame_hwnd)); |
101 parent_ = reinterpret_cast<views::Window*>(win_util::GetWindowUserData( | 101 parent_ = reinterpret_cast<views::Window*>(win_util::GetWindowUserData( |
102 owning_frame_hwnd)); | 102 owning_frame_hwnd)); |
103 parent_->DisableInactiveRendering(true); | 103 parent_->DisableInactiveRendering(); |
104 | 104 |
105 if (kInfoBubbleCornerTopLeft == NULL) { | 105 if (kInfoBubbleCornerTopLeft == NULL) { |
106 kInfoBubbleCornerTopLeft = ResourceBundle::GetSharedInstance() | 106 kInfoBubbleCornerTopLeft = ResourceBundle::GetSharedInstance() |
107 .GetBitmapNamed(IDR_INFO_BUBBLE_CORNER_TOP_LEFT); | 107 .GetBitmapNamed(IDR_INFO_BUBBLE_CORNER_TOP_LEFT); |
108 kInfoBubbleCornerTopRight = ResourceBundle::GetSharedInstance() | 108 kInfoBubbleCornerTopRight = ResourceBundle::GetSharedInstance() |
109 .GetBitmapNamed(IDR_INFO_BUBBLE_CORNER_TOP_RIGHT); | 109 .GetBitmapNamed(IDR_INFO_BUBBLE_CORNER_TOP_RIGHT); |
110 kInfoBubbleCornerBottomLeft = ResourceBundle::GetSharedInstance() | 110 kInfoBubbleCornerBottomLeft = ResourceBundle::GetSharedInstance() |
111 .GetBitmapNamed(IDR_INFO_BUBBLE_CORNER_BOTTOM_LEFT); | 111 .GetBitmapNamed(IDR_INFO_BUBBLE_CORNER_BOTTOM_LEFT); |
112 kInfoBubbleCornerBottomRight = ResourceBundle::GetSharedInstance() | 112 kInfoBubbleCornerBottomRight = ResourceBundle::GetSharedInstance() |
113 .GetBitmapNamed(IDR_INFO_BUBBLE_CORNER_BOTTOM_RIGHT); | 113 .GetBitmapNamed(IDR_INFO_BUBBLE_CORNER_BOTTOM_RIGHT); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 return new ContentView(content, this); | 200 return new ContentView(content, this); |
201 } | 201 } |
202 | 202 |
203 void InfoBubble::Close(bool closed_by_escape) { | 203 void InfoBubble::Close(bool closed_by_escape) { |
204 if (closed_) | 204 if (closed_) |
205 return; | 205 return; |
206 | 206 |
207 // We don't fade out because it looks terrible. | 207 // We don't fade out because it looks terrible. |
208 if (delegate_) | 208 if (delegate_) |
209 delegate_->InfoBubbleClosing(this, closed_by_escape); | 209 delegate_->InfoBubbleClosing(this, closed_by_escape); |
210 parent_->DisableInactiveRendering(false); | |
211 closed_ = true; | 210 closed_ = true; |
212 WidgetWin::Close(); | 211 WidgetWin::Close(); |
213 } | 212 } |
214 | 213 |
215 // ContentView ---------------------------------------------------------------- | 214 // ContentView ---------------------------------------------------------------- |
216 | 215 |
217 InfoBubble::ContentView::ContentView(views::View* content, InfoBubble* host) | 216 InfoBubble::ContentView::ContentView(views::View* content, InfoBubble* host) |
218 : host_(host) { | 217 : host_(host) { |
219 if (UILayoutIsRightToLeft()) { | 218 if (UILayoutIsRightToLeft()) { |
220 arrow_edge_ = TOP_RIGHT; | 219 arrow_edge_ = TOP_RIGHT; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 x -= kArrowXOffset; | 422 x -= kArrowXOffset; |
424 else | 423 else |
425 x = x + kArrowXOffset - pref.width(); | 424 x = x + kArrowXOffset - pref.width(); |
426 if (IsTop()) { | 425 if (IsTop()) { |
427 y = position_relative_to.bottom() + kArrowToContentPadding; | 426 y = position_relative_to.bottom() + kArrowToContentPadding; |
428 } else { | 427 } else { |
429 y = position_relative_to.y() - kArrowToContentPadding - pref.height(); | 428 y = position_relative_to.y() - kArrowToContentPadding - pref.height(); |
430 } | 429 } |
431 return gfx::Rect(x, y, pref.width(), pref.height()); | 430 return gfx::Rect(x, y, pref.width(), pref.height()); |
432 } | 431 } |
OLD | NEW |