| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/compositor/layer_delegate.h" | 10 #include "ui/compositor/layer_delegate.h" |
| 11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
| 12 | 12 |
| 13 namespace aura { | 13 namespace aura { |
| 14 class Window; | 14 class Window; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 class Layer; | 18 class Layer; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace views { | |
| 22 class View; | |
| 23 } | |
| 24 | |
| 25 namespace chromeos { | 21 namespace chromeos { |
| 26 | 22 |
| 27 // FocusRingLayer draws a focus ring for a given view. | 23 // A delegate interface implemented by the object that owns a FocusRingLayer. |
| 24 class FocusRingLayerDelegate { |
| 25 public: |
| 26 virtual void OnDeviceScaleFactorChanged() = 0; |
| 27 |
| 28 protected: |
| 29 virtual ~FocusRingLayerDelegate(); |
| 30 }; |
| 31 |
| 32 // FocusRingLayer draws a focus ring at a given global rectangle. |
| 28 class FocusRingLayer : public ui::LayerDelegate { | 33 class FocusRingLayer : public ui::LayerDelegate { |
| 29 public: | 34 public: |
| 30 FocusRingLayer(); | 35 explicit FocusRingLayer(FocusRingLayerDelegate* delegate); |
| 31 virtual ~FocusRingLayer(); | 36 virtual ~FocusRingLayer(); |
| 32 | 37 |
| 33 // Create the layer and update its bounds and position in the hierarchy. | 38 // Move the focus ring layer to the given bounds in the coordinates of |
| 34 void Update(); | 39 // the given root window. |
| 35 | 40 void Set(aura::Window* root_window, const gfx::Rect& bounds); |
| 36 // Updates the focus ring layer for the view or clears it if |view| is NULL. | |
| 37 void SetForView(views::View* view); | |
| 38 | 41 |
| 39 private: | 42 private: |
| 40 // ui::LayerDelegate overrides: | 43 // ui::LayerDelegate overrides: |
| 41 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; | 44 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; |
| 42 virtual void OnDelegatedFrameDamage( | 45 virtual void OnDelegatedFrameDamage( |
| 43 const gfx::Rect& damage_rect_in_dip) OVERRIDE; | 46 const gfx::Rect& damage_rect_in_dip) OVERRIDE; |
| 44 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; | 47 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; |
| 45 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE; | 48 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE; |
| 46 | 49 |
| 47 // The window containing focus. | 50 // The object that owns this layer. |
| 48 aura::Window* window_; | 51 FocusRingLayerDelegate* delegate_; |
| 49 | 52 |
| 50 // The current root window containing the focused object. | 53 // The current root window containing the focused object. |
| 51 aura::Window* root_window_; | 54 aura::Window* root_window_; |
| 52 | 55 |
| 53 // The bounding rectangle of the focused object, in |window_| coordinates. | 56 // The bounding rectangle of the focused object, in |root_window_| |
| 57 // coordinates. |
| 54 gfx::Rect focus_ring_; | 58 gfx::Rect focus_ring_; |
| 55 | 59 |
| 56 // The current layer. | 60 // The current layer. |
| 57 scoped_ptr<ui::Layer> layer_; | 61 scoped_ptr<ui::Layer> layer_; |
| 58 | 62 |
| 59 DISALLOW_COPY_AND_ASSIGN(FocusRingLayer); | 63 DISALLOW_COPY_AND_ASSIGN(FocusRingLayer); |
| 60 }; | 64 }; |
| 61 | 65 |
| 62 } // namespace chromeos | 66 } // namespace chromeos |
| 63 | 67 |
| 64 #endif // CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_ | 68 #endif // CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_ |
| OLD | NEW |