Chromium Code Reviews| 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 | 14 |
| 15 namespace ash { | 15 namespace ash { |
| 16 | 16 |
| 17 namespace test { | 17 namespace test { |
| 18 class CursorManagerTestApi; | 18 class CursorManagerTestApi; |
| 19 } | 19 } |
| 20 | 20 |
| 21 class CursorDelegate; | |
| 22 class ImageCursors; | 21 class ImageCursors; |
| 23 | 22 |
| 24 // This class controls the visibility and the type of the cursor. | 23 // This class controls the visibility and the type of the cursor. |
| 25 // The cursor type can be locked so that the type stays the same | 24 // The cursor type can be locked so that the type stays the same |
| 26 // until it's unlocked. | 25 // until it's unlocked. |
| 27 class ASH_EXPORT CursorManager : public aura::client::CursorClient { | 26 class ASH_EXPORT CursorManager : public aura::client::CursorClient { |
| 28 public: | 27 public: |
| 29 CursorManager(); | 28 CursorManager(); |
| 30 virtual ~CursorManager(); | 29 virtual ~CursorManager(); |
| 31 | 30 |
| 32 void set_delegate(CursorDelegate* delegate) { delegate_ = delegate; } | |
| 33 | |
| 34 // Locks/Unlocks the cursor change. | 31 // Locks/Unlocks the cursor change. |
| 35 void LockCursor(); | 32 void LockCursor(); |
| 36 void UnlockCursor(); | 33 void UnlockCursor(); |
|
oshima
2012/10/09 23:08:38
Can you define these API in CursorClient? RWHVA ne
mazda
2012/10/10 00:59:12
Done.
I'd like to add the implementations other th
| |
| 37 | 34 |
| 38 bool is_cursor_locked() const { return cursor_lock_count_ > 0; } | 35 bool is_cursor_locked() const { return cursor_lock_count_ > 0; } |
| 39 | 36 |
| 40 // Shows or hides the cursor. | 37 // Shows or hides the cursor. |
| 41 bool cursor_visible() const { return cursor_visible_; } | 38 bool cursor_visible() const { return cursor_visible_; } |
| 42 | 39 |
| 43 // Overridden from aura::client::CursorClient: | 40 // Overridden from aura::client::CursorClient: |
| 44 virtual void SetCursor(gfx::NativeCursor) OVERRIDE; | 41 virtual void SetCursor(gfx::NativeCursor) OVERRIDE; |
| 45 virtual void ShowCursor(bool show) OVERRIDE; | 42 virtual void ShowCursor(bool show) OVERRIDE; |
| 46 virtual bool IsCursorVisible() const OVERRIDE; | 43 virtual bool IsCursorVisible() const OVERRIDE; |
| 47 virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE; | 44 virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE; |
| 48 | 45 |
| 49 private: | 46 private: |
| 50 friend class test::CursorManagerTestApi; | 47 friend class test::CursorManagerTestApi; |
| 51 | 48 |
| 52 void SetCursorInternal(gfx::NativeCursor cursor); | 49 void SetCursorInternal(gfx::NativeCursor cursor); |
| 53 | 50 void ShowCursorInternal(bool show); |
| 54 CursorDelegate* delegate_; | |
| 55 | 51 |
| 56 // Number of times LockCursor() has been invoked without a corresponding | 52 // Number of times LockCursor() has been invoked without a corresponding |
| 57 // UnlockCursor(). | 53 // UnlockCursor(). |
| 58 int cursor_lock_count_; | 54 int cursor_lock_count_; |
| 59 | 55 |
| 60 // Set to true if UpdateCursor() is invoked while |cursor_lock_count_| == 0. | 56 // Set to true if SetCursor() is invoked while |cursor_lock_count_| == 0. |
| 61 bool did_cursor_change_; | 57 bool did_cursor_change_; |
| 62 | 58 |
| 63 // Cursor to set once |cursor_lock_count_| is set to 0. Only valid if | 59 // Cursor to set once |cursor_lock_count_| is set to 0. Only valid if |
| 64 // |did_cursor_change_| is true. | 60 // |did_cursor_change_| is true. |
| 65 gfx::NativeCursor cursor_to_set_on_unlock_; | 61 gfx::NativeCursor cursor_to_set_on_unlock_; |
| 66 | 62 |
| 63 // Set to true if ShowCursor() is invoked while |cursor_lock_count_| == 0. | |
| 64 bool did_visibility_change_; | |
| 65 | |
| 66 // The visibility to set once |cursor_lock_count_| is set to 0. Only valid if | |
| 67 // |did_visibility_change_| is true. | |
| 68 bool show_on_unlock_; | |
| 69 | |
| 67 // Is cursor visible? | 70 // Is cursor visible? |
| 68 bool cursor_visible_; | 71 bool cursor_visible_; |
| 69 | 72 |
| 70 // The cursor currently set. | 73 // The cursor currently set. |
| 71 gfx::NativeCursor current_cursor_; | 74 gfx::NativeCursor current_cursor_; |
| 72 | 75 |
| 73 scoped_ptr<ImageCursors> image_cursors_; | 76 scoped_ptr<ImageCursors> image_cursors_; |
| 74 | 77 |
| 75 DISALLOW_COPY_AND_ASSIGN(CursorManager); | 78 DISALLOW_COPY_AND_ASSIGN(CursorManager); |
| 76 }; | 79 }; |
| 77 | 80 |
| 78 } // namespace ash | 81 } // namespace ash |
| 79 | 82 |
| 80 #endif // UI_AURA_CURSOR_MANAGER_H_ | 83 #endif // UI_AURA_CURSOR_MANAGER_H_ |
| OLD | NEW |