This source file includes following definitions.
- ShouldAnimateWindow
- CallAnimateOnChildWindowVisibilityChanged
- UpdateLayerVisibility
- original_enabled_
- SuspendChildWindowVisibilityAnimations
- SetChildWindowVisibilityChangesAnimated
#include "ui/wm/core/visibility_controller.h"
#include "ui/aura/window.h"
#include "ui/aura/window_property.h"
#include "ui/compositor/layer.h"
#include "ui/wm/core/window_animations.h"
namespace wm {
namespace {
DEFINE_WINDOW_PROPERTY_KEY(
bool, kChildWindowVisibilityChangesAnimatedKey, false);
bool ShouldAnimateWindow(aura::Window* window) {
return window->parent() && window->parent()->GetProperty(
kChildWindowVisibilityChangesAnimatedKey);
}
}
VisibilityController::VisibilityController() {
}
VisibilityController::~VisibilityController() {
}
bool VisibilityController::CallAnimateOnChildWindowVisibilityChanged(
aura::Window* window,
bool visible) {
return AnimateOnChildWindowVisibilityChanged(window, visible);
}
void VisibilityController::UpdateLayerVisibility(aura::Window* window,
bool visible) {
bool animated = window->type() != ui::wm::WINDOW_TYPE_CONTROL &&
window->type() != ui::wm::WINDOW_TYPE_UNKNOWN &&
ShouldAnimateWindow(window);
animated = animated &&
CallAnimateOnChildWindowVisibilityChanged(window, visible);
if (!visible &&
window->layer()->GetAnimator()->IsAnimatingProperty(
ui::LayerAnimationElement::VISIBILITY) &&
!window->layer()->GetTargetVisibility()) {
return;
}
if (!animated || visible)
window->layer()->SetVisible(visible);
}
SuspendChildWindowVisibilityAnimations::SuspendChildWindowVisibilityAnimations(
aura::Window* window)
: window_(window),
original_enabled_(window->GetProperty(
kChildWindowVisibilityChangesAnimatedKey)) {
window_->ClearProperty(kChildWindowVisibilityChangesAnimatedKey);
}
SuspendChildWindowVisibilityAnimations::
~SuspendChildWindowVisibilityAnimations() {
if (original_enabled_)
window_->SetProperty(kChildWindowVisibilityChangesAnimatedKey, true);
else
window_->ClearProperty(kChildWindowVisibilityChangesAnimatedKey);
}
void SetChildWindowVisibilityChangesAnimated(aura::Window* window) {
window->SetProperty(kChildWindowVisibilityChangesAnimatedKey, true);
}
}