| 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/app/theme/theme_resources.h" | 8 #include "chrome/app/theme/theme_resources.h" |
| 9 #include "chrome/browser/browser_window.h" | 9 #include "chrome/browser/browser_window.h" |
| 10 #include "chrome/browser/frame_util.h" | 10 #include "chrome/browser/frame_util.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 if (window_bounds.right() > monitor_bounds.right()) { | 229 if (window_bounds.right() > monitor_bounds.right()) { |
| 230 if (IsTop()) | 230 if (IsTop()) |
| 231 SetArrowEdge(TOP_RIGHT); | 231 SetArrowEdge(TOP_RIGHT); |
| 232 else | 232 else |
| 233 SetArrowEdge(BOTTOM_RIGHT); | 233 SetArrowEdge(BOTTOM_RIGHT); |
| 234 } | 234 } |
| 235 // And return new bounds. | 235 // And return new bounds. |
| 236 return CalculateWindowBounds(position_relative_to); | 236 return CalculateWindowBounds(position_relative_to); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void InfoBubble::ContentView::GetPreferredSize(CSize* pref) { | 239 gfx::Size InfoBubble::ContentView::GetPreferredSize() { |
| 240 DCHECK(GetChildViewCount() == 1); | 240 DCHECK(GetChildViewCount() == 1); |
| 241 View* content = GetChildViewAt(0); | 241 View* content = GetChildViewAt(0); |
| 242 content->GetPreferredSize(pref); | 242 gfx::Size pref = content->GetPreferredSize(); |
| 243 pref->cx += kBorderSize + kBorderSize + kInfoBubbleViewLeftMargin + | 243 pref.Enlarge(kBorderSize + kBorderSize + kInfoBubbleViewLeftMargin + |
| 244 kInfoBubbleViewRightMargin; | 244 kInfoBubbleViewRightMargin, |
| 245 pref->cy += kBorderSize + kBorderSize + kArrowSize + | 245 kBorderSize + kBorderSize + kArrowSize + |
| 246 kInfoBubbleViewTopMargin + kInfoBubbleViewBottomMargin; | 246 kInfoBubbleViewTopMargin + kInfoBubbleViewBottomMargin); |
| 247 return pref; |
| 247 } | 248 } |
| 248 | 249 |
| 249 void InfoBubble::ContentView::Layout() { | 250 void InfoBubble::ContentView::Layout() { |
| 250 DCHECK(GetChildViewCount() == 1); | 251 DCHECK(GetChildViewCount() == 1); |
| 251 View* content = GetChildViewAt(0); | 252 View* content = GetChildViewAt(0); |
| 252 int x = kBorderSize; | 253 int x = kBorderSize; |
| 253 int y = kBorderSize; | 254 int y = kBorderSize; |
| 254 int content_width = width() - kBorderSize - kBorderSize - | 255 int content_width = width() - kBorderSize - kBorderSize - |
| 255 kInfoBubbleViewLeftMargin - kInfoBubbleViewRightMargin; | 256 kInfoBubbleViewLeftMargin - kInfoBubbleViewRightMargin; |
| 256 int content_height = height() - kBorderSize - kBorderSize - kArrowSize - | 257 int content_height = height() - kBorderSize - kBorderSize - kArrowSize - |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 canvas->FillRectInt(kBorderColor2, arrow_x - (kArrowSize - i) - 1, y, 1, | 399 canvas->FillRectInt(kBorderColor2, arrow_x - (kArrowSize - i) - 1, y, 1, |
| 399 1); | 400 1); |
| 400 canvas->FillRectInt(kBorderColor2, arrow_x + (kArrowSize - i) + 1, y, 1, | 401 canvas->FillRectInt(kBorderColor2, arrow_x + (kArrowSize - i) + 1, y, 1, |
| 401 1); | 402 1); |
| 402 } | 403 } |
| 403 } | 404 } |
| 404 } | 405 } |
| 405 | 406 |
| 406 gfx::Rect InfoBubble::ContentView::CalculateWindowBounds( | 407 gfx::Rect InfoBubble::ContentView::CalculateWindowBounds( |
| 407 const gfx::Rect& position_relative_to) { | 408 const gfx::Rect& position_relative_to) { |
| 408 CSize pref; | 409 gfx::Size pref = GetPreferredSize(); |
| 409 GetPreferredSize(&pref); | |
| 410 int x = position_relative_to.x() + position_relative_to.width() / 2; | 410 int x = position_relative_to.x() + position_relative_to.width() / 2; |
| 411 int y; | 411 int y; |
| 412 if (IsLeft()) | 412 if (IsLeft()) |
| 413 x -= kArrowXOffset; | 413 x -= kArrowXOffset; |
| 414 else | 414 else |
| 415 x = x + kArrowXOffset - pref.cx; | 415 x = x + kArrowXOffset - pref.width(); |
| 416 if (IsTop()) { | 416 if (IsTop()) { |
| 417 y = position_relative_to.bottom() + kArrowToContentPadding; | 417 y = position_relative_to.bottom() + kArrowToContentPadding; |
| 418 } else { | 418 } else { |
| 419 y = position_relative_to.y() - kArrowToContentPadding - pref.cy; | 419 y = position_relative_to.y() - kArrowToContentPadding - pref.height(); |
| 420 } | 420 } |
| 421 return gfx::Rect(x, y, pref.cx, pref.cy); | 421 return gfx::Rect(x, y, pref.width(), pref.height()); |
| 422 } | 422 } |
| 423 | 423 |
| OLD | NEW |