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