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" | |
13 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
14 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
| 14 #include "ui/views/corewm/cursor_controller.h" |
15 | 15 |
16 namespace ash { | 16 namespace ash { |
17 | 17 |
18 namespace internal { | |
19 class CursorState; | |
20 } | |
21 | |
22 namespace test { | 18 namespace test { |
23 class CursorManagerTestApi; | 19 class CursorManagerTestApi; |
24 } | 20 } |
25 | 21 |
26 class ImageCursors; | 22 class ImageCursors; |
27 | 23 |
28 // This class controls the visibility and the type of the cursor. | 24 // This class controls the visibility and the type of the cursor. |
29 // The cursor type can be locked so that the type stays the same | 25 // The cursor type can be locked so that the type stays the same |
30 // until it's unlocked. | 26 // until it's unlocked. |
31 class ASH_EXPORT CursorManager : public aura::client::CursorClient { | 27 class ASH_EXPORT CursorManager : public views::corewm::CursorController { |
32 public: | 28 public: |
33 CursorManager(); | 29 CursorManager(); |
34 virtual ~CursorManager(); | 30 virtual ~CursorManager(); |
35 | 31 |
36 bool is_cursor_locked() const { return cursor_lock_count_ > 0; } | 32 // Overridden from aura::client::CursorClient |
37 | |
38 // Overridden from aura::client::CursorClient: | |
39 virtual void SetCursor(gfx::NativeCursor) OVERRIDE; | |
40 virtual void ShowCursor() OVERRIDE; | |
41 virtual void HideCursor() OVERRIDE; | |
42 virtual bool IsCursorVisible() const OVERRIDE; | |
43 virtual void EnableMouseEvents() OVERRIDE; | |
44 virtual void DisableMouseEvents() OVERRIDE; | |
45 virtual bool IsMouseEventsEnabled() const OVERRIDE; | |
46 virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE; | 33 virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE; |
47 virtual void LockCursor() OVERRIDE; | |
48 virtual void UnlockCursor() OVERRIDE; | |
49 | 34 |
50 private: | 35 private: |
51 friend class test::CursorManagerTestApi; | 36 friend class test::CursorManagerTestApi; |
52 | 37 |
53 void SetCursorInternal(gfx::NativeCursor cursor); | 38 // Overridden from views::corewm::CursorController: |
54 void SetCursorVisibility(bool visible); | 39 virtual void SetCursorInternal(gfx::NativeCursor cursor) OVERRIDE; |
55 void SetMouseEventsEnabled(bool enabled); | 40 virtual void SetCursorVisibility(bool visible) OVERRIDE; |
56 | 41 virtual void SetMouseEventsEnabled(bool enabled) OVERRIDE; |
57 // Returns the current cursor. | |
58 gfx::NativeCursor GetCurrentCursor() const; | |
59 | |
60 // Number of times LockCursor() has been invoked without a corresponding | |
61 // UnlockCursor(). | |
62 int cursor_lock_count_; | |
63 | 42 |
64 // The cursor location where the cursor was disabled. | 43 // The cursor location where the cursor was disabled. |
65 gfx::Point disabled_cursor_location_; | 44 gfx::Point disabled_cursor_location_; |
66 | 45 |
67 // The current state of the cursor. | |
68 scoped_ptr<internal::CursorState> current_state_; | |
69 | |
70 // The cursor state to restore when the cursor is unlocked. | |
71 scoped_ptr<internal::CursorState> state_on_unlock_; | |
72 | |
73 scoped_ptr<ImageCursors> image_cursors_; | 46 scoped_ptr<ImageCursors> image_cursors_; |
74 | 47 |
75 DISALLOW_COPY_AND_ASSIGN(CursorManager); | 48 DISALLOW_COPY_AND_ASSIGN(CursorManager); |
76 }; | 49 }; |
77 | 50 |
78 } // namespace ash | 51 } // namespace ash |
79 | 52 |
80 #endif // UI_AURA_CURSOR_MANAGER_H_ | 53 #endif // UI_AURA_CURSOR_MANAGER_H_ |
OLD | NEW |