Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: ui/views/bubble/info_bubble.cc

Issue 2684343006: Make the account chooser and CVC dialog use the same icon with toolip for Views. (Closed)
Patch Set: comments from msw@ Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/bubble/info_bubble.h ('k') | ui/views/bubble/tooltip_icon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/bubble/info_bubble.cc
diff --git a/chrome/browser/ui/views/autofill/info_bubble.cc b/ui/views/bubble/info_bubble.cc
similarity index 53%
rename from chrome/browser/ui/views/autofill/info_bubble.cc
rename to ui/views/bubble/info_bubble.cc
index ecc7bc152cf3f8c21a847705eee0453baec543ad..0b633c919269133c1d5b3c1c278c1731edc027e8 100644
--- a/chrome/browser/ui/views/autofill/info_bubble.cc
+++ b/ui/views/bubble/info_bubble.cc
@@ -2,23 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/views/autofill/info_bubble.h"
+#include "ui/views/bubble/info_bubble.h"
-#include "base/i18n/rtl.h"
-#include "base/macros.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
-#include "ui/gfx/text_constants.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/bubble/bubble_frame_view.h"
-#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h"
-#include "ui/views/layout/layout_constants.h"
#include "ui/views/widget/widget.h"
-namespace autofill {
+namespace views {
namespace {
@@ -31,10 +26,10 @@ const int kInfoBubbleVerticalMargin = 12;
} // namespace
-class InfoBubbleFrame : public views::BubbleFrameView {
+class InfoBubbleFrame : public BubbleFrameView {
public:
explicit InfoBubbleFrame(const gfx::Insets& content_margins)
- : views::BubbleFrameView(gfx::Insets(), content_margins) {}
+ : BubbleFrameView(gfx::Insets(), content_margins) {}
~InfoBubbleFrame() override {}
gfx::Rect GetAvailableScreenBounds(const gfx::Rect& rect) const override {
@@ -52,24 +47,17 @@ class InfoBubbleFrame : public views::BubbleFrameView {
DISALLOW_COPY_AND_ASSIGN(InfoBubbleFrame);
};
-InfoBubble::InfoBubble(views::View* anchor,
- const base::string16& message)
- : anchor_(anchor),
- frame_(NULL),
- align_to_anchor_edge_(false),
- preferred_width_(233),
- show_above_anchor_(false) {
+InfoBubble::InfoBubble(View* anchor, const base::string16& message)
+ : anchor_(anchor), frame_(nullptr), preferred_width_(0) {
DCHECK(anchor_);
SetAnchorView(anchor_);
- set_margins(gfx::Insets(kInfoBubbleVerticalMargin,
- kInfoBubbleHorizontalMargin,
- kInfoBubbleVerticalMargin,
- kInfoBubbleHorizontalMargin));
+ set_margins(
+ gfx::Insets(kInfoBubbleVerticalMargin, kInfoBubbleHorizontalMargin));
set_can_activate(false);
- SetLayoutManager(new views::FillLayout);
- views::Label* label = new views::Label(message);
+ SetLayoutManager(new FillLayout);
+ Label* label = new Label(message);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label->SetMultiLine(true);
AddChildView(label);
@@ -78,71 +66,44 @@ InfoBubble::InfoBubble(views::View* anchor,
InfoBubble::~InfoBubble() {}
void InfoBubble::Show() {
- // TODO(dbeam): currently we assume that combobox menus always show downward
- // (which isn't true). If the invalid combobox is low enough on the screen,
- // its menu will actually show upward and obscure the bubble. Figure out when
- // this might happen and adjust |show_above_anchor_| accordingly. This is not
- // that big of deal because it rarely happens in practice.
- if (show_above_anchor_)
- set_arrow(views::BubbleBorder::vertical_mirror(arrow()));
-
- widget_ = views::BubbleDialogDelegateView::CreateBubble(this);
-
- if (align_to_anchor_edge_) {
- // The frame adjusts its arrow before the bubble's alignment can be changed.
- // Set the created bubble border back to the original arrow and re-adjust.
- frame_->bubble_border()->set_arrow(arrow());
- SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
- }
+ widget_ = BubbleDialogDelegateView::CreateBubble(this);
UpdatePosition();
}
void InfoBubble::Hide() {
- views::Widget* widget = GetWidget();
+ Widget* widget = GetWidget();
if (widget && !widget->IsClosed())
widget->Close();
}
-void InfoBubble::UpdatePosition() {
- if (!widget_)
- return;
-
- if (!anchor_->GetVisibleBounds().IsEmpty()) {
- SizeToContents();
- widget_->SetVisibilityChangedAnimationsEnabled(true);
- widget_->ShowInactive();
- } else {
- widget_->SetVisibilityChangedAnimationsEnabled(false);
- widget_->Hide();
- }
-}
-
-views::NonClientFrameView* InfoBubble::CreateNonClientFrameView(
- views::Widget* widget) {
+NonClientFrameView* InfoBubble::CreateNonClientFrameView(Widget* widget) {
DCHECK(!frame_);
frame_ = new InfoBubbleFrame(margins());
frame_->set_available_bounds(anchor_widget()->GetWindowBoundsInScreen());
- frame_->SetBubbleBorder(std::unique_ptr<views::BubbleBorder>(
- new views::BubbleBorder(arrow(), shadow(), color())));
+ frame_->SetBubbleBorder(std::unique_ptr<BubbleBorder>(
+ new BubbleBorder(arrow(), shadow(), color())));
return frame_;
}
gfx::Size InfoBubble::GetPreferredSize() const {
+ if (preferred_width_ == 0)
+ return BubbleDialogDelegateView::GetPreferredSize();
+
int pref_width = preferred_width_;
pref_width -= frame_->GetInsets().width();
pref_width -= 2 * kBubbleBorderVisibleWidth;
return gfx::Size(pref_width, GetHeightForWidth(pref_width));
}
-void InfoBubble::OnWidgetDestroyed(views::Widget* widget) {
+void InfoBubble::OnWidgetDestroyed(Widget* widget) {
if (widget == widget_)
- widget_ = NULL;
+ widget_ = nullptr;
}
-void InfoBubble::OnWidgetBoundsChanged(views::Widget* widget,
+void InfoBubble::OnWidgetBoundsChanged(Widget* widget,
const gfx::Rect& new_bounds) {
- views::BubbleDialogDelegateView::OnWidgetBoundsChanged(widget, new_bounds);
+ BubbleDialogDelegateView::OnWidgetBoundsChanged(widget, new_bounds);
if (anchor_widget() == widget)
frame_->set_available_bounds(widget->GetWindowBoundsInScreen());
}
@@ -151,4 +112,18 @@ int InfoBubble::GetDialogButtons() const {
return ui::DIALOG_BUTTON_NONE;
}
-} // namespace autofill
+void InfoBubble::UpdatePosition() {
+ if (!widget_)
+ return;
+
+ if (!anchor_->GetVisibleBounds().IsEmpty()) {
+ SizeToContents();
+ widget_->SetVisibilityChangedAnimationsEnabled(true);
+ widget_->ShowInactive();
+ } else {
+ widget_->SetVisibilityChangedAnimationsEnabled(false);
+ widget_->Hide();
+ }
+}
+
+} // namespace views
« no previous file with comments | « ui/views/bubble/info_bubble.h ('k') | ui/views/bubble/tooltip_icon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698