| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/ui/focus_ring_layer.h" | 5 #include "chrome/browser/chromeos/ui/focus_ring_layer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/compositor/compositor_animation_observer.h" | 9 #include "ui/compositor/compositor_animation_observer.h" |
| 10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 gfx::Rect layer_bounds = bounds; | 42 gfx::Rect layer_bounds = bounds; |
| 43 int inset = -(kShadowRadius + 2); | 43 int inset = -(kShadowRadius + 2); |
| 44 layer_bounds.Inset(inset, inset, inset, inset); | 44 layer_bounds.Inset(inset, inset, inset, inset); |
| 45 CreateOrUpdateLayer(root_window, "FocusRing", layer_bounds); | 45 CreateOrUpdateLayer(root_window, "FocusRing", layer_bounds); |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool FocusRingLayer::CanAnimate() const { | 48 bool FocusRingLayer::CanAnimate() const { |
| 49 return compositor_ && compositor_->HasAnimationObserver(this); | 49 return compositor_ && compositor_->HasAnimationObserver(this); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void FocusRingLayer::SetOpacity(float opacity) { |
| 53 layer()->SetOpacity(opacity); |
| 54 } |
| 55 |
| 52 void FocusRingLayer::CreateOrUpdateLayer(aura::Window* root_window, | 56 void FocusRingLayer::CreateOrUpdateLayer(aura::Window* root_window, |
| 53 const char* layer_name, | 57 const char* layer_name, |
| 54 const gfx::Rect& bounds) { | 58 const gfx::Rect& bounds) { |
| 55 if (!layer_ || root_window != root_window_) { | 59 if (!layer_ || root_window != root_window_) { |
| 56 root_window_ = root_window; | 60 root_window_ = root_window; |
| 57 ui::Layer* root_layer = root_window->layer(); | 61 ui::Layer* root_layer = root_window->layer(); |
| 58 layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); | 62 layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); |
| 59 layer_->set_name(layer_name); | 63 layer_->set_name(layer_name); |
| 60 layer_->set_delegate(this); | 64 layer_->set_delegate(this); |
| 61 layer_->SetFillsBoundsOpaquely(false); | 65 layer_->SetFillsBoundsOpaquely(false); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 126 } |
| 123 | 127 |
| 124 void FocusRingLayer::OnCompositingShuttingDown(ui::Compositor* compositor) { | 128 void FocusRingLayer::OnCompositingShuttingDown(ui::Compositor* compositor) { |
| 125 if (compositor == compositor_) { | 129 if (compositor == compositor_) { |
| 126 compositor->RemoveAnimationObserver(this); | 130 compositor->RemoveAnimationObserver(this); |
| 127 compositor_ = nullptr; | 131 compositor_ = nullptr; |
| 128 } | 132 } |
| 129 } | 133 } |
| 130 | 134 |
| 131 } // namespace chromeos | 135 } // namespace chromeos |
| OLD | NEW |