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

Side by Side Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_view.h

Issue 2720183002: [Views] Update ink drop for omnibox icons (Closed)
Patch Set: Update the behavior Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "ui/gfx/geometry/insets.h" 12 #include "ui/gfx/geometry/insets.h"
13 #include "ui/gfx/geometry/size.h" 13 #include "ui/gfx/geometry/size.h"
14 #include "ui/views/animation/ink_drop_host_view.h" 14 #include "ui/views/animation/ink_drop_host_view.h"
15 #include "ui/views/controls/label.h" 15 #include "ui/views/controls/label.h"
16 #include "ui/views/widget/widget_observer.h"
17
18 class SeparatorView;
bruthig 2017/03/08 18:58:24 I will let OWNER's confirm/correct me on this but
spqchan 2017/03/14 00:07:52 Done.
16 19
17 namespace gfx { 20 namespace gfx {
18 class Canvas;
19 class FontList; 21 class FontList;
20 class ImageSkia; 22 class ImageSkia;
21 } 23 }
22 24
23 namespace views { 25 namespace views {
24 class ImageView; 26 class ImageView;
25 class Label; 27 class InkDropContainerView;
26 } 28 }
27 29
28 // View used to draw a bubble, containing an icon and a label. We use this as a 30 // View used to draw a bubble, containing an icon and a label. We use this as a
29 // base for the classes that handle the location icon (including the EV bubble), 31 // base for the classes that handle the location icon (including the EV bubble),
30 // tab-to-search UI, and content settings. 32 // tab-to-search UI, and content settings.
31 class IconLabelBubbleView : public views::InkDropHostView { 33 class IconLabelBubbleView : public views::InkDropHostView,
34 public views::WidgetObserver {
32 public: 35 public:
33 static constexpr int kTrailingPaddingPreMd = 2; 36 static constexpr int kTrailingPaddingPreMd = 2;
34 37
35 IconLabelBubbleView(const gfx::FontList& font_list, bool elide_in_middle); 38 IconLabelBubbleView(const gfx::FontList& font_list, bool elide_in_middle);
36 ~IconLabelBubbleView() override; 39 ~IconLabelBubbleView() override;
37 40
38 void SetLabel(const base::string16& label); 41 void SetLabel(const base::string16& label);
39 void SetImage(const gfx::ImageSkia& image); 42 void SetImage(const gfx::ImageSkia& image);
40 43
41 const views::ImageView* GetImageView() const { return image_; } 44 const views::ImageView* GetImageView() const { return image_; }
(...skipping 18 matching lines...) Expand all
60 virtual bool ShouldShowLabel() const; 63 virtual bool ShouldShowLabel() const;
61 64
62 // Returns a multiplier used to calculate the actual width of the view based 65 // Returns a multiplier used to calculate the actual width of the view based
63 // on its desired width. This ranges from 0 for a zero-width view to 1 for a 66 // on its desired width. This ranges from 0 for a zero-width view to 1 for a
64 // full-width view and can be used to animate the width of the view. 67 // full-width view and can be used to animate the width of the view.
65 virtual double WidthMultiplier() const; 68 virtual double WidthMultiplier() const;
66 69
67 // Returns true when animation is in progress and is shrinking. 70 // Returns true when animation is in progress and is shrinking.
68 virtual bool IsShrinking() const; 71 virtual bool IsShrinking() const;
69 72
73 // Returns true if ink drop is enabled. Subclasses are expected to override
74 // this if they want to have an inkdrop effect. Otherwise, it's false by
75 // default.
76 virtual bool IsInkDropEnabled() const;
bruthig 2017/03/08 18:58:24 Would InkDropHostView::SetInkDropMode() be a suffi
spqchan 2017/03/14 00:07:52 Not quite, IsInkDropEnabled() is used in LocationI
77
70 // The view has been activated by a user gesture such as spacebar. Returns 78 // The view has been activated by a user gesture such as spacebar. Returns
71 // true if some handling was performed. 79 // true if some handling was performed.
72 virtual bool OnActivate(const ui::Event& event); 80 virtual bool OnActivate(const ui::Event& event);
73 81
74 // views::InkDropHostView: 82 // views::InkDropHostView:
75 gfx::Size GetPreferredSize() const override; 83 gfx::Size GetPreferredSize() const override;
76 void Layout() override; 84 void Layout() override;
85 bool OnMousePressed(const ui::MouseEvent& event) override;
86 void OnMouseReleased(const ui::MouseEvent& event) override;
77 bool OnKeyPressed(const ui::KeyEvent& event) override; 87 bool OnKeyPressed(const ui::KeyEvent& event) override;
78 bool OnKeyReleased(const ui::KeyEvent& event) override; 88 bool OnKeyReleased(const ui::KeyEvent& event) override;
79 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; 89 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
80 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; 90 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override;
81 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; 91 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
82 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; 92 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
93 std::unique_ptr<views::InkDrop> CreateInkDrop() override;
83 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() 94 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
84 const override; 95 const override;
96 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
85 SkColor GetInkDropBaseColor() const override; 97 SkColor GetInkDropBaseColor() const override;
98 void InkDropAnimationStarted() override;
99
100 // views::WidgetObserver:
101 void OnWidgetDestroying(views::Widget* widget) override;
102 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
86 103
87 const gfx::FontList& font_list() const { return label_->font_list(); } 104 const gfx::FontList& font_list() const { return label_->font_list(); }
88 105
89 SkColor GetParentBackgroundColor() const; 106 SkColor GetParentBackgroundColor() const;
90 107
91 gfx::Size GetSizeForLabelWidth(int label_width) const; 108 gfx::Size GetSizeForLabelWidth(int label_width) const;
92 109
93 private: 110 private:
111 friend SeparatorView;
112
94 // Amount of padding from the leading edge of the view to the leading edge of 113 // Amount of padding from the leading edge of the view to the leading edge of
95 // the image, and from the trailing edge of the label (or image, if the label 114 // the image, and from the trailing edge of the label (or image, if the label
96 // is invisible) to the trailing edge of the view. 115 // is invisible) to the trailing edge of the view.
97 int GetOuterPadding() const; 116 int GetOuterPadding() const;
98 117
99 // Spacing between the image and the label. 118 // Spacing between the image and the label.
100 int GetInternalSpacing() const; 119 int GetInternalSpacing() const;
101 120
102 // Padding after the separator. 121 // Padding after the separator.
103 int GetPostSeparatorPadding() const; 122 int GetPostSeparatorPadding() const;
104 123
105 float GetScaleFactor() const; 124 float GetScaleFactor() const;
106 125
107 // views::View: 126 // views::View:
108 const char* GetClassName() const override; 127 const char* GetClassName() const override;
109 void OnPaint(gfx::Canvas* canvas) override;
110 128
111 // The contents of the bubble. 129 // The contents of the bubble.
112 views::ImageView* image_; 130 views::ImageView* image_;
113 views::Label* label_; 131 views::Label* label_;
132 views::InkDropContainerView* ink_drop_container_;
133 std::unique_ptr<SeparatorView> separator_view_;
114 134
115 // The padding of the element that will be displayed after |this|. This value 135 // The padding of the element that will be displayed after |this|. This value
116 // is relevant for calculating the amount of space to reserve after the 136 // is relevant for calculating the amount of space to reserve after the
117 // separator. 137 // separator.
118 int next_element_interior_padding_ = 0; 138 int next_element_interior_padding_ = 0;
119 139
120 DISALLOW_COPY_AND_ASSIGN(IconLabelBubbleView); 140 DISALLOW_COPY_AND_ASSIGN(IconLabelBubbleView);
121 }; 141 };
122 142
123 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_ 143 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698