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

Side by Side Diff: ui/views/controls/button/image_button.h

Issue 681753004: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_
6 #define UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ 6 #define UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_
7 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ui/base/layout.h" 10 #include "ui/base/layout.h"
(...skipping 20 matching lines...) Expand all
31 ALIGN_RIGHT 31 ALIGN_RIGHT
32 }; 32 };
33 33
34 enum VerticalAlignment { 34 enum VerticalAlignment {
35 ALIGN_TOP = 0, 35 ALIGN_TOP = 0,
36 ALIGN_MIDDLE, 36 ALIGN_MIDDLE,
37 ALIGN_BOTTOM 37 ALIGN_BOTTOM
38 }; 38 };
39 39
40 explicit ImageButton(ButtonListener* listener); 40 explicit ImageButton(ButtonListener* listener);
41 virtual ~ImageButton(); 41 ~ImageButton() override;
42 42
43 // Returns the image for a given |state|. 43 // Returns the image for a given |state|.
44 virtual const gfx::ImageSkia& GetImage(ButtonState state) const; 44 virtual const gfx::ImageSkia& GetImage(ButtonState state) const;
45 45
46 // Set the image the button should use for the provided state. 46 // Set the image the button should use for the provided state.
47 virtual void SetImage(ButtonState state, const gfx::ImageSkia* image); 47 virtual void SetImage(ButtonState state, const gfx::ImageSkia* image);
48 48
49 // Set the background details. 49 // Set the background details.
50 void SetBackground(SkColor color, 50 void SetBackground(SkColor color,
51 const gfx::ImageSkia* image, 51 const gfx::ImageSkia* image,
(...skipping 10 matching lines...) Expand all
62 // larger. 62 // larger.
63 const gfx::Size& minimum_image_size() const { return minimum_image_size_; } 63 const gfx::Size& minimum_image_size() const { return minimum_image_size_; }
64 void SetMinimumImageSize(const gfx::Size& size); 64 void SetMinimumImageSize(const gfx::Size& size);
65 65
66 // Whether we should draw our images resources horizontally flipped. 66 // Whether we should draw our images resources horizontally flipped.
67 void SetDrawImageMirrored(bool mirrored) { 67 void SetDrawImageMirrored(bool mirrored) {
68 draw_image_mirrored_ = mirrored; 68 draw_image_mirrored_ = mirrored;
69 } 69 }
70 70
71 // Overridden from View: 71 // Overridden from View:
72 virtual gfx::Size GetPreferredSize() const override; 72 gfx::Size GetPreferredSize() const override;
73 virtual const char* GetClassName() const override; 73 const char* GetClassName() const override;
74 virtual void OnPaint(gfx::Canvas* canvas) override; 74 void OnPaint(gfx::Canvas* canvas) override;
75 75
76 protected: 76 protected:
77 // Overridden from View: 77 // Overridden from View:
78 virtual void OnFocus() override; 78 void OnFocus() override;
79 virtual void OnBlur() override; 79 void OnBlur() override;
80 80
81 // Returns the image to paint. This is invoked from paint and returns a value 81 // Returns the image to paint. This is invoked from paint and returns a value
82 // from images. 82 // from images.
83 virtual gfx::ImageSkia GetImageToPaint(); 83 virtual gfx::ImageSkia GetImageToPaint();
84 84
85 // Updates button background for |scale_factor|. 85 // Updates button background for |scale_factor|.
86 void UpdateButtonBackground(ui::ScaleFactor scale_factor); 86 void UpdateButtonBackground(ui::ScaleFactor scale_factor);
87 87
88 Painter* focus_painter() { return focus_painter_.get(); } 88 Painter* focus_painter() { return focus_painter_.get(); }
89 89
(...skipping 30 matching lines...) Expand all
120 //////////////////////////////////////////////////////////////////////////////// 120 ////////////////////////////////////////////////////////////////////////////////
121 // 121 //
122 // ToggleImageButton 122 // ToggleImageButton
123 // 123 //
124 // A toggle-able ImageButton. It swaps out its graphics when toggled. 124 // A toggle-able ImageButton. It swaps out its graphics when toggled.
125 // 125 //
126 //////////////////////////////////////////////////////////////////////////////// 126 ////////////////////////////////////////////////////////////////////////////////
127 class VIEWS_EXPORT ToggleImageButton : public ImageButton { 127 class VIEWS_EXPORT ToggleImageButton : public ImageButton {
128 public: 128 public:
129 explicit ToggleImageButton(ButtonListener* listener); 129 explicit ToggleImageButton(ButtonListener* listener);
130 virtual ~ToggleImageButton(); 130 ~ToggleImageButton() override;
131 131
132 // Change the toggled state. 132 // Change the toggled state.
133 void SetToggled(bool toggled); 133 void SetToggled(bool toggled);
134 134
135 // Like ImageButton::SetImage(), but to set the graphics used for the 135 // Like ImageButton::SetImage(), but to set the graphics used for the
136 // "has been toggled" state. Must be called for each button state 136 // "has been toggled" state. Must be called for each button state
137 // before the button is toggled. 137 // before the button is toggled.
138 void SetToggledImage(ButtonState state, const gfx::ImageSkia* image); 138 void SetToggledImage(ButtonState state, const gfx::ImageSkia* image);
139 139
140 // Set the tooltip text displayed when the button is toggled. 140 // Set the tooltip text displayed when the button is toggled.
141 void SetToggledTooltipText(const base::string16& tooltip); 141 void SetToggledTooltipText(const base::string16& tooltip);
142 142
143 // Overridden from ImageButton: 143 // Overridden from ImageButton:
144 virtual const gfx::ImageSkia& GetImage(ButtonState state) const override; 144 const gfx::ImageSkia& GetImage(ButtonState state) const override;
145 virtual void SetImage(ButtonState state, 145 void SetImage(ButtonState state, const gfx::ImageSkia* image) override;
146 const gfx::ImageSkia* image) override;
147 146
148 // Overridden from View: 147 // Overridden from View:
149 virtual bool GetTooltipText(const gfx::Point& p, 148 bool GetTooltipText(const gfx::Point& p,
150 base::string16* tooltip) const override; 149 base::string16* tooltip) const override;
151 virtual void GetAccessibleState(ui::AXViewState* state) override; 150 void GetAccessibleState(ui::AXViewState* state) override;
152 151
153 private: 152 private:
154 // The parent class's images_ member is used for the current images, 153 // The parent class's images_ member is used for the current images,
155 // and this array is used to hold the alternative images. 154 // and this array is used to hold the alternative images.
156 // We swap between the two when toggling. 155 // We swap between the two when toggling.
157 gfx::ImageSkia alternate_images_[STATE_COUNT]; 156 gfx::ImageSkia alternate_images_[STATE_COUNT];
158 157
159 // True if the button is currently toggled. 158 // True if the button is currently toggled.
160 bool toggled_; 159 bool toggled_;
161 160
162 // The parent class's tooltip_text_ is displayed when not toggled, and 161 // The parent class's tooltip_text_ is displayed when not toggled, and
163 // this one is shown when toggled. 162 // this one is shown when toggled.
164 base::string16 toggled_tooltip_text_; 163 base::string16 toggled_tooltip_text_;
165 164
166 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); 165 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton);
167 }; 166 };
168 167
169 } // namespace views 168 } // namespace views
170 169
171 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ 170 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_
OLDNEW
« no previous file with comments | « ui/views/controls/button/custom_button_unittest.cc ('k') | ui/views/controls/button/label_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698