| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 ASH_COMMON_SYSTEM_USER_ROUNDED_IMAGE_VIEW_H_ | 5 #ifndef ASH_COMMON_SYSTEM_USER_ROUNDED_IMAGE_VIEW_H_ |
| 6 #define ASH_COMMON_SYSTEM_USER_ROUNDED_IMAGE_VIEW_H_ | 6 #define ASH_COMMON_SYSTEM_USER_ROUNDED_IMAGE_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "ui/gfx/geometry/size.h" | 9 #include "ui/gfx/geometry/size.h" |
| 10 #include "ui/gfx/image/image_skia.h" | 10 #include "ui/gfx/image/image_skia.h" |
| 11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 namespace tray { | 14 namespace tray { |
| 15 | 15 |
| 16 // A custom image view with rounded edges. | 16 // A custom image view with rounded edges. |
| 17 class RoundedImageView : public views::View { | 17 class RoundedImageView : public views::View { |
| 18 public: | 18 public: |
| 19 // Constructs a new rounded image view with rounded corners of radius | 19 // Constructs a new rounded image view with rounded corners of radius |
| 20 // |corner_radius|. If |active_user| is set, the icon will be drawn in | 20 // |corner_radius|. |
| 21 // full colors - otherwise it will fade into the background. | 21 explicit RoundedImageView(int corner_radius); |
| 22 RoundedImageView(int corner_radius, bool active_user); | |
| 23 ~RoundedImageView() override; | 22 ~RoundedImageView() override; |
| 24 | 23 |
| 25 // Set the image that should be displayed. The image contents is copied to the | 24 // Set the image that should be displayed. The image contents is copied to the |
| 26 // receiver's image. | 25 // receiver's image. |
| 27 void SetImage(const gfx::ImageSkia& img, const gfx::Size& size); | 26 void SetImage(const gfx::ImageSkia& img, const gfx::Size& size); |
| 28 | 27 |
| 29 // Set the radii of the corners independently. | 28 // Set the radii of the corners independently. |
| 30 void SetCornerRadii(int top_left, | 29 void SetCornerRadii(int top_left, |
| 31 int top_right, | 30 int top_right, |
| 32 int bottom_right, | 31 int bottom_right, |
| 33 int bottom_left); | 32 int bottom_left); |
| 34 | 33 |
| 35 // Overridden from views::View. | 34 // Overridden from views::View. |
| 36 gfx::Size GetPreferredSize() const override; | 35 gfx::Size GetPreferredSize() const override; |
| 37 void OnPaint(gfx::Canvas* canvas) override; | 36 void OnPaint(gfx::Canvas* canvas) override; |
| 38 | 37 |
| 39 private: | 38 private: |
| 40 gfx::ImageSkia image_; | 39 gfx::ImageSkia image_; |
| 41 gfx::ImageSkia resized_; | 40 gfx::ImageSkia resized_; |
| 42 gfx::Size image_size_; | 41 gfx::Size image_size_; |
| 43 int corner_radius_[4]; | 42 int corner_radius_[4]; |
| 44 | 43 |
| 45 // True if the given user is the active user and the icon should get | |
| 46 // painted as active. | |
| 47 // TODO(estade): remove this, it's not used in Material Design. | |
| 48 bool active_user_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(RoundedImageView); | 44 DISALLOW_COPY_AND_ASSIGN(RoundedImageView); |
| 51 }; | 45 }; |
| 52 | 46 |
| 53 } // namespace tray | 47 } // namespace tray |
| 54 } // namespace ash | 48 } // namespace ash |
| 55 | 49 |
| 56 #endif // ASH_COMMON_SYSTEM_USER_ROUNDED_IMAGE_VIEW_H_ | 50 #endif // ASH_COMMON_SYSTEM_USER_ROUNDED_IMAGE_VIEW_H_ |
| OLD | NEW |