| 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 #ifndef CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "third_party/skia/include/core/SkColor.h" |
| 12 #include "ui/compositor/compositor_animation_observer.h" | 13 #include "ui/compositor/compositor_animation_observer.h" |
| 13 #include "ui/compositor/layer_delegate.h" | 14 #include "ui/compositor/layer_delegate.h" |
| 14 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 15 | 16 |
| 16 namespace aura { | 17 namespace aura { |
| 17 class Window; | 18 class Window; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace ui { | 21 namespace ui { |
| 21 class Compositor; | 22 class Compositor; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 45 // the given root window. | 46 // the given root window. |
| 46 void Set(aura::Window* root_window, const gfx::Rect& bounds); | 47 void Set(aura::Window* root_window, const gfx::Rect& bounds); |
| 47 | 48 |
| 48 // Returns true if this layer is in a composited window with an | 49 // Returns true if this layer is in a composited window with an |
| 49 // animation observer. | 50 // animation observer. |
| 50 bool CanAnimate() const; | 51 bool CanAnimate() const; |
| 51 | 52 |
| 52 // Set the layer's opacity. | 53 // Set the layer's opacity. |
| 53 void SetOpacity(float opacity); | 54 void SetOpacity(float opacity); |
| 54 | 55 |
| 56 // Set a custom color, or reset to the default. |
| 57 void SetColor(SkColor color); |
| 58 void ResetColor(); |
| 59 |
| 55 ui::Layer* layer() { return layer_.get(); } | 60 ui::Layer* layer() { return layer_.get(); } |
| 56 aura::Window* root_window() { return root_window_; } | 61 aura::Window* root_window() { return root_window_; } |
| 57 | 62 |
| 58 protected: | 63 protected: |
| 59 // Updates |root_window_| and creates |layer_| if it doesn't exist, | 64 // Updates |root_window_| and creates |layer_| if it doesn't exist, |
| 60 // or if the root window has changed. Moves the layer to the top if | 65 // or if the root window has changed. Moves the layer to the top if |
| 61 // it wasn't there already. | 66 // it wasn't there already. |
| 62 void CreateOrUpdateLayer(aura::Window* root_window, | 67 void CreateOrUpdateLayer(aura::Window* root_window, |
| 63 const char* layer_name, | 68 const char* layer_name, |
| 64 const gfx::Rect& bounds); | 69 const gfx::Rect& bounds); |
| 65 | 70 |
| 71 bool has_custom_color() { return has_custom_color_; } |
| 72 SkColor custom_color() { return custom_color_; } |
| 73 |
| 66 private: | 74 private: |
| 67 // ui::LayerDelegate overrides: | 75 // ui::LayerDelegate overrides: |
| 68 void OnPaintLayer(const ui::PaintContext& context) override; | 76 void OnPaintLayer(const ui::PaintContext& context) override; |
| 69 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; | 77 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; |
| 70 void OnDeviceScaleFactorChanged(float device_scale_factor) override; | 78 void OnDeviceScaleFactorChanged(float device_scale_factor) override; |
| 71 | 79 |
| 72 // CompositorAnimationObserver overrides: | 80 // CompositorAnimationObserver overrides: |
| 73 void OnAnimationStep(base::TimeTicks timestamp) override; | 81 void OnAnimationStep(base::TimeTicks timestamp) override; |
| 74 void OnCompositingShuttingDown(ui::Compositor* compositor) override; | 82 void OnCompositingShuttingDown(ui::Compositor* compositor) override; |
| 75 | 83 |
| 76 // The object that owns this layer. | 84 // The object that owns this layer. |
| 77 FocusRingLayerDelegate* delegate_; | 85 FocusRingLayerDelegate* delegate_; |
| 78 | 86 |
| 79 // The current root window containing the focused object. | 87 // The current root window containing the focused object. |
| 80 aura::Window* root_window_; | 88 aura::Window* root_window_; |
| 81 | 89 |
| 82 // The current layer. | 90 // The current layer. |
| 83 std::unique_ptr<ui::Layer> layer_; | 91 std::unique_ptr<ui::Layer> layer_; |
| 84 | 92 |
| 85 // The bounding rectangle of the focused object, in |root_window_| | 93 // The bounding rectangle of the focused object, in |root_window_| |
| 86 // coordinates. | 94 // coordinates. |
| 87 gfx::Rect focus_ring_; | 95 gfx::Rect focus_ring_; |
| 88 | 96 |
| 97 bool has_custom_color_; |
| 98 SkColor custom_color_; |
| 99 |
| 89 // The compositor associated with this layer. | 100 // The compositor associated with this layer. |
| 90 ui::Compositor* compositor_; | 101 ui::Compositor* compositor_; |
| 91 | 102 |
| 92 DISALLOW_COPY_AND_ASSIGN(FocusRingLayer); | 103 DISALLOW_COPY_AND_ASSIGN(FocusRingLayer); |
| 93 }; | 104 }; |
| 94 | 105 |
| 95 } // namespace chromeos | 106 } // namespace chromeos |
| 96 | 107 |
| 97 #endif // CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_ | 108 #endif // CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_ |
| OLD | NEW |