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