Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_VIEWS_COREWM_CURSOR_CONTROLLER_H_ | |
| 6 #define UI_VIEWS_COREWM_CURSOR_CONTROLLER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "ui/aura/client/cursor_client.h" | |
| 12 #include "ui/gfx/native_widget_types.h" | |
| 13 #include "ui/gfx/point.h" | |
| 14 #include "ui/views/views_export.h" | |
| 15 | |
| 16 namespace views { | |
| 17 namespace corewm { | |
| 18 | |
| 19 namespace internal { | |
| 20 class CursorState; | |
| 21 } | |
| 22 | |
| 23 // This class controls the visibility and the type of the cursor. The cursor | |
| 24 // type can be locked so that the type stays the same until it's unlocked. | |
| 25 class VIEWS_EXPORT CursorController : public aura::client::CursorClient { | |
| 26 public: | |
|
mazda
2013/02/15 01:40:12
Need one space.
| |
| 27 CursorController(); | |
| 28 virtual ~CursorController(); | |
| 29 | |
| 30 bool is_cursor_locked() const { return cursor_lock_count_ > 0; } | |
| 31 | |
| 32 // Overridden from aura::client::CursorClient: | |
| 33 virtual void SetCursor(gfx::NativeCursor) OVERRIDE; | |
| 34 virtual void ShowCursor() OVERRIDE; | |
| 35 virtual void HideCursor() OVERRIDE; | |
| 36 virtual bool IsCursorVisible() const OVERRIDE; | |
| 37 virtual void EnableMouseEvents() OVERRIDE; | |
| 38 virtual void DisableMouseEvents() OVERRIDE; | |
| 39 virtual bool IsMouseEventsEnabled() const OVERRIDE; | |
| 40 virtual void LockCursor() OVERRIDE; | |
| 41 virtual void UnlockCursor() OVERRIDE; | |
| 42 | |
| 43 protected: | |
|
mazda
2013/02/15 01:40:12
Ditto.
| |
| 44 // Returns the current cursor. | |
| 45 gfx::NativeCursor GetCurrentCursor() const; | |
| 46 | |
| 47 // Subclasses of CursorController control the actual assignment of cursors | |
| 48 // through the following template methods. | |
| 49 | |
| 50 // Called to set the current cursor. Subclasses that need to set platform | |
| 51 // state should call the base method from their override after mutating their | |
| 52 // incoming cursor with their platform state. | |
| 53 virtual void SetCursorInternal(gfx::NativeCursor cursor); | |
| 54 | |
| 55 // Called to set the visibility. Subclasses should call the base method first | |
| 56 // and then do platform visibility mutation. | |
| 57 virtual void SetCursorVisibility(bool visible); | |
| 58 | |
| 59 // Called to set whether mouse events are enabled. Subclasses should call the | |
| 60 // base method first and then restore whatever state is necessary on their | |
| 61 // platform. | |
| 62 virtual void SetMouseEventsEnabled(bool enabled); | |
| 63 | |
| 64 private: | |
|
mazda
2013/02/15 01:40:12
Ditto.
| |
| 65 // Number of times LockCursor() has been invoked without a corresponding | |
| 66 // UnlockCursor(). | |
| 67 int cursor_lock_count_; | |
| 68 | |
| 69 // The current state of the cursor. | |
| 70 scoped_ptr<internal::CursorState> current_state_; | |
| 71 | |
| 72 // The cursor state to restore when the cursor is unlocked. | |
| 73 scoped_ptr<internal::CursorState> state_on_unlock_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(CursorController); | |
| 76 }; | |
| 77 | |
| 78 } // namespace corewm | |
| 79 } // namespace views | |
| 80 | |
| 81 #endif // UI_VIEWS_COREWM_CURSOR_CONTROLLER_H_ | |
| OLD | NEW |