summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/ui/focus_ring_layer.h
blob: ba83535bd51c14a429a7b1799317025ac73d972c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_
#define CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_

#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/compositor/layer_delegate.h"
#include "ui/gfx/rect.h"

namespace aura {
class Window;
}

namespace ui {
class Layer;
}

namespace views {
class View;
}

namespace chromeos {

// FocusRingLayer draws a focus ring for a given view.
class FocusRingLayer : public ui::LayerDelegate {
 public:
  FocusRingLayer();
  virtual ~FocusRingLayer();

  // Create the layer and update its bounds and position in the hierarchy.
  void Update();

  // Updates the focus ring layer for the view or clears it if |view| is NULL.
  void SetForView(views::View* view);

 private:
  // ui::LayerDelegate overrides:
  virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE;
  virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
  virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE;

  // The window containing focus.
  aura::Window* window_;

  // The current root window containing the focused object.
  aura::Window* root_window_;

  // The bounding rectangle of the focused object, in |window_| coordinates.
  gfx::Rect focus_ring_;

  // The current layer.
  scoped_ptr<ui::Layer> layer_;

  DISALLOW_COPY_AND_ASSIGN(FocusRingLayer);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_