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 ASH_WM_CURSOR_MANAGER_H_ | 5 #ifndef ASH_WM_CURSOR_MANAGER_H_ |
6 #define ASH_WM_CURSOR_MANAGER_H_ | 6 #define ASH_WM_CURSOR_MANAGER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "ui/aura/client/cursor_client.h" | 12 #include "ui/aura/client/cursor_client.h" |
13 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
| 14 #include "ui/gfx/point.h" |
14 | 15 |
15 namespace ash { | 16 namespace ash { |
16 | 17 |
| 18 namespace internal { |
| 19 class CursorState; |
| 20 } |
| 21 |
17 namespace test { | 22 namespace test { |
18 class CursorManagerTestApi; | 23 class CursorManagerTestApi; |
19 } | 24 } |
20 | 25 |
21 class ImageCursors; | 26 class ImageCursors; |
22 | 27 |
23 // This class controls the visibility and the type of the cursor. | 28 // This class controls the visibility and the type of the cursor. |
24 // The cursor type can be locked so that the type stays the same | 29 // The cursor type can be locked so that the type stays the same |
25 // until it's unlocked. | 30 // until it's unlocked. |
26 class ASH_EXPORT CursorManager : public aura::client::CursorClient { | 31 class ASH_EXPORT CursorManager : public aura::client::CursorClient { |
27 public: | 32 public: |
28 CursorManager(); | 33 CursorManager(); |
29 virtual ~CursorManager(); | 34 virtual ~CursorManager(); |
30 | 35 |
31 bool is_cursor_locked() const { return cursor_lock_count_ > 0; } | 36 bool is_cursor_locked() const { return cursor_lock_count_ > 0; } |
32 | 37 |
33 // Overridden from aura::client::CursorClient: | 38 // Overridden from aura::client::CursorClient: |
34 virtual void SetCursor(gfx::NativeCursor) OVERRIDE; | 39 virtual void SetCursor(gfx::NativeCursor) OVERRIDE; |
35 virtual void ShowCursor(bool show) OVERRIDE; | 40 virtual void ShowCursor(bool show) OVERRIDE; |
36 virtual bool IsCursorVisible() const OVERRIDE; | 41 virtual bool IsCursorVisible() const OVERRIDE; |
| 42 virtual void EnableCursor(bool enabled) OVERRIDE; |
| 43 virtual bool IsCursorEnabled() const OVERRIDE; |
37 virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE; | 44 virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE; |
38 virtual void LockCursor() OVERRIDE; | 45 virtual void LockCursor() OVERRIDE; |
39 virtual void UnlockCursor() OVERRIDE; | 46 virtual void UnlockCursor() OVERRIDE; |
40 | 47 |
41 private: | 48 private: |
42 friend class test::CursorManagerTestApi; | 49 friend class test::CursorManagerTestApi; |
43 | 50 |
44 void SetCursorInternal(gfx::NativeCursor cursor); | 51 void SetCursorInternal(gfx::NativeCursor cursor); |
45 void ShowCursorInternal(bool show); | 52 void ShowCursorInternal(bool show); |
| 53 void EnableCursorInternal(bool enabled); |
| 54 |
| 55 // Returns the current cursor. |
| 56 gfx::NativeCursor GetCurrentCursor() const; |
46 | 57 |
47 // Number of times LockCursor() has been invoked without a corresponding | 58 // Number of times LockCursor() has been invoked without a corresponding |
48 // UnlockCursor(). | 59 // UnlockCursor(). |
49 int cursor_lock_count_; | 60 int cursor_lock_count_; |
50 | 61 |
51 // Set to true if SetCursor() is invoked while |cursor_lock_count_| == 0. | 62 // The cursor location where the cursor was disabled. |
52 bool did_cursor_change_; | 63 gfx::Point disabled_cursor_location_; |
53 | 64 |
54 // Cursor to set once |cursor_lock_count_| is set to 0. Only valid if | 65 // The current state of the cursor. |
55 // |did_cursor_change_| is true. | 66 scoped_ptr<internal::CursorState> current_state_; |
56 gfx::NativeCursor cursor_to_set_on_unlock_; | |
57 | 67 |
58 // Set to true if ShowCursor() is invoked while |cursor_lock_count_| == 0. | 68 // The cursor state to restore when the cursor is unlocked. |
59 bool did_visibility_change_; | 69 scoped_ptr<internal::CursorState> state_on_unlock_; |
60 | |
61 // The visibility to set once |cursor_lock_count_| is set to 0. Only valid if | |
62 // |did_visibility_change_| is true. | |
63 bool show_on_unlock_; | |
64 | |
65 // Is cursor visible? | |
66 bool cursor_visible_; | |
67 | |
68 // The cursor currently set. | |
69 gfx::NativeCursor current_cursor_; | |
70 | 70 |
71 scoped_ptr<ImageCursors> image_cursors_; | 71 scoped_ptr<ImageCursors> image_cursors_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(CursorManager); | 73 DISALLOW_COPY_AND_ASSIGN(CursorManager); |
74 }; | 74 }; |
75 | 75 |
76 } // namespace ash | 76 } // namespace ash |
77 | 77 |
78 #endif // UI_AURA_CURSOR_MANAGER_H_ | 78 #endif // UI_AURA_CURSOR_MANAGER_H_ |
OLD | NEW |