blob: ad5d47a7874dfb3a8fe26b4b95d05fc0829079a4 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/macros.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/views/view.h"
namespace ash {
namespace tray {
// A custom image view with rounded edges.
class RoundedImageView : public views::View {
// Constructs a new rounded image view with rounded corners of radius
// |corner_radius|. If |active_user| is set, the icon will be drawn in
// full colors - otherwise it will fade into the background.
RoundedImageView(int corner_radius, bool active_user);
~RoundedImageView() override;
// Set the image that should be displayed. The image contents is copied to the
// receiver's image.
void SetImage(const gfx::ImageSkia& img, const gfx::Size& size);
// Set the radii of the corners independently.
void SetCornerRadii(int top_left,
int top_right,
int bottom_right,
int bottom_left);
// Overridden from views::View.
gfx::Size GetPreferredSize() const override;
void OnPaint(gfx::Canvas* canvas) override;
gfx::ImageSkia image_;
gfx::ImageSkia resized_;
gfx::Size image_size_;
int corner_radius_[4];
// True if the given user is the active user and the icon should get
// painted as active.
// TODO(estade): remove this, it's not used in Material Design.
bool active_user_;
} // namespace tray
} // namespace ash