summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/info_bubble.cc
diff options
context:
space:
mode:
authorjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-10 22:33:56 +0000
committerjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-10 22:33:56 +0000
commit37c1cfb34294b31a47711b8bdb87165a91478eb6 (patch)
tree8ee5ef58f97bff47db03b17239173451f9a390d0 /chrome/browser/views/info_bubble.cc
parent09d46b7984480d74ec8a0d9163a6072757f2056b (diff)
downloadchromium_src-37c1cfb34294b31a47711b8bdb87165a91478eb6.zip
chromium_src-37c1cfb34294b31a47711b8bdb87165a91478eb6.tar.gz
chromium_src-37c1cfb34294b31a47711b8bdb87165a91478eb6.tar.bz2
Adding a way to pin the info bubble arrow.
It is useful with the app launcher that should always stay at the same location. BUG=43754 TEST=Open the app launcher with the Chrome window at the bottom of the screen. The app launcher bubble should be displayed in the browser, with the app launcher location bar aligned with the browser's one. Review URL: http://codereview.chromium.org/2000005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/info_bubble.cc')
-rw-r--r--chrome/browser/views/info_bubble.cc47
1 files changed, 25 insertions, 22 deletions
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index 63dc590..5bfb822 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -41,6 +41,7 @@ void BorderContents::Init() {
void BorderContents::SizeAndGetBounds(
const gfx::Rect& position_relative_to,
BubbleBorder::ArrowLocation arrow_location,
+ bool allow_bubble_offscreen,
const gfx::Size& contents_size,
gfx::Rect* contents_bounds,
gfx::Rect* window_bounds) {
@@ -60,26 +61,28 @@ void BorderContents::SizeAndGetBounds(
*window_bounds =
bubble_border_->GetBounds(position_relative_to, local_contents_size);
- // See if those bounds will fit on the monitor.
- scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_provider(
- WindowSizer::CreateDefaultMonitorInfoProvider());
- gfx::Rect monitor_bounds(
- monitor_provider->GetMonitorWorkAreaMatching(position_relative_to));
- if (!monitor_bounds.IsEmpty() && !monitor_bounds.Contains(*window_bounds)) {
- // The bounds don't fit. Move the arrow to try and improve things.
- if (window_bounds->bottom() > monitor_bounds.bottom())
- arrow_location = BubbleBorder::horizontal_mirror(arrow_location);
- else if (BubbleBorder::is_arrow_on_left(arrow_location) ?
- (window_bounds->right() > monitor_bounds.right()) :
- (window_bounds->x() < monitor_bounds.x())) {
- arrow_location = BubbleBorder::rtl_mirror(arrow_location);
+ if (!allow_bubble_offscreen) {
+ // See if those bounds will fit on the monitor.
+ scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_provider(
+ WindowSizer::CreateDefaultMonitorInfoProvider());
+ gfx::Rect monitor_bounds(
+ monitor_provider->GetMonitorWorkAreaMatching(position_relative_to));
+ if (!monitor_bounds.IsEmpty() && !monitor_bounds.Contains(*window_bounds)) {
+ // The bounds don't fit. Move the arrow to try and improve things.
+ if (window_bounds->bottom() > monitor_bounds.bottom())
+ arrow_location = BubbleBorder::horizontal_mirror(arrow_location);
+ else if (BubbleBorder::is_arrow_on_left(arrow_location) ?
+ (window_bounds->right() > monitor_bounds.right()) :
+ (window_bounds->x() < monitor_bounds.x())) {
+ arrow_location = BubbleBorder::rtl_mirror(arrow_location);
+ }
+
+ bubble_border_->set_arrow_location(arrow_location);
+
+ // Now get the recalculated bounds.
+ *window_bounds = bubble_border_->GetBounds(position_relative_to,
+ local_contents_size);
}
-
- bubble_border_->set_arrow_location(arrow_location);
-
- // Now get the recalculated bounds.
- *window_bounds = bubble_border_->GetBounds(position_relative_to,
- local_contents_size);
}
// Calculate the bounds of the contained contents (in window coordinates) by
@@ -143,7 +146,7 @@ gfx::Rect BorderWidget::SizeAndGetBounds(
gfx::Rect contents_bounds;
gfx::Rect window_bounds;
border_contents_->SizeAndGetBounds(position_relative_to, arrow_location,
- contents_size, &contents_bounds,
+ false, contents_size, &contents_bounds,
&window_bounds);
SetBounds(window_bounds);
@@ -271,7 +274,7 @@ void InfoBubble::Init(views::Widget* parent,
border_contents_->Init();
gfx::Rect contents_bounds;
border_contents_->SizeAndGetBounds(position_relative_to,
- arrow_location, contents->GetPreferredSize(),
+ arrow_location, false, contents->GetPreferredSize(),
&contents_bounds, &window_bounds);
// This new view must be added before |contents| so it will paint under it.
contents_view->AddChildView(0, border_contents_);
@@ -318,7 +321,7 @@ void InfoBubble::SizeToContents() {
#else
gfx::Rect contents_bounds;
border_contents_->SizeAndGetBounds(position_relative_to_,
- arrow_location_, contents_->GetPreferredSize(),
+ arrow_location_, false, contents_->GetPreferredSize(),
&contents_bounds, &window_bounds);
// |contents_view| has no layout manager, so we have to explicitly position
// its children.