diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-01 07:16:14 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-01 07:16:14 +0000 |
commit | 9861f175f93a2fb3b7ab48df78622c311f9fa8f9 (patch) | |
tree | 28c225f59d56a55619caf033c0c199f2e17d609e /ui | |
parent | 6bc34b9d3b72c666e67d7e81ae60dbe544abcf65 (diff) | |
download | chromium_src-9861f175f93a2fb3b7ab48df78622c311f9fa8f9.zip chromium_src-9861f175f93a2fb3b7ab48df78622c311f9fa8f9.tar.gz chromium_src-9861f175f93a2fb3b7ab48df78622c311f9fa8f9.tar.bz2 |
ash: Holding down shift slows window animations for debugging
* Adds SlowAnimationEventFilter to look for raw shift-press events
* Adds tests for above
* Adds "slow animation mode" to layer animator that slows down layer animations by a factor of 4 for visual testing/debugging
* Fixes some typos in comments
I elected to make this a new event filter because I can't accomplish this with a regular accelerator and I didn't want to pollute any of the existing filters with this functionality.
BUG=130168
TEST=aura_shell_unittests SlowAnimationEventFilterTest, hold down shift and maximize/restore windows
Review URL: https://chromiumcodereview.appspot.com/10456034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139986 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/accelerators/accelerator.cc | 4 | ||||
-rw-r--r-- | ui/base/accelerators/accelerator.h | 4 | ||||
-rw-r--r-- | ui/compositor/layer_animator.cc | 27 | ||||
-rw-r--r-- | ui/compositor/layer_animator.h | 12 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 2 |
5 files changed, 36 insertions, 13 deletions
diff --git a/ui/base/accelerators/accelerator.cc b/ui/base/accelerators/accelerator.cc index 153a13f..d249d81 100644 --- a/ui/base/accelerators/accelerator.cc +++ b/ui/base/accelerators/accelerator.cc @@ -205,10 +205,10 @@ string16 Accelerator::GetShortcutText() const { // problem). // // The only way to solve this problem is to adjust the string if the locale - // is RTL so that it is drawn correnctly in an RTL context. Instead of + // is RTL so that it is drawn correctly in an RTL context. Instead of // returning "Ctrl++" in the above example, we return "++Ctrl". This will // cause the text to appear as "Ctrl++" when Windows draws the string in an - // RTL context because the punctunation no longer appears at the end of the + // RTL context because the punctuation no longer appears at the end of the // string. // // TODO(idana) bug# 1232732: this hack can be avoided if instead of using diff --git a/ui/base/accelerators/accelerator.h b/ui/base/accelerators/accelerator.h index 33beaa4..6c7753f 100644 --- a/ui/base/accelerators/accelerator.h +++ b/ui/base/accelerators/accelerator.h @@ -73,7 +73,7 @@ class UI_EXPORT AcceleratorTarget { virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; // Should return true if the target can handle the accelerator events. The - // AcceleratorPressed method is inovked only for targets for which + // AcceleratorPressed method is invoked only for targets for which // CanHandleAccelerators returns true. virtual bool CanHandleAccelerators() const = 0; @@ -81,7 +81,7 @@ class UI_EXPORT AcceleratorTarget { virtual ~AcceleratorTarget() {} }; -// Since acclerator code is one of the few things that can't be cross platform +// Since accelerator code is one of the few things that can't be cross platform // in the chrome UI, separate out just the GetAcceleratorForCommandId() from // the menu delegates. class AcceleratorProvider { diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc index 712cd2b2..79aebc7 100644 --- a/ui/compositor/layer_animator.cc +++ b/ui/compositor/layer_animator.cc @@ -26,7 +26,15 @@ static const base::TimeDelta kDefaultTransitionDuration = static const base::TimeDelta kTimerInterval = base::TimeDelta::FromMilliseconds(10); -} // namespace; +// For visual debugging, slow animations down by this factor. +const int kSlowAnimationScaleFactor = 4; + +} // namespace + +// static +bool LayerAnimator::disable_animations_for_test_ = false; +// static +bool LayerAnimator::slow_animation_mode_ = false; // LayerAnimator public -------------------------------------------------------- @@ -46,9 +54,6 @@ LayerAnimator::~LayerAnimator() { } // static -bool LayerAnimator::disable_animations_for_test_ = false; - -// static LayerAnimator* LayerAnimator::CreateDefaultAnimator() { return new LayerAnimator(base::TimeDelta::FromMilliseconds(0)); } @@ -59,7 +64,7 @@ LayerAnimator* LayerAnimator::CreateImplicitAnimator() { } void LayerAnimator::SetTransform(const Transform& transform) { - base::TimeDelta duration = transition_duration_; + base::TimeDelta duration = GetTransitionDuration(); scoped_ptr<LayerAnimationElement> element( LayerAnimationElement::CreateTransformElement(transform, duration)); element->set_tween_type(tween_type_); @@ -73,7 +78,7 @@ Transform LayerAnimator::GetTargetTransform() const { } void LayerAnimator::SetBounds(const gfx::Rect& bounds) { - base::TimeDelta duration = transition_duration_; + base::TimeDelta duration = GetTransitionDuration(); scoped_ptr<LayerAnimationElement> element( LayerAnimationElement::CreateBoundsElement(bounds, duration)); element->set_tween_type(tween_type_); @@ -87,7 +92,7 @@ gfx::Rect LayerAnimator::GetTargetBounds() const { } void LayerAnimator::SetOpacity(float opacity) { - base::TimeDelta duration = transition_duration_; + base::TimeDelta duration = GetTransitionDuration(); scoped_ptr<LayerAnimationElement> element( LayerAnimationElement::CreateOpacityElement(opacity, duration)); element->set_tween_type(tween_type_); @@ -101,7 +106,7 @@ float LayerAnimator::GetTargetOpacity() const { } void LayerAnimator::SetVisibility(bool visibility) { - base::TimeDelta duration = transition_duration_; + base::TimeDelta duration = GetTransitionDuration(); // Tween type doesn't matter for visibility. StartAnimation(new LayerAnimationSequence( @@ -581,4 +586,10 @@ void LayerAnimator::OnScheduled(LayerAnimationSequence* sequence) { sequence->OnScheduled(); } +base::TimeDelta LayerAnimator::GetTransitionDuration() const { + if (slow_animation_mode_) + return transition_duration_ * kSlowAnimationScaleFactor; + return transition_duration_; +} + } // namespace ui diff --git a/ui/compositor/layer_animator.h b/ui/compositor/layer_animator.h index 4f41bb5..130af0e 100644 --- a/ui/compositor/layer_animator.h +++ b/ui/compositor/layer_animator.h @@ -135,6 +135,11 @@ class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement { } base::TimeTicks last_step_time() const { return last_step_time_; } + // When set all animations play slowly for visual debugging. + static void set_slow_animation_mode(bool slow) { + slow_animation_mode_ = slow; + } + // When set to true, all animations complete immediately. static void set_disable_animations_for_test(bool disable_animations) { disable_animations_for_test_ = disable_animations; @@ -240,6 +245,10 @@ class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement { // starting the animation or adding to the queue. void OnScheduled(LayerAnimationSequence* sequence); + // Returns the default length of animations, including adjustment for slow + // animation mode if set. + base::TimeDelta GetTransitionDuration() const; + // This is the queue of animations to run. AnimationQueue animation_queue_; @@ -271,6 +280,9 @@ class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement { // This causes all animations to complete immediately. static bool disable_animations_for_test_; + // Slows down all animations for visual debugging. + static bool slow_animation_mode_; + // Observers are notified when layer animations end, are scheduled or are // aborted. ObserverList<LayerAnimationObserver> observers_; diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index a2e3a47..5df2920 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -724,7 +724,7 @@ void NativeWidgetAura::OnBlur() { bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { if (event->is_char()) { - // If a ui::InputMethod object is attched to the root window, character + // If a ui::InputMethod object is attached to the root window, character // events are handled inside the object and are not passed to this function. // If such object is not attached, character events might be sent (e.g. on // Windows). In this case, we just skip these. |