| OLD | NEW |
| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 virtual gfx::Size GetPreferredSize() const override; |
| 73 virtual const char* GetClassName() const OVERRIDE; | 73 virtual const char* GetClassName() const override; |
| 74 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 74 virtual 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 virtual void OnFocus() override; |
| 79 virtual void OnBlur() OVERRIDE; | 79 virtual 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 virtual const gfx::ImageSkia& GetImage(ButtonState state) const override; |
| 145 virtual void SetImage(ButtonState state, | 145 virtual void SetImage(ButtonState state, |
| 146 const gfx::ImageSkia* image) OVERRIDE; | 146 const gfx::ImageSkia* image) override; |
| 147 | 147 |
| 148 // Overridden from View: | 148 // Overridden from View: |
| 149 virtual bool GetTooltipText(const gfx::Point& p, | 149 virtual bool GetTooltipText(const gfx::Point& p, |
| 150 base::string16* tooltip) const OVERRIDE; | 150 base::string16* tooltip) const override; |
| 151 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 151 virtual void GetAccessibleState(ui::AXViewState* state) override; |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 // The parent class's images_ member is used for the current images, | 154 // The parent class's images_ member is used for the current images, |
| 155 // and this array is used to hold the alternative images. | 155 // and this array is used to hold the alternative images. |
| 156 // We swap between the two when toggling. | 156 // We swap between the two when toggling. |
| 157 gfx::ImageSkia alternate_images_[STATE_COUNT]; | 157 gfx::ImageSkia alternate_images_[STATE_COUNT]; |
| 158 | 158 |
| 159 // True if the button is currently toggled. | 159 // True if the button is currently toggled. |
| 160 bool toggled_; | 160 bool toggled_; |
| 161 | 161 |
| 162 // The parent class's tooltip_text_ is displayed when not toggled, and | 162 // The parent class's tooltip_text_ is displayed when not toggled, and |
| 163 // this one is shown when toggled. | 163 // this one is shown when toggled. |
| 164 base::string16 toggled_tooltip_text_; | 164 base::string16 toggled_tooltip_text_; |
| 165 | 165 |
| 166 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); | 166 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 } // namespace views | 169 } // namespace views |
| 170 | 170 |
| 171 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 171 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
| OLD | NEW |