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

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 (nits) 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() { return image_; }
56 views::Label* label() { return label_; } 56 views::Label* label() { return label_; }
57 const views::Label* label() const { return label_; }
57 58
58 // Gets the color for displaying text. 59 // Gets the color for displaying text.
59 virtual SkColor GetTextColor() const = 0; 60 virtual SkColor GetTextColor() const = 0;
60 61
61 // Gets the color for the border (a more transparent version of which is used 62 // Gets the color for the border (a more transparent version of which is used
62 // for the background). 63 // for the background).
63 virtual SkColor GetBorderColor() const = 0; 64 virtual SkColor GetBorderColor() const = 0;
64 65
65 // Returns true when the background should be rendered. 66 // Returns true when the background should be rendered.
66 virtual bool ShouldShowBackground() const; 67 virtual bool ShouldShowBackground() const;
67 68
68 // Returns a multiplier used to calculate the actual width of the view based 69 // 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 70 // 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. 71 // full-width view and can be used to animate the width of the view.
71 virtual double WidthMultiplier() const; 72 virtual double WidthMultiplier() const;
72 73
74 // Returns true when animation is in progress and is shrinking.
75 virtual bool IsShrinking() const;
76
73 // Returns the amount of horizontal space needed to draw the image and its 77 // Returns the amount of horizontal space needed to draw the image and its
74 // padding before the label. 78 // padding before the label.
75 virtual int GetImageAndPaddingWidth() const; 79 virtual int GetImageAndPaddingWidth() const;
76 80
77 // views::View: 81 // views::View:
78 gfx::Size GetPreferredSize() const override; 82 gfx::Size GetPreferredSize() const override;
79 void Layout() override; 83 void Layout() override;
80 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; 84 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override;
81 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; 85 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
82 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; 86 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
83 scoped_ptr<views::InkDropHover> CreateInkDropHover() const override; 87 scoped_ptr<views::InkDropHover> CreateInkDropHover() const override;
84 SkColor GetInkDropBaseColor() const override; 88 SkColor GetInkDropBaseColor() const override;
85 89
86 const gfx::FontList& font_list() const { return label_->font_list(); } 90 const gfx::FontList& font_list() const { return label_->font_list(); }
87 91
88 SkColor GetParentBackgroundColor() const; 92 SkColor GetParentBackgroundColor() const;
89 93
90 gfx::Size GetSizeForLabelWidth(int width) const; 94 gfx::Size GetSizeForLabelWidth(int label_width) const;
95
96 // Amount of padding from the edge of the icon / label to the outer edge of
97 // the bubble view. If |leading| is true, this is the padding at the
98 // beginning of the bubble (left in LTR), otherwise it's the trailing padding.
99 int GetBubbleOuterPadding(bool leading) const;
91 100
92 private: 101 private:
93 // Sets a background color on |label_| based on |chip_background_color| and 102 // Sets a background color on |label_| based on |chip_background_color| and
94 // the parent's bg color. 103 // the parent's bg color.
95 void SetLabelBackgroundColor(SkColor chip_background_color); 104 void SetLabelBackgroundColor(SkColor chip_background_color);
96 105
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. 106 // As above, but for Material Design. TODO(estade): remove/replace the above.
103 int GetBubbleOuterPaddingMd(bool leading) const; 107 int GetBubbleOuterPaddingMd(bool leading) const;
104 108
105 // views::View: 109 // views::View:
106 const char* GetClassName() const override; 110 const char* GetClassName() const override;
107 void OnPaint(gfx::Canvas* canvas) override; 111 void OnPaint(gfx::Canvas* canvas) override;
108 112
109 // For painting the background. TODO(estade): remove post MD launch. 113 // For painting the background. TODO(estade): remove post MD launch.
110 scoped_ptr<views::Painter> background_painter_; 114 scoped_ptr<views::Painter> background_painter_;
111 115
112 // The contents of the bubble. 116 // The contents of the bubble.
113 views::ImageView* image_; 117 views::ImageView* image_;
114 views::Label* label_; 118 views::Label* label_;
115 119
116 bool is_extension_icon_; 120 bool is_extension_icon_;
117 121
118 // This is only used in pre-MD. In MD, the background color is derived from 122 // 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): 123 // the native theme (so it responds to native theme updates). TODO(estade):
120 // remove when MD is default. 124 // remove when MD is default.
121 SkColor parent_background_color_; 125 SkColor parent_background_color_;
122 126
123 bool should_show_background_; 127 bool should_show_background_;
124 128
125 DISALLOW_COPY_AND_ASSIGN(IconLabelBubbleView); 129 DISALLOW_COPY_AND_ASSIGN(IconLabelBubbleView);
126 }; 130 };
127 131
128 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_ 132 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698