OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_AURA_CURSOR_MANAGER_H_ | 5 #ifndef ASH_WM_CURSOR_MANAGER_H_ |
6 #define UI_AURA_CURSOR_MANAGER_H_ | 6 #define ASH_WM_CURSOR_MANAGER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
9 #include "ui/aura/aura_export.h" | 10 #include "ui/aura/aura_export.h" |
| 11 #include "ui/aura/client/cursor_client.h" |
10 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
11 | 13 |
12 namespace aura { | 14 namespace ash { |
13 class CursorDelegate; | 15 class CursorDelegate; |
14 | 16 |
15 // This class controls the visibility and the type of the cursor. | 17 // This class controls the visibility and the type of the cursor. |
16 // The cursor type can be locked so that the type stays the same | 18 // The cursor type can be locked so that the type stays the same |
17 // until it's unlocked. | 19 // until it's unlocked. |
18 class AURA_EXPORT CursorManager { | 20 class CursorManager : public aura::client::CursorClient { |
19 public: | 21 public: |
20 CursorManager(); | 22 CursorManager(); |
21 ~CursorManager(); | 23 ~CursorManager(); |
22 | 24 |
23 void set_delegate(CursorDelegate* delegate) { delegate_ = delegate; } | 25 void set_delegate(CursorDelegate* delegate) { delegate_ = delegate; } |
24 | 26 |
25 // Locks/Unlocks the cursor change. | 27 // Locks/Unlocks the cursor change. |
26 void LockCursor(); | 28 void LockCursor(); |
27 void UnlockCursor(); | 29 void UnlockCursor(); |
28 | 30 |
29 bool is_cursor_locked() const { return cursor_lock_count_ > 0; } | 31 bool is_cursor_locked() const { return cursor_lock_count_ > 0; } |
30 | 32 |
31 void SetCursor(gfx::NativeCursor); | 33 // Shows or hides the cursor. |
| 34 bool cursor_visible() const { return cursor_visible_; } |
32 | 35 |
33 // Shows or hides the cursor. | 36 virtual void SetCursor(gfx::NativeCursor) OVERRIDE; |
34 void ShowCursor(bool show); | 37 virtual void ShowCursor(bool show) OVERRIDE; |
35 bool cursor_visible() const { return cursor_visible_; } | 38 virtual bool IsCursorVisible() const OVERRIDE; |
36 | 39 |
37 private: | 40 private: |
38 CursorDelegate* delegate_; | 41 CursorDelegate* delegate_; |
39 | 42 |
40 // Number of times LockCursor() has been invoked without a corresponding | 43 // Number of times LockCursor() has been invoked without a corresponding |
41 // UnlockCursor(). | 44 // UnlockCursor(). |
42 int cursor_lock_count_; | 45 int cursor_lock_count_; |
43 | 46 |
44 // Set to true if UpdateCursor() is invoked while |cursor_lock_count_| == 0. | 47 // Set to true if UpdateCursor() is invoked while |cursor_lock_count_| == 0. |
45 bool did_cursor_change_; | 48 bool did_cursor_change_; |
46 | 49 |
47 // Cursor to set once |cursor_lock_count_| is set to 0. Only valid if | 50 // Cursor to set once |cursor_lock_count_| is set to 0. Only valid if |
48 // |did_cursor_change_| is true. | 51 // |did_cursor_change_| is true. |
49 gfx::NativeCursor cursor_to_set_on_unlock_; | 52 gfx::NativeCursor cursor_to_set_on_unlock_; |
50 | 53 |
51 // Is cursor visible? | 54 // Is cursor visible? |
52 bool cursor_visible_; | 55 bool cursor_visible_; |
53 | 56 |
54 DISALLOW_COPY_AND_ASSIGN(CursorManager); | 57 DISALLOW_COPY_AND_ASSIGN(CursorManager); |
55 }; | 58 }; |
56 | 59 |
57 } // namespace aura | 60 } // namespace aura |
58 | 61 |
59 #endif // UI_AURA_CURSOR_MANAGER_H_ | 62 #endif // UI_AURA_CURSOR_MANAGER_H_ |
OLD | NEW |