| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/display/shared_display_edge_indicator.h" | 5 #include "ash/display/shared_display_edge_indicator.h" |
| 6 | 6 |
| 7 #include "ash/common/shell_window_ids.h" | 7 #include "ash/common/shell_window_ids.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
| 10 #include "ui/aura/client/screen_position_client.h" | 10 #include "ui/aura/client/screen_position_client.h" |
| 11 #include "ui/aura/window_event_dispatcher.h" | 11 #include "ui/aura/window_event_dispatcher.h" |
| 12 #include "ui/display/display.h" | 12 #include "ui/display/display.h" |
| 13 #include "ui/display/screen.h" | 13 #include "ui/display/screen.h" |
| 14 #include "ui/gfx/animation/throb_animation.h" | 14 #include "ui/gfx/animation/throb_animation.h" |
| 15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 16 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 | 18 |
| 19 namespace ash { | 19 namespace ash { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const int kIndicatorAnimationDurationMs = 1000; | 22 const int kIndicatorAnimationDurationMs = 1000; |
| 23 | 23 |
| 24 class IndicatorView : public views::View { | 24 class IndicatorView : public views::View { |
| 25 public: | 25 public: |
| 26 IndicatorView() { | 26 IndicatorView() {} |
| 27 } | |
| 28 ~IndicatorView() override {} | 27 ~IndicatorView() override {} |
| 29 | 28 |
| 30 void SetColor(SkColor color) { | 29 void SetColor(SkColor color) { |
| 31 color_ = color; | 30 color_ = color; |
| 32 SchedulePaint(); | 31 SchedulePaint(); |
| 33 } | 32 } |
| 34 | 33 |
| 35 // views::Views overrides: | 34 // views::Views overrides: |
| 36 void OnPaint(gfx::Canvas* canvas) override { | 35 void OnPaint(gfx::Canvas* canvas) override { |
| 37 canvas->FillRect(gfx::Rect(bounds().size()), color_); | 36 canvas->FillRect(gfx::Rect(bounds().size()), color_); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 62 aura::client::ScreenPositionClient* screen_position_client = | 61 aura::client::ScreenPositionClient* screen_position_client = |
| 63 aura::client::GetScreenPositionClient(window->GetRootWindow()); | 62 aura::client::GetScreenPositionClient(window->GetRootWindow()); |
| 64 screen_position_client->SetBounds(window, bounds, display); | 63 screen_position_client->SetBounds(window, bounds, display); |
| 65 widget->Show(); | 64 widget->Show(); |
| 66 return widget; | 65 return widget; |
| 67 } | 66 } |
| 68 | 67 |
| 69 } // namespace | 68 } // namespace |
| 70 | 69 |
| 71 SharedDisplayEdgeIndicator::SharedDisplayEdgeIndicator() | 70 SharedDisplayEdgeIndicator::SharedDisplayEdgeIndicator() |
| 72 : src_indicator_(NULL), | 71 : src_indicator_(NULL), dst_indicator_(NULL) {} |
| 73 dst_indicator_(NULL) { | |
| 74 } | |
| 75 | 72 |
| 76 SharedDisplayEdgeIndicator::~SharedDisplayEdgeIndicator() { | 73 SharedDisplayEdgeIndicator::~SharedDisplayEdgeIndicator() { |
| 77 Hide(); | 74 Hide(); |
| 78 } | 75 } |
| 79 | 76 |
| 80 void SharedDisplayEdgeIndicator::Show(const gfx::Rect& src_bounds, | 77 void SharedDisplayEdgeIndicator::Show(const gfx::Rect& src_bounds, |
| 81 const gfx::Rect& dst_bounds) { | 78 const gfx::Rect& dst_bounds) { |
| 82 DCHECK(!src_indicator_); | 79 DCHECK(!src_indicator_); |
| 83 DCHECK(!dst_indicator_); | 80 DCHECK(!dst_indicator_); |
| 84 src_indicator_ = new IndicatorView; | 81 src_indicator_ = new IndicatorView; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 100 } | 97 } |
| 101 | 98 |
| 102 void SharedDisplayEdgeIndicator::AnimationProgressed( | 99 void SharedDisplayEdgeIndicator::AnimationProgressed( |
| 103 const gfx::Animation* animation) { | 100 const gfx::Animation* animation) { |
| 104 int value = animation->CurrentValueBetween(0, 255); | 101 int value = animation->CurrentValueBetween(0, 255); |
| 105 SkColor color = SkColorSetARGB(0xFF, value, value, value); | 102 SkColor color = SkColorSetARGB(0xFF, value, value, value); |
| 106 if (src_indicator_) | 103 if (src_indicator_) |
| 107 static_cast<IndicatorView*>(src_indicator_)->SetColor(color); | 104 static_cast<IndicatorView*>(src_indicator_)->SetColor(color); |
| 108 if (dst_indicator_) | 105 if (dst_indicator_) |
| 109 static_cast<IndicatorView*>(dst_indicator_)->SetColor(color); | 106 static_cast<IndicatorView*>(dst_indicator_)->SetColor(color); |
| 110 | |
| 111 } | 107 } |
| 112 | 108 |
| 113 } // namespace ash | 109 } // namespace ash |
| OLD | NEW |