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

Side by Side Diff: ui/keyboard/keyboard_controller.cc

Issue 2877373002: Change keyboard initialization animation from 350 ms to 100 ms (Closed)
Patch Set: Merge branch 'master' of https://chromium.googlesource.com/chromium/src into animation-change Created 3 years, 7 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 | « no previous file | no next file » | 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/keyboard/keyboard_controller.h" 5 #include "ui/keyboard/keyboard_controller.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 28 matching lines...) Expand all
39 #include "ui/ozone/public/input_controller.h" 39 #include "ui/ozone/public/input_controller.h"
40 #include "ui/ozone/public/ozone_platform.h" 40 #include "ui/ozone/public/ozone_platform.h"
41 #endif 41 #endif
42 #endif // if defined(OS_CHROMEOS) 42 #endif // if defined(OS_CHROMEOS)
43 43
44 namespace { 44 namespace {
45 45
46 const int kHideKeyboardDelayMs = 100; 46 const int kHideKeyboardDelayMs = 100;
47 47
48 // The virtual keyboard show/hide animation duration. 48 // The virtual keyboard show/hide animation duration.
49 const int kShowAnimationDurationMs = 350; 49 const int kAnimationDurationMs = 100;
50 const int kHideAnimationDurationMs = 100;
51 50
52 // The opacity of virtual keyboard container when show animation starts or 51 // The opacity of virtual keyboard container when show animation starts or
53 // hide animation finishes. This cannot be zero because we call Show() on the 52 // hide animation finishes. This cannot be zero because we call Show() on the
54 // keyboard window before setting the opacity back to 1.0. Since windows are not 53 // keyboard window before setting the opacity back to 1.0. Since windows are not
55 // allowed to be shown with zero opacity, we always animate to 0.01 instead. 54 // allowed to be shown with zero opacity, we always animate to 0.01 instead.
56 const float kAnimationStartOrAfterHideOpacity = 0.01f; 55 const float kAnimationStartOrAfterHideOpacity = 0.01f;
57 56
58 // The KeyboardWindowDelegate makes sure the keyboard-window does not get focus. 57 // The KeyboardWindowDelegate makes sure the keyboard-window does not get focus.
59 // This is necessary to make sure that the synthetic key-events reach the target 58 // This is necessary to make sure that the synthetic key-events reach the target
60 // window. 59 // window.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ui::LayerAnimator* container_animator = container_->layer()->GetAnimator(); 261 ui::LayerAnimator* container_animator = container_->layer()->GetAnimator();
263 animation_observer_.reset(new CallbackAnimationObserver( 262 animation_observer_.reset(new CallbackAnimationObserver(
264 container_animator, 263 container_animator,
265 base::Bind(&KeyboardController::HideAnimationFinished, 264 base::Bind(&KeyboardController::HideAnimationFinished,
266 base::Unretained(this)))); 265 base::Unretained(this))));
267 container_animator->AddObserver(animation_observer_.get()); 266 container_animator->AddObserver(animation_observer_.get());
268 267
269 ui::ScopedLayerAnimationSettings settings(container_animator); 268 ui::ScopedLayerAnimationSettings settings(container_animator);
270 settings.SetTweenType(gfx::Tween::FAST_OUT_LINEAR_IN); 269 settings.SetTweenType(gfx::Tween::FAST_OUT_LINEAR_IN);
271 settings.SetTransitionDuration( 270 settings.SetTransitionDuration(
272 base::TimeDelta::FromMilliseconds(kHideAnimationDurationMs)); 271 base::TimeDelta::FromMilliseconds(kAnimationDurationMs));
273 gfx::Transform transform; 272 gfx::Transform transform;
274 transform.Translate(0, kAnimationDistance); 273 transform.Translate(0, kAnimationDistance);
275 container_->SetTransform(transform); 274 container_->SetTransform(transform);
276 container_->layer()->SetOpacity(kAnimationStartOrAfterHideOpacity); 275 container_->layer()->SetOpacity(kAnimationStartOrAfterHideOpacity);
277 } 276 }
278 277
279 void KeyboardController::AddObserver(KeyboardControllerObserver* observer) { 278 void KeyboardController::AddObserver(KeyboardControllerObserver* observer) {
280 observer_list_.AddObserver(observer); 279 observer_list_.AddObserver(observer);
281 } 280 }
282 281
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 ui_->ShowKeyboardContainer(container_.get()); 491 ui_->ShowKeyboardContainer(container_.get());
493 492
494 { 493 {
495 // Scope the following animation settings as we don't want to animate 494 // Scope the following animation settings as we don't want to animate
496 // visibility change that triggered by a call to the base class function 495 // visibility change that triggered by a call to the base class function
497 // ShowKeyboardContainer with these settings. The container should become 496 // ShowKeyboardContainer with these settings. The container should become
498 // visible immediately. 497 // visible immediately.
499 ui::ScopedLayerAnimationSettings settings(container_animator); 498 ui::ScopedLayerAnimationSettings settings(container_animator);
500 settings.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN); 499 settings.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN);
501 settings.SetTransitionDuration( 500 settings.SetTransitionDuration(
502 base::TimeDelta::FromMilliseconds(kShowAnimationDurationMs)); 501 base::TimeDelta::FromMilliseconds(kAnimationDurationMs));
503 container_->SetTransform(gfx::Transform()); 502 container_->SetTransform(gfx::Transform());
504 container_->layer()->SetOpacity(1.0); 503 container_->layer()->SetOpacity(1.0);
505 } 504 }
506 } 505 }
507 506
508 bool KeyboardController::WillHideKeyboard() const { 507 bool KeyboardController::WillHideKeyboard() const {
509 return weak_factory_.HasWeakPtrs(); 508 return weak_factory_.HasWeakPtrs();
510 } 509 }
511 510
512 void KeyboardController::ShowAnimationFinished() { 511 void KeyboardController::ShowAnimationFinished() {
(...skipping 21 matching lines...) Expand all
534 int keyboard_height = GetContainerWindow()->bounds().height(); 533 int keyboard_height = GetContainerWindow()->bounds().height();
535 const gfx::Rect& root_bounds = container_->GetRootWindow()->bounds(); 534 const gfx::Rect& root_bounds = container_->GetRootWindow()->bounds();
536 gfx::Rect new_bounds = root_bounds; 535 gfx::Rect new_bounds = root_bounds;
537 new_bounds.set_y(root_bounds.height() - keyboard_height); 536 new_bounds.set_y(root_bounds.height() - keyboard_height);
538 new_bounds.set_height(keyboard_height); 537 new_bounds.set_height(keyboard_height);
539 GetContainerWindow()->SetBounds(new_bounds); 538 GetContainerWindow()->SetBounds(new_bounds);
540 } 539 }
541 } 540 }
542 541
543 } // namespace keyboard 542 } // namespace keyboard
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698