Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / athena / home / minimized_home.cc
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.
4
5 #include "athena/home/minimized_home.h"
6
7 #include "ui/compositor/layer.h"
8 #include "ui/compositor/layer_owner.h"
9 #include "ui/gfx/canvas.h"
10
11 namespace {
12
13 const int kDragHandleWidth = 112;
14 const int kDragHandleHeight = 2;
15 const char kMinimizedHomeLayerName[] = "MinimizedHome";
16
17 class MinimizedHomePainter : public ui::LayerDelegate,
18                              public ui::LayerOwner {
19  public:
20   explicit MinimizedHomePainter(ui::Layer* layer) {
21     layer->set_name(kMinimizedHomeLayerName);
22     layer->set_delegate(this);
23     SetLayer(layer);
24   }
25   virtual ~MinimizedHomePainter() {}
26
27  private:
28   // ui::LayerDelegate:
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,
34                                kDragHandleWidth,
35                                kDragHandleHeight),
36                      SK_ColorWHITE);
37   }
38
39   virtual void OnDelegatedFrameDamage(
40       const gfx::Rect& damage_rect_in_dip) OVERRIDE {
41   }
42
43   virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {
44   }
45
46   virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE {
47     return base::Closure();
48   }
49
50   DISALLOW_COPY_AND_ASSIGN(MinimizedHomePainter);
51 };
52
53 }  // namespace
54
55 namespace athena {
56
57 scoped_ptr<ui::LayerOwner> CreateMinimizedHome() {
58   return scoped_ptr<ui::LayerOwner>(
59       new MinimizedHomePainter(new ui::Layer(ui::LAYER_TEXTURED)));
60 }
61
62 }  // namespace athena