OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/sticky_keys/sticky_keys_overlay.h" | 5 #include "ash/sticky_keys/sticky_keys_overlay.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/sticky_keys/sticky_keys_controller.h" | 9 #include "ash/sticky_keys/sticky_keys_controller.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 virtual ~StickyKeysOverlayView(); | 124 virtual ~StickyKeysOverlayView(); |
125 | 125 |
126 // views::WidgetDelegateView overrides: | 126 // views::WidgetDelegateView overrides: |
127 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 127 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
128 | 128 |
129 void SetKeyState(ui::EventFlags modifier, StickyKeyState state); | 129 void SetKeyState(ui::EventFlags modifier, StickyKeyState state); |
130 | 130 |
131 StickyKeyState GetKeyState(ui::EventFlags modifier); | 131 StickyKeyState GetKeyState(ui::EventFlags modifier); |
132 | 132 |
| 133 void SetModifierVisible(ui::EventFlags modifier, bool visible); |
| 134 |
133 private: | 135 private: |
134 void AddKeyLabel(ui::EventFlags modifier, const std::string& key_label); | 136 void AddKeyLabel(ui::EventFlags modifier, const std::string& key_label); |
135 | 137 |
136 typedef std::map<ui::EventFlags, StickyKeyOverlayLabel*> ModifierLabelMap; | 138 typedef std::map<ui::EventFlags, StickyKeyOverlayLabel*> ModifierLabelMap; |
137 ModifierLabelMap modifier_label_map_; | 139 ModifierLabelMap modifier_label_map_; |
138 | 140 |
139 DISALLOW_COPY_AND_ASSIGN(StickyKeysOverlayView); | 141 DISALLOW_COPY_AND_ASSIGN(StickyKeysOverlayView); |
140 }; | 142 }; |
141 | 143 |
142 StickyKeysOverlayView::StickyKeysOverlayView() { | 144 StickyKeysOverlayView::StickyKeysOverlayView() { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 label->SetKeyState(state); | 186 label->SetKeyState(state); |
185 } | 187 } |
186 } | 188 } |
187 | 189 |
188 StickyKeyState StickyKeysOverlayView::GetKeyState(ui::EventFlags modifier) { | 190 StickyKeyState StickyKeysOverlayView::GetKeyState(ui::EventFlags modifier) { |
189 ModifierLabelMap::iterator it = modifier_label_map_.find(modifier); | 191 ModifierLabelMap::iterator it = modifier_label_map_.find(modifier); |
190 DCHECK(it != modifier_label_map_.end()); | 192 DCHECK(it != modifier_label_map_.end()); |
191 return it->second->state(); | 193 return it->second->state(); |
192 } | 194 } |
193 | 195 |
| 196 void StickyKeysOverlayView::SetModifierVisible(ui::EventFlags modifier, |
| 197 bool visible) { |
| 198 ModifierLabelMap::iterator it = modifier_label_map_.find(modifier); |
| 199 DCHECK(it != modifier_label_map_.end()); |
| 200 it->second->SetVisible(visible); |
| 201 } |
| 202 |
194 void StickyKeysOverlayView::AddKeyLabel(ui::EventFlags modifier, | 203 void StickyKeysOverlayView::AddKeyLabel(ui::EventFlags modifier, |
195 const std::string& key_label) { | 204 const std::string& key_label) { |
196 StickyKeyOverlayLabel* label = new StickyKeyOverlayLabel(key_label); | 205 StickyKeyOverlayLabel* label = new StickyKeyOverlayLabel(key_label); |
197 AddChildView(label); | 206 AddChildView(label); |
198 modifier_label_map_[modifier] = label; | 207 modifier_label_map_[modifier] = label; |
199 } | 208 } |
200 | 209 |
201 /////////////////////////////////////////////////////////////////////////////// | 210 /////////////////////////////////////////////////////////////////////////////// |
202 // StickyKeysOverlay | 211 // StickyKeysOverlay |
203 StickyKeysOverlay::StickyKeysOverlay() | 212 StickyKeysOverlay::StickyKeysOverlay() |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 ui::ScopedLayerAnimationSettings settings(animator); | 259 ui::ScopedLayerAnimationSettings settings(animator); |
251 settings.SetPreemptionStrategy( | 260 settings.SetPreemptionStrategy( |
252 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 261 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
253 settings.SetTweenType(visible ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN); | 262 settings.SetTweenType(visible ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN); |
254 settings.SetTransitionDuration( | 263 settings.SetTransitionDuration( |
255 base::TimeDelta::FromMilliseconds(kSlideAnimationDurationMs)); | 264 base::TimeDelta::FromMilliseconds(kSlideAnimationDurationMs)); |
256 | 265 |
257 overlay_widget_->GetLayer()->SetTransform(gfx::Transform()); | 266 overlay_widget_->GetLayer()->SetTransform(gfx::Transform()); |
258 } | 267 } |
259 | 268 |
| 269 void StickyKeysOverlay::SetModifierVisible(ui::EventFlags modifier, |
| 270 bool visible) { |
| 271 overlay_view_->SetModifierVisible(modifier, visible); |
| 272 widget_size_ = overlay_view_->GetPreferredSize(); |
| 273 } |
| 274 |
260 void StickyKeysOverlay::SetModifierKeyState(ui::EventFlags modifier, | 275 void StickyKeysOverlay::SetModifierKeyState(ui::EventFlags modifier, |
261 StickyKeyState state) { | 276 StickyKeyState state) { |
262 overlay_view_->SetKeyState(modifier, state); | 277 overlay_view_->SetKeyState(modifier, state); |
263 } | 278 } |
264 | 279 |
265 StickyKeyState StickyKeysOverlay::GetModifierKeyState( | 280 StickyKeyState StickyKeysOverlay::GetModifierKeyState( |
266 ui::EventFlags modifier) { | 281 ui::EventFlags modifier) { |
267 return overlay_view_->GetKeyState(modifier); | 282 return overlay_view_->GetKeyState(modifier); |
268 } | 283 } |
269 | 284 |
(...skipping 16 matching lines...) Expand all Loading... |
286 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); | 301 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); |
287 if (animator) | 302 if (animator) |
288 animator->RemoveObserver(this); | 303 animator->RemoveObserver(this); |
289 } | 304 } |
290 | 305 |
291 void StickyKeysOverlay::OnLayerAnimationScheduled( | 306 void StickyKeysOverlay::OnLayerAnimationScheduled( |
292 ui::LayerAnimationSequence* sequence) { | 307 ui::LayerAnimationSequence* sequence) { |
293 } | 308 } |
294 | 309 |
295 } // namespace ash | 310 } // namespace ash |
OLD | NEW |