summaryrefslogtreecommitdiffstats
path: root/ash/focus_cycler.h
blob: d0071d1078889dfce1c01ec3dc5b0cff382966b6 (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
// Copyright (c) 2012 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 FOCUS_CYCLER_H_
#define FOCUS_CYCLER_H_

#include <vector>

#include "ash/ash_export.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"

namespace views {
class Widget;
}  // namespace views

namespace ash {

namespace internal {

// This class handles moving focus between a set of widgets and the main browser
// window.
class ASH_EXPORT FocusCycler {
 public:
  enum Direction {
    FORWARD,
    BACKWARD
  };

  FocusCycler();
  ~FocusCycler();

  // Returns the widget the FocusCycler is attempting to activate or NULL if
  // FocusCycler is not activating any widgets.
  const views::Widget* widget_activating() const { return widget_activating_; }

  // Add a widget to the focus cycle. The widget needs to have an
  // AccessiblePaneView as the content view.
  void AddWidget(views::Widget* widget);

  // Move focus to the next widget.
  void RotateFocus(Direction direction);

  // Moves focus the specified widget. Returns true if the widget was activated.
  bool FocusWidget(views::Widget* widget);

 private:
  std::vector<views::Widget*> widgets_;

  // See description above getter.
  views::Widget* widget_activating_;

  DISALLOW_COPY_AND_ASSIGN(FocusCycler);
};

}  // namespace internal

}  // namespace ash

#endif  // FOCUS_CYCLER_H_