| 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_PROPORTIONAL_IMAGE_VIEW_H_ | 5 #ifndef UI_MESSAGE_CENTER_VIEWS_PROPORTIONAL_IMAGE_VIEW_H_ |
| 6 #define UI_MESSAGE_CENTER_VIEWS_PROPORTIONAL_IMAGE_VIEW_H_ | 6 #define UI_MESSAGE_CENTER_VIEWS_PROPORTIONAL_IMAGE_VIEW_H_ |
| 7 | 7 |
| 8 #include "ui/gfx/image/image_skia.h" | 8 #include "ui/gfx/image/image_skia.h" |
| 9 #include "ui/views/view.h" | 9 #include "ui/views/view.h" |
| 10 | 10 |
| 11 namespace message_center { | 11 namespace message_center { |
| 12 | 12 |
| 13 // ProportionalImageViews center their images to preserve their proportion. | 13 // ProportionalImageViews center their images to preserve their proportion. |
| 14 class ProportionalImageView : public views::View { | 14 class ProportionalImageView : public views::View { |
| 15 public: | 15 public: |
| 16 ProportionalImageView(const gfx::ImageSkia& image, const gfx::Size& max_size); | 16 ProportionalImageView(const gfx::ImageSkia& image, const gfx::Size& max_size); |
| 17 virtual ~ProportionalImageView(); | 17 virtual ~ProportionalImageView(); |
| 18 | 18 |
| 19 // Overridden from views::View: | 19 // Overridden from views::View: |
| 20 virtual gfx::Size GetPreferredSize() OVERRIDE; | 20 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 21 virtual int GetHeightForWidth(int width) OVERRIDE; | 21 virtual int GetHeightForWidth(int width) const OVERRIDE; |
| 22 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 22 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 23 | 23 |
| 24 private: | 24 private: |
| 25 gfx::Size GetImageDrawingSize(); | 25 gfx::Size GetImageDrawingSize(); |
| 26 | 26 |
| 27 gfx::ImageSkia image_; | 27 gfx::ImageSkia image_; |
| 28 gfx::Size max_size_; | 28 gfx::Size max_size_; |
| 29 | 29 |
| 30 DISALLOW_COPY_AND_ASSIGN(ProportionalImageView); | 30 DISALLOW_COPY_AND_ASSIGN(ProportionalImageView); |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 } // namespace message_center | 33 } // namespace message_center |
| 34 | 34 |
| 35 #endif // UI_MESSAGE_CENTER_VIEWS_PROPORTIONAL_IMAGE_VIEW_H_ | 35 #endif // UI_MESSAGE_CENTER_VIEWS_PROPORTIONAL_IMAGE_VIEW_H_ |
| OLD | NEW |