summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-07 17:13:16 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-07 17:13:16 +0000
commit4d684f49efc822ea97870edd7796ca6fee2348e9 (patch)
tree4761f2f62055ea3817558e31b03b78a8c624ceac
parent9031aff180fbfae4a10e92b553b656d00467da9d (diff)
downloadchromium_src-4d684f49efc822ea97870edd7796ca6fee2348e9.zip
chromium_src-4d684f49efc822ea97870edd7796ca6fee2348e9.tar.gz
chromium_src-4d684f49efc822ea97870edd7796ca6fee2348e9.tar.bz2
Merge 108537 - Align avatar bubble with edge of anchor control
Currently when showing the avatar bubble the tip of the bubble points to the middle of the anchor control. This can look weird so I'm changing it to be aligned with the edge of the anchor control. BUG=98884 TEST= Review URL: http://codereview.chromium.org/8493011 git-svn-id: svn://svn.chromium.org/chrome/branches/912/src@108880 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/login/message_bubble.cc2
-rw-r--r--chrome/browser/chromeos/status/caps_lock_menu_button.cc12
-rw-r--r--chrome/browser/external_tab_container_win.cc1
-rw-r--r--chrome/browser/resources/ntp4/new_tab.css2
-rw-r--r--chrome/browser/speech/speech_input_bubble_views.cc5
-rw-r--r--chrome/browser/ui/views/avatar_menu_button.cc3
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc3
-rw-r--r--chrome/browser/ui/views/bubble/border_contents.cc5
-rw-r--r--chrome/browser/ui/views/bubble/border_contents.h3
-rw-r--r--chrome/browser/ui/views/bubble/bubble.cc9
-rw-r--r--chrome/browser/ui/views/bubble/bubble.h3
-rw-r--r--chrome/browser/ui/views/extensions/extension_installed_bubble.cc4
-rw-r--r--chrome/browser/ui/views/first_run_bubble.cc3
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc9
-rw-r--r--chrome/browser/ui/views/global_error_bubble_view.cc5
-rw-r--r--chrome/browser/ui/views/location_bar/content_setting_image_view.cc1
-rw-r--r--chrome/browser/ui/views/page_info_bubble_view.cc1
-rw-r--r--chrome/browser/ui/views/pinned_contents_info_bubble.cc1
-rw-r--r--chrome/browser/ui/views/toolbar_view.cc1
-rw-r--r--chrome/browser/ui/views/web_intent_picker_view.cc4
-rw-r--r--views/bubble/bubble_border.cc14
-rw-r--r--views/bubble/bubble_border.h14
22 files changed, 79 insertions, 26 deletions
diff --git a/chrome/browser/chromeos/login/message_bubble.cc b/chrome/browser/chromeos/login/message_bubble.cc
index 074494ff..3304705 100644
--- a/chrome/browser/chromeos/login/message_bubble.cc
+++ b/chrome/browser/chromeos/login/message_bubble.cc
@@ -150,6 +150,7 @@ MessageBubble* MessageBubble::ShowWithLinks(
views::Widget::InitParams::TYPE_POPUP, parent, image, text, links,
true, delegate);
bubble->InitBubble(parent, position_relative_to, arrow_location,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
bubble->text_->parent(), delegate);
return bubble;
}
@@ -171,6 +172,7 @@ MessageBubble* MessageBubble::ShowNoGrab(
views::Widget::InitParams::TYPE_CONTROL, parent, image, text, links,
false, delegate);
bubble->InitBubble(parent, position_relative_to, arrow_location,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
bubble->text_->parent(), delegate);
return bubble;
}
diff --git a/chrome/browser/chromeos/status/caps_lock_menu_button.cc b/chrome/browser/chromeos/status/caps_lock_menu_button.cc
index 94ab8d1..78e4083 100644
--- a/chrome/browser/chromeos/status/caps_lock_menu_button.cc
+++ b/chrome/browser/chromeos/status/caps_lock_menu_button.cc
@@ -316,12 +316,12 @@ void CapsLockMenuButton::CreateAndShowBubble() {
gfx::Rect button_bounds = GetScreenBounds();
button_bounds.set_y(button_bounds.y() + 1); // See login/message_bubble.cc.
- bubble_ = Bubble::ShowFocusless(GetWidget(),
- button_bounds,
- views::BubbleBorder::TOP_RIGHT,
- new CapsLockMenuButton::StatusView(this),
- NULL /* no delegate */,
- true /* show_while_screen_is_locked */);
+ bubble_ = Bubble::ShowFocusless(GetWidget(), button_bounds,
+ views::BubbleBorder::TOP_RIGHT,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
+ new CapsLockMenuButton::StatusView(this),
+ NULL /* no delegate */,
+ true /* show_while_screen_is_locked */);
}
void CapsLockMenuButton::HideBubble() {
diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc
index 3f58d2a..b750366 100644
--- a/chrome/browser/external_tab_container_win.cc
+++ b/chrome/browser/external_tab_container_win.cc
@@ -601,6 +601,7 @@ void ExternalTabContainer::ShowPageInfo(Profile* profile,
ssl, show_history);
Bubble* bubble = Bubble::Show(GetWidget(), bounds,
views::BubbleBorder::TOP_LEFT,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
page_info_bubble, page_info_bubble);
page_info_bubble->set_bubble(bubble);
}
diff --git a/chrome/browser/resources/ntp4/new_tab.css b/chrome/browser/resources/ntp4/new_tab.css
index ac12e7f..643cb76 100644
--- a/chrome/browser/resources/ntp4/new_tab.css
+++ b/chrome/browser/resources/ntp4/new_tab.css
@@ -177,8 +177,10 @@ html[dir='rtl'] #attribution {
cursor: pointer;
font-size: 13px;
/* Leave room for the scrollbar. */
+ margin-left: 13px;
margin-right: 13px;
margin-top: 5px;
+ padding: 0;
position: fixed;
right: 0;
text-align: right;
diff --git a/chrome/browser/speech/speech_input_bubble_views.cc b/chrome/browser/speech/speech_input_bubble_views.cc
index d417c99..820979b 100644
--- a/chrome/browser/speech/speech_input_bubble_views.cc
+++ b/chrome/browser/speech/speech_input_bubble_views.cc
@@ -366,8 +366,9 @@ void SpeechInputBubbleImpl::Show() {
}
bubble_ = Bubble::Show(toplevel_widget,
target_rect,
- views::BubbleBorder::TOP_LEFT, bubble_content_,
- this);
+ views::BubbleBorder::TOP_LEFT,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
+ bubble_content_, this);
// We don't want fade outs when closing because it makes speech recognition
// appear slower than it is. Also setting it to false allows |Close| to
// destroy the bubble immediately instead of waiting for the fade animation
diff --git a/chrome/browser/ui/views/avatar_menu_button.cc b/chrome/browser/ui/views/avatar_menu_button.cc
index 36a899d..6640ca6 100644
--- a/chrome/browser/ui/views/avatar_menu_button.cc
+++ b/chrome/browser/ui/views/avatar_menu_button.cc
@@ -158,7 +158,8 @@ void AvatarMenuButton::ShowAvatarBubble() {
AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_);
// Bubble::Show() takes ownership of the view.
bubble_ = Bubble::Show(browser_view->GetWidget(), bounds,
- views::BubbleBorder::TOP_LEFT, bubble_view, bubble_view);
+ views::BubbleBorder::TOP_LEFT,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bubble_view, bubble_view);
bubble_->AddObserver(this);
}
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
index b7646cd..d2ba8b7 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
@@ -91,7 +91,8 @@ void BookmarkBubbleView::Show(views::Widget* parent,
bookmark_bubble_ = new BookmarkBubbleView(delegate, profile, url,
newly_bookmarked);
Bubble* bubble = Bubble::Show(
- parent, bounds, views::BubbleBorder::TOP_RIGHT, bookmark_bubble_,
+ parent, bounds, views::BubbleBorder::TOP_RIGHT,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bookmark_bubble_,
bookmark_bubble_);
// |bubble_| can be set to NULL in BubbleClosing when we close the bubble
// asynchronously. However, that can happen during the Show call above if the
diff --git a/chrome/browser/ui/views/bubble/border_contents.cc b/chrome/browser/ui/views/bubble/border_contents.cc
index 3503b19..e148e32 100644
--- a/chrome/browser/ui/views/bubble/border_contents.cc
+++ b/chrome/browser/ui/views/bubble/border_contents.cc
@@ -38,6 +38,11 @@ void BorderContents::SetBackgroundColor(SkColor color) {
bubble_border_->set_background_color(color);
}
+void BorderContents::SetAlignment(
+ views::BubbleBorder::BubbleAlignment alignment) {
+ bubble_border_->set_alignment(alignment);
+}
+
void BorderContents::SizeAndGetBounds(
const gfx::Rect& position_relative_to,
views::BubbleBorder::ArrowLocation arrow_location,
diff --git a/chrome/browser/ui/views/bubble/border_contents.h b/chrome/browser/ui/views/bubble/border_contents.h
index d61b847..5504bc0 100644
--- a/chrome/browser/ui/views/bubble/border_contents.h
+++ b/chrome/browser/ui/views/bubble/border_contents.h
@@ -22,6 +22,9 @@ class BorderContents : public views::View {
// Sets the background color.
void SetBackgroundColor(SkColor color);
+ // Sets the bubble alignment.
+ void SetAlignment(views::BubbleBorder::BubbleAlignment alignment);
+
// Given the size of the contents and the rect to point at, returns the bounds
// of both the border and the contents inside the bubble.
// |arrow_location| specifies the preferred location for the arrow
diff --git a/chrome/browser/ui/views/bubble/bubble.cc b/chrome/browser/ui/views/bubble/bubble.cc
index 04c3c390..4109295 100644
--- a/chrome/browser/ui/views/bubble/bubble.cc
+++ b/chrome/browser/ui/views/bubble/bubble.cc
@@ -51,10 +51,11 @@ string16 BubbleDelegate::GetAccessibleName() {
Bubble* Bubble::Show(views::Widget* parent,
const gfx::Rect& position_relative_to,
views::BubbleBorder::ArrowLocation arrow_location,
+ views::BubbleBorder::BubbleAlignment alignment,
views::View* contents,
BubbleDelegate* delegate) {
Bubble* bubble = new Bubble;
- bubble->InitBubble(parent, position_relative_to, arrow_location,
+ bubble->InitBubble(parent, position_relative_to, arrow_location, alignment,
contents, delegate);
// Register the Escape accelerator for closing.
@@ -72,12 +73,13 @@ Bubble* Bubble::ShowFocusless(
views::Widget* parent,
const gfx::Rect& position_relative_to,
views::BubbleBorder::ArrowLocation arrow_location,
+ views::BubbleBorder::BubbleAlignment alignment,
views::View* contents,
BubbleDelegate* delegate,
bool show_while_screen_is_locked) {
Bubble* bubble = new Bubble(views::Widget::InitParams::TYPE_POPUP,
show_while_screen_is_locked);
- bubble->InitBubble(parent, position_relative_to, arrow_location,
+ bubble->InitBubble(parent, position_relative_to, arrow_location, alignment,
contents, delegate);
return bubble;
}
@@ -191,6 +193,7 @@ Bubble::~Bubble() {
void Bubble::InitBubble(views::Widget* parent,
const gfx::Rect& position_relative_to,
views::BubbleBorder::ArrowLocation arrow_location,
+ views::BubbleBorder::BubbleAlignment alignment,
views::View* contents,
BubbleDelegate* delegate) {
delegate_ = delegate;
@@ -220,6 +223,7 @@ void Bubble::InitBubble(views::Widget* parent,
border_->InitBorderWidgetWin(CreateBorderContents(), parent->GetNativeView());
border_->border_contents()->SetBackgroundColor(kBackgroundColor);
+ border_->border_contents()->SetAlignment(alignment);
// We make the BorderWidgetWin the owner of the Bubble HWND, so that the
// latter is displayed on top of the former.
@@ -288,6 +292,7 @@ void Bubble::InitBubble(views::Widget* parent,
border_contents_ = CreateBorderContents();
border_contents_->Init();
border_contents_->SetBackgroundColor(kBackgroundColor);
+ border_contents_->SetAlignment(alignment);
gfx::Rect contents_bounds;
border_contents_->SizeAndGetBounds(position_relative_to,
arrow_location, false, contents->GetPreferredSize(),
diff --git a/chrome/browser/ui/views/bubble/bubble.h b/chrome/browser/ui/views/bubble/bubble.h
index 404501c..2ade620 100644
--- a/chrome/browser/ui/views/bubble/bubble.h
+++ b/chrome/browser/ui/views/bubble/bubble.h
@@ -112,6 +112,7 @@ class Bubble
static Bubble* Show(views::Widget* parent,
const gfx::Rect& position_relative_to,
views::BubbleBorder::ArrowLocation arrow_location,
+ views::BubbleBorder::BubbleAlignment alignment,
views::View* contents,
BubbleDelegate* delegate);
@@ -126,6 +127,7 @@ class Bubble
views::Widget* parent,
const gfx::Rect& position_relative_to,
views::BubbleBorder::ArrowLocation arrow_location,
+ views::BubbleBorder::BubbleAlignment alignment,
views::View* contents,
BubbleDelegate* delegate,
bool show_while_screen_is_locked);
@@ -181,6 +183,7 @@ class Bubble
virtual void InitBubble(views::Widget* parent,
const gfx::Rect& position_relative_to,
views::BubbleBorder::ArrowLocation arrow_location,
+ views::BubbleBorder::BubbleAlignment alignment,
views::View* contents,
BubbleDelegate* delegate);
diff --git a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc
index c7d1a3a..651c96f 100644
--- a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc
+++ b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc
@@ -408,7 +408,9 @@ void ExtensionInstalledBubble::ShowInternal() {
bubble_content_ = new InstalledBubbleContent(
browser_, extension_, type_, &icon_);
Bubble* bubble = Bubble::Show(browser_view->GetWidget(), bounds,
- arrow_location, bubble_content_, this);
+ arrow_location,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
+ bubble_content_, this);
bubble_content_->set_bubble(bubble);
}
diff --git a/chrome/browser/ui/views/first_run_bubble.cc b/chrome/browser/ui/views/first_run_bubble.cc
index 349257a..ea925db 100644
--- a/chrome/browser/ui/views/first_run_bubble.cc
+++ b/chrome/browser/ui/views/first_run_bubble.cc
@@ -510,7 +510,8 @@ FirstRunBubble* FirstRunBubble::Show(
}
bubble->set_view(view);
bubble->InitBubble(
- parent, position_relative_to, arrow_location, view, bubble);
+ parent, position_relative_to, arrow_location,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, view, bubble);
bubble->GetWidget()->GetFocusManager()->AddFocusChangeListener(view);
view->BubbleShown();
return bubble;
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 1d38db8..db38c3d 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -2603,15 +2603,14 @@ BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
void BrowserView::ShowAvatarBubble(TabContents* tab_contents,
const gfx::Rect& rect) {
- gfx::Point origin(rect.right(), rect.bottom());
+ gfx::Point origin(rect.origin());
views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin);
- gfx::Rect bounds;
- bounds.set_origin(origin);
+ gfx::Rect bounds(origin, rect.size());
AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_.get());
// Bubble::Show() takes ownership of the view.
- Bubble::Show(this->GetWidget(), bounds,
- views::BubbleBorder::TOP_RIGHT,
+ Bubble::Show(this->GetWidget(), bounds, views::BubbleBorder::TOP_RIGHT,
+ views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE,
bubble_view, bubble_view);
}
diff --git a/chrome/browser/ui/views/global_error_bubble_view.cc b/chrome/browser/ui/views/global_error_bubble_view.cc
index 76a6501..acfa705 100644
--- a/chrome/browser/ui/views/global_error_bubble_view.cc
+++ b/chrome/browser/ui/views/global_error_bubble_view.cc
@@ -172,7 +172,8 @@ void GlobalError::ShowBubbleView(Browser* browser, GlobalError* error) {
new GlobalErrorBubbleView(browser, error);
// Bubble::Show() takes ownership of the view.
Bubble* bubble = Bubble::Show(
- browser_view->GetWidget(), bounds,
- views::BubbleBorder::TOP_RIGHT, bubble_view, bubble_view);
+ browser_view->GetWidget(), bounds, views::BubbleBorder::TOP_RIGHT,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bubble_view,
+ bubble_view);
bubble_view->set_bubble(bubble);
}
diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
index 11c1835..d6cebb2 100644
--- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
@@ -144,6 +144,7 @@ void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event) {
profile, tab_contents->tab_contents());
bubble_ = Bubble::Show(GetWidget(), screen_bounds,
views::BubbleBorder::TOP_RIGHT,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
bubble_contents, this);
bubble_contents->set_bubble(bubble_);
}
diff --git a/chrome/browser/ui/views/page_info_bubble_view.cc b/chrome/browser/ui/views/page_info_bubble_view.cc
index 16033d9..9a6dbed 100644
--- a/chrome/browser/ui/views/page_info_bubble_view.cc
+++ b/chrome/browser/ui/views/page_info_bubble_view.cc
@@ -502,6 +502,7 @@ void ShowPageInfoBubble(BrowserView* browser_view,
Bubble* bubble =
Bubble::Show(browser_view->GetWidget(), bounds,
views::BubbleBorder::TOP_LEFT,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
page_info_bubble, page_info_bubble);
page_info_bubble->set_bubble(bubble);
}
diff --git a/chrome/browser/ui/views/pinned_contents_info_bubble.cc b/chrome/browser/ui/views/pinned_contents_info_bubble.cc
index f1b712b..3566536 100644
--- a/chrome/browser/ui/views/pinned_contents_info_bubble.cc
+++ b/chrome/browser/ui/views/pinned_contents_info_bubble.cc
@@ -44,6 +44,7 @@ PinnedContentsInfoBubble* PinnedContentsInfoBubble::Show(
PinnedContentsInfoBubble* bubble =
new PinnedContentsInfoBubble(bubble_anchor);
bubble->InitBubble(parent, position_relative_to, arrow_location,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
contents, delegate);
return bubble;
}
diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc
index 207d093..84ead0e 100644
--- a/chrome/browser/ui/views/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar_view.cc
@@ -731,6 +731,7 @@ void ToolbarView::ShowCriticalNotification() {
Bubble* bubble = Bubble::Show(GetWidget(),
gfx::Rect(screen_loc, app_menu_->size()),
views::BubbleBorder::TOP_RIGHT,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
critical_notification_bubble,
critical_notification_bubble);
bubble->set_close_on_deactivate(false);
diff --git a/chrome/browser/ui/views/web_intent_picker_view.cc b/chrome/browser/ui/views/web_intent_picker_view.cc
index 347d34a..387f77b 100644
--- a/chrome/browser/ui/views/web_intent_picker_view.cc
+++ b/chrome/browser/ui/views/web_intent_picker_view.cc
@@ -167,7 +167,9 @@ WebIntentPickerView::WebIntentPickerView(Browser* browser,
bounds.set_width(kIconHorizontalOffset);
bubble_ = Bubble::Show(browser_view->GetWidget(), bounds,
- views::BubbleBorder::TOP_LEFT, this, this);
+ views::BubbleBorder::TOP_LEFT,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
+ this, this);
}
WebIntentPickerView::~WebIntentPickerView() {
diff --git a/views/bubble/bubble_border.cc b/views/bubble/bubble_border.cc
index 871e669..7982fb1 100644
--- a/views/bubble/bubble_border.cc
+++ b/views/bubble/bubble_border.cc
@@ -60,12 +60,15 @@ gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& position_relative_to,
switch (arrow_location_) {
case TOP_LEFT:
case BOTTOM_LEFT:
- x += w / 2 - arrow_offset;
+ x += alignment_ == ALIGN_ARROW_TO_MID_ANCHOR ? w / 2 - arrow_offset :
+ -kArrowOverlap;
break;
case TOP_RIGHT:
case BOTTOM_RIGHT:
- x += w / 2 + arrow_offset - border_size.width() + 1;
+ x += alignment_ == ALIGN_ARROW_TO_MID_ANCHOR ?
+ w / 2 + arrow_offset - border_size.width() + 1 :
+ w - border_size.width() + kArrowOverlap;
break;
case LEFT_TOP:
@@ -98,12 +101,15 @@ gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& position_relative_to,
case LEFT_TOP:
case RIGHT_TOP:
- y += h / 2 - arrow_offset;
+ y += alignment_ == ALIGN_ARROW_TO_MID_ANCHOR ? h / 2 - arrow_offset :
+ -kArrowOverlap;
break;
case LEFT_BOTTOM:
case RIGHT_BOTTOM:
- y += h / 2 + arrow_offset - border_size.height() + 1;
+ y += alignment_ == ALIGN_ARROW_TO_MID_ANCHOR ?
+ h / 2 + arrow_offset - border_size.height() + 1 :
+ h - border_size.height() + kArrowOverlap;
break;
case NONE:
diff --git a/views/bubble/bubble_border.h b/views/bubble/bubble_border.h
index 59ec8b7..2331680 100644
--- a/views/bubble/bubble_border.h
+++ b/views/bubble/bubble_border.h
@@ -35,9 +35,18 @@ class VIEWS_EXPORT BubbleBorder : public views::Border {
FLOAT = 9 // No arrow. Centered over the supplied rect.
};
+ // The position of the bubble in relation to the anchor.
+ enum BubbleAlignment {
+ // The tip of the arrow points to the middle of the anchor.
+ ALIGN_ARROW_TO_MID_ANCHOR,
+ // The edge nearest to the arrow is lined up with the edge of the anchor.
+ ALIGN_EDGE_TO_ANCHOR_EDGE
+ };
+
explicit BubbleBorder(ArrowLocation arrow_location)
: override_arrow_offset_(0),
arrow_location_(arrow_location),
+ alignment_(ALIGN_ARROW_TO_MID_ANCHOR),
background_color_(SK_ColorWHITE) {
InitClass();
}
@@ -57,6 +66,10 @@ class VIEWS_EXPORT BubbleBorder : public views::Border {
}
ArrowLocation arrow_location() const { return arrow_location_; }
+ // Sets the alignment.
+ void set_alignment(BubbleAlignment alignment) { alignment_ = alignment; }
+ BubbleAlignment alignment() const { return alignment_; }
+
static ArrowLocation horizontal_mirror(ArrowLocation loc) {
return loc >= NONE ? loc : static_cast<ArrowLocation>(loc ^ 1);
}
@@ -151,6 +164,7 @@ class VIEWS_EXPORT BubbleBorder : public views::Border {
int override_arrow_offset_;
ArrowLocation arrow_location_;
+ BubbleAlignment alignment_;
SkColor background_color_;
DISALLOW_COPY_AND_ASSIGN(BubbleBorder);