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

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

Issue 1763713004: Adjusts content bubble animation with respect to icon size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjusts content bubble animation with respect to icon size (code comment) Created 4 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"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 void SetLabel(const base::string16& label); 45 void SetLabel(const base::string16& label);
46 void SetImage(const gfx::ImageSkia& image); 46 void SetImage(const gfx::ImageSkia& image);
47 void set_is_extension_icon(bool is_extension_icon) { 47 void set_is_extension_icon(bool is_extension_icon) {
48 is_extension_icon_ = is_extension_icon; 48 is_extension_icon_ = is_extension_icon;
49 } 49 }
50 50
51 const views::ImageView* GetImageView() const { return image_; } 51 const views::ImageView* GetImageView() const { return image_; }
52 views::ImageView* GetImageView() { return image_; } 52 views::ImageView* GetImageView() { return image_; }
53 53
54 protected: 54 protected:
55 views::ImageView* image() { return image_; } 55 views::ImageView* image() const { return image_; }
56 views::Label* label() { return label_; } 56 views::Label* label() const { return label_; }
Peter Kasting 2016/03/07 20:24:27 Don't make these changes, or else make them by add
varkha 2016/03/08 18:01:04 Done.
57 57
58 // Gets the color for displaying text. 58 // Gets the color for displaying text.
59 virtual SkColor GetTextColor() const = 0; 59 virtual SkColor GetTextColor() const = 0;
60 60
61 // Gets the color for the border (a more transparent version of which is used 61 // Gets the color for the border (a more transparent version of which is used
62 // for the background). 62 // for the background).
63 virtual SkColor GetBorderColor() const = 0; 63 virtual SkColor GetBorderColor() const = 0;
64 64
65 // Returns true when the background should be rendered. 65 // Returns true when the background should be rendered.
66 virtual bool ShouldShowBackground() const; 66 virtual bool ShouldShowBackground() const;
67 67
68 // Returns a multiplier used to calculate the actual width of the view based 68 // Returns a multiplier used to calculate the actual width of the view based
69 // on its desired width. This ranges from 0 for a zero-width view to 1 for a 69 // on its desired width. This ranges from 0 for a zero-width view to 1 for a
70 // full-width view and can be used to animate the width of the view. 70 // full-width view and can be used to animate the width of the view.
71 virtual double WidthMultiplier() const; 71 virtual double WidthMultiplier() const;
72 72
73 // Stops animation if it is in progress.
74 virtual void StopAnimation();
75
76 // Returns true when animation is in progress and is shrinking.
77 virtual bool IsShrinking() const;
78
73 // Returns the amount of horizontal space needed to draw the image and its 79 // Returns the amount of horizontal space needed to draw the image and its
74 // padding before the label. 80 // padding before the label.
75 virtual int GetImageAndPaddingWidth() const; 81 virtual int GetImageAndPaddingWidth() const;
76 82
77 // views::View: 83 // views::View:
78 gfx::Size GetPreferredSize() const override; 84 gfx::Size GetPreferredSize() const override;
79 void Layout() override; 85 void Layout() override;
80 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; 86 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override;
81 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; 87 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
82 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; 88 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
83 scoped_ptr<views::InkDropHover> CreateInkDropHover() const override; 89 scoped_ptr<views::InkDropHover> CreateInkDropHover() const override;
84 SkColor GetInkDropBaseColor() const override; 90 SkColor GetInkDropBaseColor() const override;
85 91
86 const gfx::FontList& font_list() const { return label_->font_list(); } 92 const gfx::FontList& font_list() const { return label_->font_list(); }
87 93
88 SkColor GetParentBackgroundColor() const; 94 SkColor GetParentBackgroundColor() const;
89 95
90 gfx::Size GetSizeForLabelWidth(int width) const; 96 gfx::Size GetSizeForLabelWidth(int width) const;
91 97
98 // Amount of padding at the edges of the bubble. If |leading| is true, this
Peter Kasting 2016/03/07 20:24:27 Nit: For clarity you might want to be a bit more p
varkha 2016/03/08 18:01:03 Done.
99 // is the padding at the beginning of the bubble (left in LTR), otherwise it's
100 // the end padding.
Peter Kasting 2016/03/07 20:24:27 Nit: end -> trailing
varkha 2016/03/08 18:01:04 Done.
101 int GetBubbleOuterPadding(bool leading) const;
102
92 private: 103 private:
93 // Sets a background color on |label_| based on |chip_background_color| and 104 // Sets a background color on |label_| based on |chip_background_color| and
94 // the parent's bg color. 105 // the parent's bg color.
95 void SetLabelBackgroundColor(SkColor chip_background_color); 106 void SetLabelBackgroundColor(SkColor chip_background_color);
96 107
97 // Amount of padding at the edges of the bubble. If |leading| is true, this
98 // is the padding at the beginning of the bubble (left in LTR), otherwise it's
99 // the end padding.
100 int GetBubbleOuterPadding(bool leading) const;
101
102 // As above, but for Material Design. TODO(estade): remove/replace the above. 108 // As above, but for Material Design. TODO(estade): remove/replace the above.
103 int GetBubbleOuterPaddingMd(bool leading) const; 109 int GetBubbleOuterPaddingMd(bool leading) const;
104 110
105 // views::View: 111 // views::View:
106 const char* GetClassName() const override; 112 const char* GetClassName() const override;
107 void OnPaint(gfx::Canvas* canvas) override; 113 void OnPaint(gfx::Canvas* canvas) override;
108 114
109 // For painting the background. TODO(estade): remove post MD launch. 115 // For painting the background. TODO(estade): remove post MD launch.
110 scoped_ptr<views::Painter> background_painter_; 116 scoped_ptr<views::Painter> background_painter_;
111 117
112 // The contents of the bubble. 118 // The contents of the bubble.
113 views::ImageView* image_; 119 views::ImageView* image_;
114 views::Label* label_; 120 views::Label* label_;
115 121
116 bool is_extension_icon_; 122 bool is_extension_icon_;
117 123
118 // This is only used in pre-MD. In MD, the background color is derived from 124 // This is only used in pre-MD. In MD, the background color is derived from
119 // the native theme (so it responds to native theme updates). TODO(estade): 125 // the native theme (so it responds to native theme updates). TODO(estade):
120 // remove when MD is default. 126 // remove when MD is default.
121 SkColor parent_background_color_; 127 SkColor parent_background_color_;
122 128
123 bool should_show_background_; 129 bool should_show_background_;
124 130
125 DISALLOW_COPY_AND_ASSIGN(IconLabelBubbleView); 131 DISALLOW_COPY_AND_ASSIGN(IconLabelBubbleView);
126 }; 132 };
127 133
128 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_ 134 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698