| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MESSAGE_CENTER_VIEWS_PADDED_BUTTON_H_ | 5 #ifndef UI_MESSAGE_CENTER_VIEWS_PADDED_BUTTON_H_ |
| 6 #define UI_MESSAGE_CENTER_VIEWS_PADDED_BUTTON_H_ | 6 #define UI_MESSAGE_CENTER_VIEWS_PADDED_BUTTON_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "ui/views/controls/button/image_button.h" | 10 #include "ui/views/controls/button/image_button.h" |
| 11 | 11 |
| 12 namespace message_center { | 12 namespace message_center { |
| 13 | 13 |
| 14 // PaddedButtons are ImageButtons whose image can be padded within the button. | 14 // PaddedButtons are ImageButtons whose image can be padded within the button. |
| 15 // This allows the creation of buttons like the notification close and expand | 15 // This allows the creation of buttons like the notification close and expand |
| 16 // buttons whose clickable areas extends beyond their image areas | 16 // buttons whose clickable areas extends beyond their image areas |
| 17 // (<http://crbug.com/168822>) without the need to create and maintain | 17 // (<http://crbug.com/168822>) without the need to create and maintain |
| 18 // corresponding resource images with alpha padding. In the future, this class | 18 // corresponding resource images with alpha padding. In the future, this class |
| 19 // will also allow for buttons whose touch areas extend beyond their clickable | 19 // will also allow for buttons whose touch areas extend beyond their clickable |
| 20 // area (<http://crbug.com/168856>). | 20 // area (<http://crbug.com/168856>). |
| 21 class PaddedButton : public views::ImageButton { | 21 class PaddedButton : public views::ImageButton { |
| 22 public: | 22 public: |
| 23 PaddedButton(views::ButtonListener* listener); | 23 PaddedButton(views::ButtonListener* listener); |
| 24 virtual ~PaddedButton(); | 24 virtual ~PaddedButton(); |
| 25 | 25 |
| 26 // Overridden from views::ImageButton: | 26 // Overridden from views::ImageButton: |
| 27 virtual gfx::Size GetPreferredSize() OVERRIDE; | 27 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 28 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 28 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 29 virtual void OnFocus() OVERRIDE; | 29 virtual void OnFocus() OVERRIDE; |
| 30 | 30 |
| 31 // The SetPadding() method also sets the button's image alignment (positive | 31 // The SetPadding() method also sets the button's image alignment (positive |
| 32 // values yield left/top alignments, negative values yield right/bottom ones, | 32 // values yield left/top alignments, negative values yield right/bottom ones, |
| 33 // and zero values center/middle ones). ImageButton::SetImageAlignment() calls | 33 // and zero values center/middle ones). ImageButton::SetImageAlignment() calls |
| 34 // will not affect PaddedButton image alignments. | 34 // will not affect PaddedButton image alignments. |
| 35 void SetPadding(int horizontal_padding, int vertical_padding); | 35 void SetPadding(int horizontal_padding, int vertical_padding); |
| 36 | 36 |
| 37 void SetNormalImage(int resource_id); | 37 void SetNormalImage(int resource_id); |
| 38 void SetHoveredImage(int resource_id); | 38 void SetHoveredImage(int resource_id); |
| 39 void SetPressedImage(int resource_id); | 39 void SetPressedImage(int resource_id); |
| 40 | 40 |
| 41 protected: | 41 protected: |
| 42 gfx::Point ComputePaddedImagePaintPosition(const gfx::ImageSkia& image); | 42 gfx::Point ComputePaddedImagePaintPosition(const gfx::ImageSkia& image); |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 gfx::Insets padding_; | 45 gfx::Insets padding_; |
| 46 | 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(PaddedButton); | 47 DISALLOW_COPY_AND_ASSIGN(PaddedButton); |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 } // namespace message_center | 50 } // namespace message_center |
| 51 | 51 |
| 52 #endif // UI_MESSAGE_CENTER_VIEWS_PADDED_BUTTON_H_ | 52 #endif // UI_MESSAGE_CENTER_VIEWS_PADDED_BUTTON_H_ |
| OLD | NEW |