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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_CONTROLLER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ui/views/focus/focus_manager.h"
11 #include "ui/views/focus/widget_focus_manager.h"
12 #include "ui/views/widget/widget_observer.h"
23 // FocusRingController manages the focus ring around the focused view. It
24 // follows widget focus change and update the focus ring layer when the focused
25 // view of the widget changes.
26 class FocusRingController
: public views::WidgetObserver
,
27 public views::WidgetFocusChangeListener
,
28 public views::FocusChangeListener
{
30 FocusRingController();
31 virtual ~FocusRingController();
33 // Turns on/off the focus ring.
34 void SetVisible(bool visible
);
37 // Sets the focused |widget|.
38 void SetWidget(views::Widget
* widget
);
40 // Updates the focus ring to the focused view of |widget_|. If |widget_| is
41 // NULL or has no focused view, removes the focus ring. Otherwise, draws it.
42 void UpdateFocusRing();
44 // views::WidgetObserver overrides:
45 virtual void OnWidgetDestroying(views::Widget
* widget
) OVERRIDE
;
46 virtual void OnWidgetBoundsChanged(views::Widget
* widget
,
47 const gfx::Rect
& new_bounds
) OVERRIDE
;
49 // views::WidgetFocusChangeListener overrides:
50 virtual void OnNativeFocusChange(gfx::NativeView focused_before
,
51 gfx::NativeView focused_now
) OVERRIDE
;
53 // views::FocusChangeListener overrides:
54 virtual void OnWillChangeFocus(views::View
* focused_before
,
55 views::View
* focused_now
) OVERRIDE
;
56 virtual void OnDidChangeFocus(views::View
* focused_before
,
57 views::View
* focused_now
) OVERRIDE
;
61 views::Widget
* widget_
;
62 scoped_ptr
<FocusRingLayer
> focus_ring_layer_
;
64 DISALLOW_COPY_AND_ASSIGN(FocusRingController
);
67 } // namespace chromeos
69 #endif // CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_CONTROLLER_H_