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 #include "athena/home/minimized_home.h"
7 #include "ui/compositor/layer.h"
8 #include "ui/compositor/layer_owner.h"
9 #include "ui/gfx/canvas.h"
13 const int kDragHandleWidth
= 112;
14 const int kDragHandleHeight
= 2;
15 const char kMinimizedHomeLayerName
[] = "MinimizedHome";
17 class MinimizedHomePainter
: public ui::LayerDelegate
,
18 public ui::LayerOwner
{
20 explicit MinimizedHomePainter(ui::Layer
* layer
) {
21 layer
->set_name(kMinimizedHomeLayerName
);
22 layer
->set_delegate(this);
25 virtual ~MinimizedHomePainter() {}
29 virtual void OnPaintLayer(gfx::Canvas
* canvas
) OVERRIDE
{
30 gfx::Rect
bounds(layer()->GetTargetBounds().size());
31 canvas
->FillRect(bounds
, SK_ColorBLACK
);
32 canvas
->FillRect(gfx::Rect((bounds
.width() - kDragHandleWidth
) / 2,
33 bounds
.bottom() - kDragHandleHeight
,
39 virtual void OnDelegatedFrameDamage(
40 const gfx::Rect
& damage_rect_in_dip
) OVERRIDE
{
43 virtual void OnDeviceScaleFactorChanged(float device_scale_factor
) OVERRIDE
{
46 virtual base::Closure
PrepareForLayerBoundsChange() OVERRIDE
{
47 return base::Closure();
50 DISALLOW_COPY_AND_ASSIGN(MinimizedHomePainter
);
57 scoped_ptr
<ui::LayerOwner
> CreateMinimizedHome() {
58 return scoped_ptr
<ui::LayerOwner
>(
59 new MinimizedHomePainter(new ui::Layer(ui::LAYER_TEXTURED
)));