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

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

Issue 233053003: Remove obsolete scale related APIs for cursor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix wm_core_unittests Created 6 years, 8 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 | Annotate | Revision Log
« 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 "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/aura/client/cursor_client_observer.h" 8 #include "ui/aura/client/cursor_client_observer.h"
9 #include "ui/wm/core/native_cursor_manager.h" 9 #include "ui/wm/core/native_cursor_manager.h"
10 #include "ui/wm/core/native_cursor_manager_delegate.h" 10 #include "ui/wm/core/native_cursor_manager_delegate.h"
11 11
12 namespace wm { 12 namespace wm {
13 13
14 namespace internal { 14 namespace internal {
15 15
16 // Represents the cursor state which is composed of cursor type, visibility, and 16 // Represents the cursor state which is composed of cursor type, visibility, and
17 // mouse events enable state. When mouse events are disabled, the cursor is 17 // mouse events enable state. When mouse events are disabled, the cursor is
18 // always invisible. 18 // always invisible.
19 class CursorState { 19 class CursorState {
20 public: 20 public:
21 CursorState() 21 CursorState()
22 : cursor_(ui::kCursorNone), 22 : cursor_(ui::kCursorNone),
23 visible_(true), 23 visible_(true),
24 scale_(1.f),
25 cursor_set_(ui::CURSOR_SET_NORMAL), 24 cursor_set_(ui::CURSOR_SET_NORMAL),
26 mouse_events_enabled_(true), 25 mouse_events_enabled_(true),
27 visible_on_mouse_events_enabled_(true) { 26 visible_on_mouse_events_enabled_(true) {
28 } 27 }
29 28
30 gfx::NativeCursor cursor() const { return cursor_; } 29 gfx::NativeCursor cursor() const { return cursor_; }
31 void set_cursor(gfx::NativeCursor cursor) { cursor_ = cursor; } 30 void set_cursor(gfx::NativeCursor cursor) { cursor_ = cursor; }
32 31
33 bool visible() const { return visible_; } 32 bool visible() const { return visible_; }
34 void SetVisible(bool visible) { 33 void SetVisible(bool visible) {
35 if (mouse_events_enabled_) 34 if (mouse_events_enabled_)
36 visible_ = visible; 35 visible_ = visible;
37 // Ignores the call when mouse events disabled. 36 // Ignores the call when mouse events disabled.
38 } 37 }
39 38
40 float scale() const { return scale_; }
41 void set_scale(float scale) {
42 scale_ = scale;
43 }
44
45 ui::CursorSetType cursor_set() const { return cursor_set_; } 39 ui::CursorSetType cursor_set() const { return cursor_set_; }
46 void set_cursor_set(ui::CursorSetType cursor_set) { 40 void set_cursor_set(ui::CursorSetType cursor_set) {
47 cursor_set_ = cursor_set; 41 cursor_set_ = cursor_set;
48 } 42 }
49 43
50 bool mouse_events_enabled() const { return mouse_events_enabled_; } 44 bool mouse_events_enabled() const { return mouse_events_enabled_; }
51 void SetMouseEventsEnabled(bool enabled) { 45 void SetMouseEventsEnabled(bool enabled) {
52 if (mouse_events_enabled_ == enabled) 46 if (mouse_events_enabled_ == enabled)
53 return; 47 return;
54 mouse_events_enabled_ = enabled; 48 mouse_events_enabled_ = enabled;
55 49
56 // Restores the visibility when mouse events are enabled. 50 // Restores the visibility when mouse events are enabled.
57 if (enabled) { 51 if (enabled) {
58 visible_ = visible_on_mouse_events_enabled_; 52 visible_ = visible_on_mouse_events_enabled_;
59 } else { 53 } else {
60 visible_on_mouse_events_enabled_ = visible_; 54 visible_on_mouse_events_enabled_ = visible_;
61 visible_ = false; 55 visible_ = false;
62 } 56 }
63 } 57 }
64 58
65 private: 59 private:
66 gfx::NativeCursor cursor_; 60 gfx::NativeCursor cursor_;
67 bool visible_; 61 bool visible_;
68 float scale_;
69 ui::CursorSetType cursor_set_; 62 ui::CursorSetType cursor_set_;
70 bool mouse_events_enabled_; 63 bool mouse_events_enabled_;
71 64
72 // The visibility to set when mouse events are enabled. 65 // The visibility to set when mouse events are enabled.
73 bool visible_on_mouse_events_enabled_; 66 bool visible_on_mouse_events_enabled_;
74 67
75 DISALLOW_COPY_AND_ASSIGN(CursorState); 68 DISALLOW_COPY_AND_ASSIGN(CursorState);
76 }; 69 };
77 70
78 } // namespace internal 71 } // namespace internal
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 delegate_->SetVisibility(state_on_unlock_->visible(), this); 109 delegate_->SetVisibility(state_on_unlock_->visible(), this);
117 FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_, 110 FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_,
118 OnCursorVisibilityChanged(false)); 111 OnCursorVisibilityChanged(false));
119 } 112 }
120 } 113 }
121 114
122 bool CursorManager::IsCursorVisible() const { 115 bool CursorManager::IsCursorVisible() const {
123 return current_state_->visible(); 116 return current_state_->visible();
124 } 117 }
125 118
126 void CursorManager::SetScale(float scale) {
127 state_on_unlock_->set_scale(scale);
128 if (GetScale() != state_on_unlock_->scale())
129 delegate_->SetScale(state_on_unlock_->scale(), this);
130 }
131
132 float CursorManager::GetScale() const {
133 return current_state_->scale();
134 }
135
136 void CursorManager::SetCursorSet(ui::CursorSetType cursor_set) { 119 void CursorManager::SetCursorSet(ui::CursorSetType cursor_set) {
137 state_on_unlock_->set_cursor_set(cursor_set); 120 state_on_unlock_->set_cursor_set(cursor_set);
138 if (GetCursorSet() != state_on_unlock_->cursor_set()) 121 if (GetCursorSet() != state_on_unlock_->cursor_set())
139 delegate_->SetCursorSet(state_on_unlock_->cursor_set(), this); 122 delegate_->SetCursorSet(state_on_unlock_->cursor_set(), this);
140 } 123 }
141 124
142 ui::CursorSetType CursorManager::GetCursorSet() const { 125 ui::CursorSetType CursorManager::GetCursorSet() const {
143 return current_state_->cursor_set(); 126 return current_state_->cursor_set();
144 } 127 }
145 128
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 199 }
217 200
218 void CursorManager::CommitVisibility(bool visible) { 201 void CursorManager::CommitVisibility(bool visible) {
219 // TODO(tdanderson): Find a better place for this so we don't 202 // TODO(tdanderson): Find a better place for this so we don't
220 // notify the observers more than is necessary. 203 // notify the observers more than is necessary.
221 FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_, 204 FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_,
222 OnCursorVisibilityChanged(visible)); 205 OnCursorVisibilityChanged(visible));
223 current_state_->SetVisible(visible); 206 current_state_->SetVisible(visible);
224 } 207 }
225 208
226 void CursorManager::CommitScale(float scale) {
227 current_state_->set_scale(scale);
228 }
229
230 void CursorManager::CommitCursorSet(ui::CursorSetType cursor_set) { 209 void CursorManager::CommitCursorSet(ui::CursorSetType cursor_set) {
231 current_state_->set_cursor_set(cursor_set); 210 current_state_->set_cursor_set(cursor_set);
232 } 211 }
233 212
234 void CursorManager::CommitMouseEventsEnabled(bool enabled) { 213 void CursorManager::CommitMouseEventsEnabled(bool enabled) {
235 current_state_->SetMouseEventsEnabled(enabled); 214 current_state_->SetMouseEventsEnabled(enabled);
236 } 215 }
237 216
238 } // namespace wm 217 } // 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