Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / ash / system / user / rounded_image_view.h
blob8e191ae1306aadf69582a8032c5b1065d8adff50
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
3 // found in the LICENSE file.
5 #ifndef ASH_SYSTEM_USER_ROUNDED_IMAGE_VIEW_H_
6 #define ASH_SYSTEM_USER_ROUNDED_IMAGE_VIEW_H_
8 #include "base/macros.h"
9 #include "ui/gfx/geometry/size.h"
10 #include "ui/gfx/image/image_skia.h"
11 #include "ui/views/view.h"
13 namespace ash {
14 namespace tray {
16 // A custom image view with rounded edges.
17 class RoundedImageView : public views::View {
18 public:
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
21 // full colors - otherwise it will fade into the background.
22 RoundedImageView(int corner_radius, bool active_user);
23 ~RoundedImageView() override;
25 // Set the image that should be displayed. The image contents is copied to the
26 // receiver's image.
27 void SetImage(const gfx::ImageSkia& img, const gfx::Size& size);
29 // Set the radii of the corners independently.
30 void SetCornerRadii(int top_left,
31 int top_right,
32 int bottom_right,
33 int bottom_left);
35 private:
36 // Overridden from views::View.
37 gfx::Size GetPreferredSize() const override;
38 void OnPaint(gfx::Canvas* canvas) override;
40 gfx::ImageSkia image_;
41 gfx::ImageSkia resized_;
42 gfx::Size image_size_;
43 int corner_radius_[4];
45 // True if the given user is the active user and the icon should get
46 // painted as active.
47 bool active_user_;
49 DISALLOW_COPY_AND_ASSIGN(RoundedImageView);
52 } // namespace tray
53 } // namespace ash
55 #endif // ASH_SYSTEM_USER_ROUNDED_IMAGE_VIEW_H_