Chromium Code Reviews| Index: ui/views/corewm/cursor_controller.h |
| diff --git a/ui/views/corewm/cursor_controller.h b/ui/views/corewm/cursor_controller.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e5301a8281fd7a99298b8db18815d8516c2ba8e4 |
| --- /dev/null |
| +++ b/ui/views/corewm/cursor_controller.h |
| @@ -0,0 +1,81 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_VIEWS_COREWM_CURSOR_CONTROLLER_H_ |
| +#define UI_VIEWS_COREWM_CURSOR_CONTROLLER_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "ui/aura/client/cursor_client.h" |
| +#include "ui/gfx/native_widget_types.h" |
| +#include "ui/gfx/point.h" |
| +#include "ui/views/views_export.h" |
| + |
| +namespace views { |
| +namespace corewm { |
| + |
| +namespace internal { |
| +class CursorState; |
| +} |
| + |
| +// This class controls the visibility and the type of the cursor. The cursor |
| +// type can be locked so that the type stays the same until it's unlocked. |
| +class VIEWS_EXPORT CursorController : public aura::client::CursorClient { |
| +public: |
|
mazda
2013/02/15 01:40:12
Need one space.
|
| + CursorController(); |
| + virtual ~CursorController(); |
| + |
| + bool is_cursor_locked() const { return cursor_lock_count_ > 0; } |
| + |
| + // Overridden from aura::client::CursorClient: |
| + virtual void SetCursor(gfx::NativeCursor) OVERRIDE; |
| + virtual void ShowCursor() OVERRIDE; |
| + virtual void HideCursor() OVERRIDE; |
| + virtual bool IsCursorVisible() const OVERRIDE; |
| + virtual void EnableMouseEvents() OVERRIDE; |
| + virtual void DisableMouseEvents() OVERRIDE; |
| + virtual bool IsMouseEventsEnabled() const OVERRIDE; |
| + virtual void LockCursor() OVERRIDE; |
| + virtual void UnlockCursor() OVERRIDE; |
| + |
| +protected: |
|
mazda
2013/02/15 01:40:12
Ditto.
|
| + // Returns the current cursor. |
| + gfx::NativeCursor GetCurrentCursor() const; |
| + |
| + // Subclasses of CursorController control the actual assignment of cursors |
| + // through the following template methods. |
| + |
| + // Called to set the current cursor. Subclasses that need to set platform |
| + // state should call the base method from their override after mutating their |
| + // incoming cursor with their platform state. |
| + virtual void SetCursorInternal(gfx::NativeCursor cursor); |
| + |
| + // Called to set the visibility. Subclasses should call the base method first |
| + // and then do platform visibility mutation. |
| + virtual void SetCursorVisibility(bool visible); |
| + |
| + // Called to set whether mouse events are enabled. Subclasses should call the |
| + // base method first and then restore whatever state is necessary on their |
| + // platform. |
| + virtual void SetMouseEventsEnabled(bool enabled); |
| + |
| +private: |
|
mazda
2013/02/15 01:40:12
Ditto.
|
| + // Number of times LockCursor() has been invoked without a corresponding |
| + // UnlockCursor(). |
| + int cursor_lock_count_; |
| + |
| + // The current state of the cursor. |
| + scoped_ptr<internal::CursorState> current_state_; |
| + |
| + // The cursor state to restore when the cursor is unlocked. |
| + scoped_ptr<internal::CursorState> state_on_unlock_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CursorController); |
| +}; |
| + |
| +} // namespace corewm |
| +} // namespace views |
| + |
| +#endif // UI_VIEWS_COREWM_CURSOR_CONTROLLER_H_ |