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

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

Issue 2684343006: Make the account chooser and CVC dialog use the same icon with toolip for Views. (Closed)
Patch Set: move files 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
« ui/views/bubble/tooltip_icon.h ('K') | « ui/views/bubble/tooltip_icon.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/bubble/tooltip_icon.cc
diff --git a/chrome/browser/ui/views/autofill/tooltip_icon.cc b/ui/views/bubble/tooltip_icon.cc
similarity index 58%
rename from chrome/browser/ui/views/autofill/tooltip_icon.cc
rename to ui/views/bubble/tooltip_icon.cc
index b2a2678f3c87c36595729ac2a62d71e66daaddaa..319bb77713762b00932f771db1cef6ce11bd023c 100644
--- a/chrome/browser/ui/views/autofill/tooltip_icon.cc
+++ b/ui/views/bubble/tooltip_icon.cc
@@ -2,59 +2,26 @@
// 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/tooltip_icon.h"
+#include "ui/views/bubble/tooltip_icon.h"
#include "base/macros.h"
msw 2017/02/15 21:06:39 nit: remove
vasilii 2017/02/16 14:28:07 Done.
#include "base/timer/timer.h"
-#include "chrome/browser/ui/views/autofill/info_bubble.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/views/bubble/bubble_frame_view.h"
+#include "ui/views/bubble/info_bubble.h"
#include "ui/views/mouse_watcher_view_host.h"
#include "ui/views/painter.h"
msw 2017/02/15 21:06:39 nit: remove?
vasilii 2017/02/16 14:28:06 Done.
-namespace autofill {
-
-namespace {
-
-gfx::Insets GetPreferredInsets(const views::View* view) {
- gfx::Size pref_size = view->GetPreferredSize();
- gfx::Rect local_bounds = view->GetLocalBounds();
- gfx::Point origin = local_bounds.CenterPoint();
- origin.Offset(-pref_size.width() / 2, -pref_size.height() / 2);
- return gfx::Insets(origin.y(),
- origin.x(),
- local_bounds.bottom() - (origin.y() + pref_size.height()),
- local_bounds.right() - (origin.x() + pref_size.width()));
-}
-
-// An info bubble with some extra positioning magic for tooltip icons.
-class TooltipBubble : public InfoBubble {
- public:
- TooltipBubble(views::View* anchor, const base::string16& message)
- : InfoBubble(anchor, message) {}
- ~TooltipBubble() override {}
-
- protected:
- // InfoBubble:
- gfx::Rect GetAnchorRect() const override {
- gfx::Rect bounds = views::BubbleDialogDelegateView::GetAnchorRect();
- bounds.Inset(GetPreferredInsets(anchor()));
- return bounds;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TooltipBubble);
-};
-
-} // namespace
+namespace views {
TooltipIcon::TooltipIcon(const base::string16& tooltip)
: tooltip_(tooltip),
mouse_inside_(false),
bubble_(NULL),
- bubble_arrow_(views::BubbleBorder::TOP_RIGHT),
+ preferred_width_(0),
+ bubble_arrow_(BubbleBorder::TOP_RIGHT),
observer_(this) {
SetDrawAsHovered(false);
}
@@ -102,7 +69,7 @@ void TooltipIcon::MouseMovedOutOfHost() {
}
void TooltipIcon::SetDrawAsHovered(bool hovered) {
- SetImage(gfx::CreateVectorIcon(gfx::VectorIconId::HELP_OUTLINE, 18,
+ SetImage(gfx::CreateVectorIcon(gfx::VectorIconId::INFO_OUTLINE, 18,
hovered
? SkColorSetARGB(0xBD, 0, 0, 0)
: SkColorSetARGB(0xBD, 0x44, 0x44, 0x44)));
@@ -114,7 +81,8 @@ void TooltipIcon::ShowBubble() {
SetDrawAsHovered(true);
- bubble_ = new TooltipBubble(this, tooltip_);
+ bubble_ = new InfoBubble(this, tooltip_);
+ bubble_->set_preferred_width(preferred_width_);
bubble_->set_arrow(bubble_arrow_);
// When shown due to a gesture event, close on deactivate (i.e. don't use
// "focusless").
@@ -124,10 +92,10 @@ void TooltipIcon::ShowBubble() {
observer_.Add(bubble_->GetWidget());
if (mouse_inside_) {
- views::View* frame = bubble_->GetWidget()->non_client_view()->frame_view();
- std::unique_ptr<views::MouseWatcherHost> host(
- new views::MouseWatcherViewHost(frame, gfx::Insets()));
- mouse_watcher_.reset(new views::MouseWatcher(host.release(), this));
+ View* frame = bubble_->GetWidget()->non_client_view()->frame_view();
+ std::unique_ptr<MouseWatcherHost> host(
+ new MouseWatcherViewHost(frame, gfx::Insets()));
msw 2017/02/15 21:06:39 nit: base::MakeUnique here and below
vasilii 2017/02/16 14:28:07 Done.
+ mouse_watcher_.reset(new MouseWatcher(host.release(), this));
mouse_watcher_->Start();
}
}
@@ -137,7 +105,7 @@ void TooltipIcon::HideBubble() {
bubble_->Hide();
}
-void TooltipIcon::OnWidgetDestroyed(views::Widget* widget) {
+void TooltipIcon::OnWidgetDestroyed(Widget* widget) {
observer_.Remove(widget);
SetDrawAsHovered(false);
@@ -145,4 +113,9 @@ void TooltipIcon::OnWidgetDestroyed(views::Widget* widget) {
bubble_ = NULL;
msw 2017/02/15 21:06:39 nit: nullptr here and elsewhere
vasilii 2017/02/16 14:28:07 Done.
}
-} // namespace autofill
+bool TooltipIcon::OnMousePressed(const ui::MouseEvent& event) {
+ // Swallow the click so that the parent doesn't process it.
+ return true;
+}
+
+} // namespace views
« ui/views/bubble/tooltip_icon.h ('K') | « ui/views/bubble/tooltip_icon.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698