diff options
author | andresantoso <andresantoso@chromium.org> | 2014-10-31 17:50:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-01 00:51:19 +0000 |
commit | 8c848c3f4b03bceab3e847f833afd0d6bd9dd4f5 (patch) | |
tree | d1d8e407ee1bb286cda6d11567211315ec0445e1 | |
parent | 6cdbabebc60c42a496af70fa7a6792454d05ecb9 (diff) | |
download | chromium_src-8c848c3f4b03bceab3e847f833afd0d6bd9dd4f5.zip chromium_src-8c848c3f4b03bceab3e847f833afd0d6bd9dd4f5.tar.gz chromium_src-8c848c3f4b03bceab3e847f833afd0d6bd9dd4f5.tar.bz2 |
MacViews: Put wm window animation calls behind an interface.
These calls are not available on MacViews without Aura, so put them behind an
interface through views::Widget.
BUG=425229
Review URL: https://codereview.chromium.org/693523003
Cr-Commit-Position: refs/heads/master@{#302368}
-rw-r--r-- | chrome/browser/chromeos/login/ui/lock_window_aura.cc | 4 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/ui/login_display_host_impl.cc | 8 | ||||
-rw-r--r-- | chrome/browser/ui/views/autofill/autofill_popup_base_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc | 5 | ||||
-rw-r--r-- | ui/views/touchui/touch_selection_controller_impl.cc | 4 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc | 26 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_native_widget_aura.h | 3 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 26 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.h | 3 | ||||
-rw-r--r-- | ui/views/widget/native_widget_mac.h | 4 | ||||
-rw-r--r-- | ui/views/widget/native_widget_mac.mm | 10 | ||||
-rw-r--r-- | ui/views/widget/native_widget_private.h | 4 | ||||
-rw-r--r-- | ui/views/widget/widget.cc | 8 | ||||
-rw-r--r-- | ui/views/widget/widget.h | 19 |
15 files changed, 111 insertions, 21 deletions
diff --git a/chrome/browser/chromeos/login/ui/lock_window_aura.cc b/chrome/browser/chromeos/login/ui/lock_window_aura.cc index 9f0164f..f816e96 100644 --- a/chrome/browser/chromeos/login/ui/lock_window_aura.cc +++ b/chrome/browser/chromeos/login/ui/lock_window_aura.cc @@ -6,7 +6,6 @@ #include "ash/shell.h" #include "ash/shell_window_ids.h" -#include "ash/wm/window_animations.h" #include "base/command_line.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" @@ -86,8 +85,7 @@ void LockWindowAura::Init() { ash::kShellWindowId_LockScreenContainer); #endif views::Widget::Init(params); - wm::SetWindowVisibilityAnimationTransition( - GetNativeView(), wm::ANIMATE_NONE); + SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); } } // namespace chromeos diff --git a/chrome/browser/chromeos/login/ui/login_display_host_impl.cc b/chrome/browser/chromeos/login/ui/login_display_host_impl.cc index 6154668..8afcca6 100644 --- a/chrome/browser/chromeos/login/ui/login_display_host_impl.cc +++ b/chrome/browser/chromeos/login/ui/login_display_host_impl.cc @@ -87,7 +87,6 @@ #include "ui/views/focus/focus_manager.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" -#include "ui/wm/core/window_animations.h" #include "url/gurl.h" #if !defined(USE_ATHENA) @@ -1104,12 +1103,9 @@ void LoginDisplayHostImpl::InitLoginWindowAndView() { if (login_view_->webui_visible()) OnLoginPromptVisible(); - wm::SetWindowVisibilityAnimationDuration( - login_window_->GetNativeView(), + login_window_->SetVisibilityAnimationDuration( base::TimeDelta::FromMilliseconds(kLoginFadeoutTransitionDurationMs)); - wm::SetWindowVisibilityAnimationTransition( - login_window_->GetNativeView(), - wm::ANIMATE_HIDE); + login_window_->SetVisibilityAnimationTransition(views::Widget::ANIMATE_HIDE); login_window_->AddRemovalsObserver(this); login_window_->SetContentsView(login_view_); diff --git a/chrome/browser/ui/views/autofill/autofill_popup_base_view.cc b/chrome/browser/ui/views/autofill/autofill_popup_base_view.cc index ced3899..0630b48 100644 --- a/chrome/browser/ui/views/autofill/autofill_popup_base_view.cc +++ b/chrome/browser/ui/views/autofill/autofill_popup_base_view.cc @@ -10,7 +10,6 @@ #include "chrome/browser/ui/autofill/popup_constants.h" #include "ui/views/border.h" #include "ui/views/widget/widget.h" -#include "ui/wm/core/window_animations.h" namespace autofill { @@ -68,8 +67,7 @@ void AutofillPopupBaseView::DoShow() { widget->SetContentsView(this); // No animation for popup appearance (too distracting). - wm::SetWindowVisibilityAnimationTransition( - widget->GetNativeView(), wm::ANIMATE_HIDE); + widget->SetVisibilityAnimationTransition(views::Widget::ANIMATE_HIDE); } SetBorder(views::Border::CreateSolidBorder(kPopupBorderThickness, diff --git a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc index b6c13e4..e4509dd 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc @@ -20,7 +20,6 @@ #include "ui/views/view_targeter.h" #include "ui/views/widget/widget.h" #include "ui/views/window/non_client_view.h" -#include "ui/wm/core/window_animations.h" // This is the number of pixels in the border image interior to the actual // border. @@ -214,8 +213,7 @@ void OmniboxPopupContentsView::UpdatePopupAppearance() { // avoid a NULL dereference. if (!popup_.get()) return; - wm::SetWindowVisibilityAnimationTransition( - popup_->GetNativeView(), wm::ANIMATE_NONE); + popup_->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); popup_->SetContentsView(this); popup_->StackAbove(omnibox_view_->GetRelativeWindowForPopup()); if (!popup_.get()) { diff --git a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc index 16c0d7a..b770137 100644 --- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc +++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc @@ -33,7 +33,7 @@ #include "ui/views/layout/fill_layout.h" #include "ui/views/layout/grid_layout.h" #include "ui/views/layout/layout_constants.h" -#include "ui/wm/core/window_animations.h" +#include "ui/views/widget/widget.h" // Helpers -------------------------------------------------------------------- @@ -868,7 +868,6 @@ void ManagePasswordsBubbleView::Observe( const content::NotificationSource& source, const content::NotificationDetails& details) { DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); - aura::Window* window = GetWidget()->GetNativeView(); - wm::SetWindowVisibilityAnimationTransition(window, wm::ANIMATE_NONE); + GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); CloseBubble(); } diff --git a/ui/views/touchui/touch_selection_controller_impl.cc b/ui/views/touchui/touch_selection_controller_impl.cc index 99de2bf..978592c 100644 --- a/ui/views/touchui/touch_selection_controller_impl.cc +++ b/ui/views/touchui/touch_selection_controller_impl.cc @@ -19,7 +19,6 @@ #include "ui/strings/grit/ui_strings.h" #include "ui/views/widget/widget.h" #include "ui/wm/core/masked_window_targeter.h" -#include "ui/wm/core/window_animations.h" namespace { @@ -239,8 +238,7 @@ class TouchSelectionControllerImpl::EditingHandleView void SetWidgetVisible(bool visible, bool quick) { if (widget_->IsVisible() == visible) return; - wm::SetWindowVisibilityAnimationDuration( - widget_->GetNativeView(), + widget_->SetVisibilityAnimationDuration( base::TimeDelta::FromMilliseconds( quick ? kSelectionHandleQuickFadeDurationMs : 0)); if (visible) diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index 2d57f73..445967f 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -55,6 +55,7 @@ #include "ui/wm/core/shadow_controller.h" #include "ui/wm/core/shadow_types.h" #include "ui/wm/core/visibility_controller.h" +#include "ui/wm/core/window_animations.h" #include "ui/wm/core/window_modality_controller.h" #include "ui/wm/public/activation_client.h" #include "ui/wm/public/drag_drop_client.h" @@ -914,6 +915,31 @@ void DesktopNativeWidgetAura::SetVisibilityChangedAnimationsEnabled( desktop_window_tree_host_->SetVisibilityChangedAnimationsEnabled(value); } +void DesktopNativeWidgetAura::SetVisibilityAnimationDuration( + const base::TimeDelta& duration) { + wm::SetWindowVisibilityAnimationDuration(content_window_, duration); +} + +void DesktopNativeWidgetAura::SetVisibilityAnimationTransition( + Widget::VisibilityTransition transition) { + wm::WindowVisibilityAnimationTransition wm_transition = wm::ANIMATE_NONE; + switch (transition) { + case Widget::ANIMATE_SHOW: + wm_transition = wm::ANIMATE_SHOW; + break; + case Widget::ANIMATE_HIDE: + wm_transition = wm::ANIMATE_HIDE; + break; + case Widget::ANIMATE_BOTH: + wm_transition = wm::ANIMATE_BOTH; + break; + case Widget::ANIMATE_NONE: + wm_transition = wm::ANIMATE_NONE; + break; + } + wm::SetWindowVisibilityAnimationTransition(content_window_, wm_transition); +} + ui::NativeTheme* DesktopNativeWidgetAura::GetNativeTheme() const { return DesktopWindowTreeHost::GetNativeTheme(content_window_); } diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h index 1400235..a3c114e 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h @@ -173,6 +173,9 @@ class VIEWS_EXPORT DesktopNativeWidgetAura Widget::MoveLoopEscapeBehavior escape_behavior) override; void EndMoveLoop() override; void SetVisibilityChangedAnimationsEnabled(bool value) override; + void SetVisibilityAnimationDuration(const base::TimeDelta& duration) override; + void SetVisibilityAnimationTransition( + Widget::VisibilityTransition transition) override; ui::NativeTheme* GetNativeTheme() const override; void OnRootViewLayout() override; bool IsTranslucentWindowOpacitySupported() const override; diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index ea164fb..b5b5394 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -37,6 +37,7 @@ #include "ui/views/widget/widget_delegate.h" #include "ui/views/widget/window_reorderer.h" #include "ui/wm/core/shadow_types.h" +#include "ui/wm/core/window_animations.h" #include "ui/wm/core/window_util.h" #include "ui/wm/public/activation_client.h" #include "ui/wm/public/drag_drop_client.h" @@ -678,6 +679,31 @@ void NativeWidgetAura::SetVisibilityChangedAnimationsEnabled(bool value) { window_->SetProperty(aura::client::kAnimationsDisabledKey, !value); } +void NativeWidgetAura::SetVisibilityAnimationDuration( + const base::TimeDelta& duration) { + wm::SetWindowVisibilityAnimationDuration(window_, duration); +} + +void NativeWidgetAura::SetVisibilityAnimationTransition( + Widget::VisibilityTransition transition) { + wm::WindowVisibilityAnimationTransition wm_transition = wm::ANIMATE_NONE; + switch (transition) { + case Widget::ANIMATE_SHOW: + wm_transition = wm::ANIMATE_SHOW; + break; + case Widget::ANIMATE_HIDE: + wm_transition = wm::ANIMATE_HIDE; + break; + case Widget::ANIMATE_BOTH: + wm_transition = wm::ANIMATE_BOTH; + break; + case Widget::ANIMATE_NONE: + wm_transition = wm::ANIMATE_NONE; + break; + } + wm::SetWindowVisibilityAnimationTransition(window_, wm_transition); +} + ui::NativeTheme* NativeWidgetAura::GetNativeTheme() const { #if !defined(OS_CHROMEOS) return DesktopWindowTreeHost::GetNativeTheme(window_); diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index bdd92e4..68e3b94 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -129,6 +129,9 @@ class VIEWS_EXPORT NativeWidgetAura Widget::MoveLoopEscapeBehavior escape_behavior) override; void EndMoveLoop() override; void SetVisibilityChangedAnimationsEnabled(bool value) override; + void SetVisibilityAnimationDuration(const base::TimeDelta& duration) override; + void SetVisibilityAnimationTransition( + Widget::VisibilityTransition transition) override; ui::NativeTheme* GetNativeTheme() const override; void OnRootViewLayout() override; bool IsTranslucentWindowOpacitySupported() const override; diff --git a/ui/views/widget/native_widget_mac.h b/ui/views/widget/native_widget_mac.h index 2736cdc..53e79b4 100644 --- a/ui/views/widget/native_widget_mac.h +++ b/ui/views/widget/native_widget_mac.h @@ -105,6 +105,10 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate { Widget::MoveLoopEscapeBehavior escape_behavior) override; virtual void EndMoveLoop() override; virtual void SetVisibilityChangedAnimationsEnabled(bool value) override; + virtual void SetVisibilityAnimationDuration( + const base::TimeDelta& duration) override; + virtual void SetVisibilityAnimationTransition( + Widget::VisibilityTransition transition) override; virtual ui::NativeTheme* GetNativeTheme() const override; virtual void OnRootViewLayout() override; virtual bool IsTranslucentWindowOpacitySupported() const override; diff --git a/ui/views/widget/native_widget_mac.mm b/ui/views/widget/native_widget_mac.mm index b6578bc..3e0dca9 100644 --- a/ui/views/widget/native_widget_mac.mm +++ b/ui/views/widget/native_widget_mac.mm @@ -512,6 +512,16 @@ void NativeWidgetMac::SetVisibilityChangedAnimationsEnabled(bool value) { NOTIMPLEMENTED(); } +void NativeWidgetMac::SetVisibilityAnimationDuration( + const base::TimeDelta& duration) { + NOTIMPLEMENTED(); +} + +void NativeWidgetMac::SetVisibilityAnimationTransition( + Widget::VisibilityTransition transition) { + NOTIMPLEMENTED(); +} + ui::NativeTheme* NativeWidgetMac::GetNativeTheme() const { return ui::NativeTheme::instance(); } diff --git a/ui/views/widget/native_widget_private.h b/ui/views/widget/native_widget_private.h index 0c28578d..3c6f370 100644 --- a/ui/views/widget/native_widget_private.h +++ b/ui/views/widget/native_widget_private.h @@ -221,6 +221,10 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget { Widget::MoveLoopEscapeBehavior escape_behavior) = 0; virtual void EndMoveLoop() = 0; virtual void SetVisibilityChangedAnimationsEnabled(bool value) = 0; + virtual void SetVisibilityAnimationDuration( + const base::TimeDelta& duration) = 0; + virtual void SetVisibilityAnimationTransition( + Widget::VisibilityTransition transition) = 0; virtual ui::NativeTheme* GetNativeTheme() const = 0; virtual void OnRootViewLayout() = 0; virtual bool IsTranslucentWindowOpacitySupported() const = 0; diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index 8cf11ff..74bd54b 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -519,6 +519,14 @@ void Widget::SetVisibilityChangedAnimationsEnabled(bool value) { native_widget_->SetVisibilityChangedAnimationsEnabled(value); } +void Widget::SetVisibilityAnimationDuration(const base::TimeDelta& duration) { + native_widget_->SetVisibilityAnimationDuration(duration); +} + +void Widget::SetVisibilityAnimationTransition(VisibilityTransition transition) { + native_widget_->SetVisibilityAnimationTransition(transition); +} + Widget::MoveLoopResult Widget::RunMoveLoop( const gfx::Vector2d& drag_offset, MoveLoopSource source, diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h index 4fb573a..fa7c771 100644 --- a/ui/views/widget/widget.h +++ b/ui/views/widget/widget.h @@ -37,6 +37,10 @@ #endif #endif +namespace base { +class TimeDelta; +} + namespace gfx { class Canvas; class Point; @@ -133,6 +137,14 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, MOVE_LOOP_ESCAPE_BEHAVIOR_DONT_HIDE, }; + // Type of visibility change transition that should animate. + enum VisibilityTransition { + ANIMATE_SHOW = 0x1, + ANIMATE_HIDE = 0x2, + ANIMATE_BOTH = ANIMATE_SHOW | ANIMATE_HIDE, + ANIMATE_NONE = 0x4, + }; + struct VIEWS_EXPORT InitParams { enum Type { TYPE_WINDOW, // A decorated Window, like a frame window. @@ -420,6 +432,13 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // Default is true. void SetVisibilityChangedAnimationsEnabled(bool value); + // Sets the duration of visibility change animations. + void SetVisibilityAnimationDuration(const base::TimeDelta& duration); + + // Sets the visibility transitions that should animate. + // Default behavior is to animate both show and hide. + void SetVisibilityAnimationTransition(VisibilityTransition transition); + // Starts a nested message loop that moves the window. This can be used to // start a window move operation from a mouse or touch event. This returns // when the move completes. |drag_offset| is the offset from the top left |