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