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