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

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

Issue 1423263004: [MD] Use programmatic rendering for omnibox chips (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 5 years, 1 month 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/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 12 matching lines...) Expand all
23 class ImageView; 23 class ImageView;
24 class Label; 24 class Label;
25 class Painter; 25 class Painter;
26 } 26 }
27 27
28 // View used to draw a bubble, containing an icon and a label. We use this as a 28 // 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 EV bubble, tab-to-search UI, and 29 // base for the classes that handle the EV bubble, tab-to-search UI, and
30 // content settings. 30 // content settings.
31 class IconLabelBubbleView : public views::View { 31 class IconLabelBubbleView : public views::View {
32 public: 32 public:
33 // TODO(estade): remove |text_color| which is not used for MD.
33 IconLabelBubbleView(int contained_image, 34 IconLabelBubbleView(int contained_image,
34 const gfx::FontList& font_list, 35 const gfx::FontList& font_list,
35 SkColor text_color, 36 SkColor text_color,
36 SkColor parent_background_color, 37 SkColor parent_background_color,
37 bool elide_in_middle); 38 bool elide_in_middle);
38 ~IconLabelBubbleView() override; 39 ~IconLabelBubbleView() override;
39 40
41 // Gets the color for displaying text.
42 virtual SkColor GetTextColor() const = 0;
43 // Gets the color for the border (a more transparent version of
44 // which is used for the background).
45 virtual SkColor GetBorderColor() const = 0;
46
40 // Sets a background that paints |background_images| in a scalable grid. 47 // Sets a background that paints |background_images| in a scalable grid.
41 // Subclasses are required to call this or SetBackgroundImageWithInsets during 48 // Subclasses are required to call this or SetBackgroundImageWithInsets during
42 // construction. 49 // construction.
43 void SetBackgroundImageGrid(const int background_images[]); 50 void SetBackgroundImageGrid(const int background_images[]);
44 51
45 // Divides the image designated by |background_image_id| into nine regions.
46 // The four corners are specified by |insets|, the remainder are stretched to
47 // fill the background. Subclasses are required to call this or
48 // SetBackgroundImageGrid during construction.
49 void SetBackgroundImageWithInsets(int background_image_id,
50 gfx::Insets& insets);
51
52 void SetLabel(const base::string16& label); 52 void SetLabel(const base::string16& label);
53 void SetImage(const gfx::ImageSkia& image); 53 void SetImage(const gfx::ImageSkia& image);
54 void set_is_extension_icon(bool is_extension_icon) { 54 void set_is_extension_icon(bool is_extension_icon) {
55 is_extension_icon_ = is_extension_icon; 55 is_extension_icon_ = is_extension_icon;
56 } 56 }
57 57
58 protected: 58 protected:
59 views::ImageView* image() { return image_; } 59 views::ImageView* image() { return image_; }
60 views::Label* label() { return label_; } 60 views::Label* label() { return label_; }
61 61
62 // Returns true when the background should be rendered. 62 // Returns true when the background should be rendered.
63 virtual bool ShouldShowBackground() const; 63 virtual bool ShouldShowBackground() const;
64 64
65 // 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
66 // 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
67 // 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.
68 virtual double WidthMultiplier() const; 68 virtual double WidthMultiplier() const;
69 69
70 // views::View: 70 // views::View:
71 gfx::Size GetPreferredSize() const override; 71 gfx::Size GetPreferredSize() const override;
72 void Layout() override; 72 void Layout() override;
73 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override;
73 74
74 const gfx::FontList& font_list() const { return label_->font_list(); } 75 const gfx::FontList& font_list() const { return label_->font_list(); }
75 76
76 gfx::Size GetSizeForLabelWidth(int width) const; 77 gfx::Size GetSizeForLabelWidth(int width) const;
77 78
78 private: 79 private:
79 // Amount of padding at the edges of the bubble. If |by_icon| is true, this 80 // Amount of padding at the edges of the bubble. If |by_icon| is true, this
80 // is the padding next to the icon; otherwise it's the padding next to the 81 // is the padding next to the icon; otherwise it's the padding next to the
81 // label. (We increase padding next to the label by the amount of padding 82 // label. (We increase padding next to the label by the amount of padding
82 // "built in" to the icon in order to make the bubble appear to have 83 // "built in" to the icon in order to make the bubble appear to have
83 // symmetrical padding.) 84 // symmetrical padding.)
84 int GetBubbleOuterPadding(bool by_icon) const; 85 int GetBubbleOuterPadding(bool by_icon) const;
85 86
86 // Sets a background color on |label_| based on |background_image_color| and 87 // Sets a background color on |label_| based on |background_image_color| and
87 // |parent_background_color_|. 88 // |parent_background_color_|.
88 void SetLabelBackgroundColor(SkColor background_image_color); 89 void SetLabelBackgroundColor(SkColor background_image_color);
89 90
90 // views::View: 91 // views::View:
91 const char* GetClassName() const override; 92 const char* GetClassName() const override;
92 void OnPaint(gfx::Canvas* canvas) override; 93 void OnPaint(gfx::Canvas* canvas) override;
93 94
94 // For painting the background. 95 // For painting the background. TODO(estade): remove post MD launch.
95 scoped_ptr<views::Painter> background_painter_; 96 scoped_ptr<views::Painter> background_painter_;
96 97
97 // The contents of the bubble. 98 // The contents of the bubble.
98 views::ImageView* image_; 99 views::ImageView* image_;
99 views::Label* label_; 100 views::Label* label_;
100 101
101 bool is_extension_icon_; 102 bool is_extension_icon_;
102 103
103 SkColor parent_background_color_; 104 SkColor parent_background_color_;
104 105
105 DISALLOW_COPY_AND_ASSIGN(IconLabelBubbleView); 106 DISALLOW_COPY_AND_ASSIGN(IconLabelBubbleView);
106 }; 107 };
107 108
108 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_ 109 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698