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