Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: ui/wm/core/cursor_manager.cc

Issue 2949353003: Implement large cursors in Mushrome. (Closed)
Patch Set: rename everything to CursorSize Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/wm/core/cursor_manager.h ('k') | ui/wm/core/cursor_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 #include "ui/wm/core/cursor_manager.h" 5 #include "ui/wm/core/cursor_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "ui/aura/client/cursor_client_observer.h" 11 #include "ui/aura/client/cursor_client_observer.h"
12 #include "ui/wm/core/native_cursor_manager.h" 12 #include "ui/wm/core/native_cursor_manager.h"
13 #include "ui/wm/core/native_cursor_manager_delegate.h" 13 #include "ui/wm/core/native_cursor_manager_delegate.h"
14 14
15 namespace wm { 15 namespace wm {
16 16
17 namespace internal { 17 namespace internal {
18 18
19 // Represents the cursor state which is composed of cursor type, visibility, and 19 // Represents the cursor state which is composed of cursor type, visibility, and
20 // mouse events enable state. When mouse events are disabled, the cursor is 20 // mouse events enable state. When mouse events are disabled, the cursor is
21 // always invisible. 21 // always invisible.
22 class CursorState { 22 class CursorState {
23 public: 23 public:
24 CursorState() 24 CursorState()
25 : cursor_(ui::CursorType::kNone), 25 : cursor_(ui::CursorType::kNone),
26 visible_(true), 26 visible_(true),
27 cursor_set_(ui::CURSOR_SET_NORMAL), 27 cursor_size_(ui::CursorSize::kNormal),
28 mouse_events_enabled_(true), 28 mouse_events_enabled_(true),
29 visible_on_mouse_events_enabled_(true) {} 29 visible_on_mouse_events_enabled_(true) {}
30 30
31 gfx::NativeCursor cursor() const { return cursor_; } 31 gfx::NativeCursor cursor() const { return cursor_; }
32 void set_cursor(gfx::NativeCursor cursor) { cursor_ = cursor; } 32 void set_cursor(gfx::NativeCursor cursor) { cursor_ = cursor; }
33 33
34 bool visible() const { return visible_; } 34 bool visible() const { return visible_; }
35 void SetVisible(bool visible) { 35 void SetVisible(bool visible) {
36 if (mouse_events_enabled_) 36 if (mouse_events_enabled_)
37 visible_ = visible; 37 visible_ = visible;
38 // Ignores the call when mouse events disabled. 38 // Ignores the call when mouse events disabled.
39 } 39 }
40 40
41 ui::CursorSetType cursor_set() const { return cursor_set_; } 41 ui::CursorSize cursor_size() const { return cursor_size_; }
42 void set_cursor_set(ui::CursorSetType cursor_set) { 42 void set_cursor_size(ui::CursorSize cursor_size) {
43 cursor_set_ = cursor_set; 43 cursor_size_ = cursor_size;
44 } 44 }
45 45
46 bool mouse_events_enabled() const { return mouse_events_enabled_; } 46 bool mouse_events_enabled() const { return mouse_events_enabled_; }
47 void SetMouseEventsEnabled(bool enabled) { 47 void SetMouseEventsEnabled(bool enabled) {
48 if (mouse_events_enabled_ == enabled) 48 if (mouse_events_enabled_ == enabled)
49 return; 49 return;
50 mouse_events_enabled_ = enabled; 50 mouse_events_enabled_ = enabled;
51 51
52 // Restores the visibility when mouse events are enabled. 52 // Restores the visibility when mouse events are enabled.
53 if (enabled) { 53 if (enabled) {
54 visible_ = visible_on_mouse_events_enabled_; 54 visible_ = visible_on_mouse_events_enabled_;
55 } else { 55 } else {
56 visible_on_mouse_events_enabled_ = visible_; 56 visible_on_mouse_events_enabled_ = visible_;
57 visible_ = false; 57 visible_ = false;
58 } 58 }
59 } 59 }
60 60
61 private: 61 private:
62 gfx::NativeCursor cursor_; 62 gfx::NativeCursor cursor_;
63 bool visible_; 63 bool visible_;
64 ui::CursorSetType cursor_set_; 64 ui::CursorSize cursor_size_;
65 bool mouse_events_enabled_; 65 bool mouse_events_enabled_;
66 66
67 // The visibility to set when mouse events are enabled. 67 // The visibility to set when mouse events are enabled.
68 bool visible_on_mouse_events_enabled_; 68 bool visible_on_mouse_events_enabled_;
69 69
70 DISALLOW_COPY_AND_ASSIGN(CursorState); 70 DISALLOW_COPY_AND_ASSIGN(CursorState);
71 }; 71 };
72 72
73 } // namespace internal 73 } // namespace internal
74 74
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 delegate_->SetVisibility(state_on_unlock_->visible(), this); 122 delegate_->SetVisibility(state_on_unlock_->visible(), this);
123 for (auto& observer : observers_) 123 for (auto& observer : observers_)
124 observer.OnCursorVisibilityChanged(false); 124 observer.OnCursorVisibilityChanged(false);
125 } 125 }
126 } 126 }
127 127
128 bool CursorManager::IsCursorVisible() const { 128 bool CursorManager::IsCursorVisible() const {
129 return current_state_->visible(); 129 return current_state_->visible();
130 } 130 }
131 131
132 void CursorManager::SetCursorSet(ui::CursorSetType cursor_set) { 132 void CursorManager::SetCursorSize(ui::CursorSize cursor_size) {
133 state_on_unlock_->set_cursor_set(cursor_set); 133 state_on_unlock_->set_cursor_size(cursor_size);
134 if (GetCursorSet() != state_on_unlock_->cursor_set()) { 134 if (GetCursorSize() != state_on_unlock_->cursor_size()) {
135 delegate_->SetCursorSet(state_on_unlock_->cursor_set(), this); 135 delegate_->SetCursorSize(state_on_unlock_->cursor_size(), this);
136 for (auto& observer : observers_) 136 for (auto& observer : observers_)
137 observer.OnCursorSetChanged(cursor_set); 137 observer.OnCursorSizeChanged(cursor_size);
138 } 138 }
139 } 139 }
140 140
141 ui::CursorSetType CursorManager::GetCursorSet() const { 141 ui::CursorSize CursorManager::GetCursorSize() const {
142 return current_state_->cursor_set(); 142 return current_state_->cursor_size();
143 } 143 }
144 144
145 void CursorManager::EnableMouseEvents() { 145 void CursorManager::EnableMouseEvents() {
146 state_on_unlock_->SetMouseEventsEnabled(true); 146 state_on_unlock_->SetMouseEventsEnabled(true);
147 if (cursor_lock_count_ == 0 && 147 if (cursor_lock_count_ == 0 &&
148 IsMouseEventsEnabled() != state_on_unlock_->mouse_events_enabled()) { 148 IsMouseEventsEnabled() != state_on_unlock_->mouse_events_enabled()) {
149 delegate_->SetMouseEventsEnabled(state_on_unlock_->mouse_events_enabled(), 149 delegate_->SetMouseEventsEnabled(state_on_unlock_->mouse_events_enabled(),
150 this); 150 this);
151 } 151 }
152 } 152 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 224
225 void CursorManager::CommitVisibility(bool visible) { 225 void CursorManager::CommitVisibility(bool visible) {
226 // TODO(tdanderson): Find a better place for this so we don't 226 // TODO(tdanderson): Find a better place for this so we don't
227 // notify the observers more than is necessary. 227 // notify the observers more than is necessary.
228 for (auto& observer : observers_) 228 for (auto& observer : observers_)
229 observer.OnCursorVisibilityChanged(visible); 229 observer.OnCursorVisibilityChanged(visible);
230 current_state_->SetVisible(visible); 230 current_state_->SetVisible(visible);
231 } 231 }
232 232
233 void CursorManager::CommitCursorSet(ui::CursorSetType cursor_set) { 233 void CursorManager::CommitCursorSize(ui::CursorSize cursor_size) {
234 current_state_->set_cursor_set(cursor_set); 234 current_state_->set_cursor_size(cursor_size);
235 } 235 }
236 236
237 void CursorManager::CommitMouseEventsEnabled(bool enabled) { 237 void CursorManager::CommitMouseEventsEnabled(bool enabled) {
238 current_state_->SetMouseEventsEnabled(enabled); 238 current_state_->SetMouseEventsEnabled(enabled);
239 } 239 }
240 240
241 } // namespace wm 241 } // namespace wm
OLDNEW
« no previous file with comments | « ui/wm/core/cursor_manager.h ('k') | ui/wm/core/cursor_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698