| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/wm/core/shadow_controller.h" | 5 #include "ui/wm/core/shadow_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
| 13 #include "ui/aura/client/aura_constants.h" | 13 #include "ui/aura/client/aura_constants.h" |
| 14 #include "ui/aura/env.h" | 14 #include "ui/aura/env.h" |
| 15 #include "ui/aura/env_observer.h" | 15 #include "ui/aura/env_observer.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
| 18 #include "ui/base/class_property.h" | 18 #include "ui/base/class_property.h" |
| 19 #include "ui/base/ui_base_types.h" | 19 #include "ui/base/ui_base_types.h" |
| 20 #include "ui/compositor/layer.h" | 20 #include "ui/compositor/layer.h" |
| 21 #include "ui/wm/core/shadow.h" | 21 #include "ui/wm/core/shadow.h" |
| 22 #include "ui/wm/core/shadow_types.h" | |
| 23 #include "ui/wm/core/window_util.h" | 22 #include "ui/wm/core/window_util.h" |
| 24 #include "ui/wm/public/activation_client.h" | 23 #include "ui/wm/public/activation_client.h" |
| 25 | 24 |
| 26 using std::make_pair; | 25 using std::make_pair; |
| 27 | 26 |
| 28 DECLARE_UI_CLASS_PROPERTY_TYPE(::wm::Shadow*); | 27 DECLARE_UI_CLASS_PROPERTY_TYPE(::wm::Shadow*); |
| 29 DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(::wm::Shadow, kShadowLayerKey, nullptr); | 28 DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(::wm::Shadow, kShadowLayerKey, nullptr); |
| 30 | 29 |
| 31 namespace wm { | 30 namespace wm { |
| 32 | 31 |
| 33 namespace { | 32 namespace { |
| 34 | 33 |
| 35 constexpr ShadowElevation kActiveNormalShadowElevation = ShadowElevation::LARGE; | |
| 36 constexpr ShadowElevation kInactiveNormalShadowElevation = | 34 constexpr ShadowElevation kInactiveNormalShadowElevation = |
| 37 ShadowElevation::MEDIUM; | 35 ShadowElevation::MEDIUM; |
| 38 | 36 |
| 39 ShadowElevation GetDefaultShadowElevationForWindow(aura::Window* window) { | 37 ShadowElevation GetDefaultShadowElevationForWindow(aura::Window* window) { |
| 40 switch (window->type()) { | 38 switch (window->type()) { |
| 41 case ui::wm::WINDOW_TYPE_NORMAL: | 39 case ui::wm::WINDOW_TYPE_NORMAL: |
| 42 case ui::wm::WINDOW_TYPE_PANEL: | 40 case ui::wm::WINDOW_TYPE_PANEL: |
| 43 return kInactiveNormalShadowElevation; | 41 return kInactiveNormalShadowElevation; |
| 44 | 42 |
| 45 case ui::wm::WINDOW_TYPE_MENU: | 43 case ui::wm::WINDOW_TYPE_MENU: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 60 ? GetDefaultShadowElevationForWindow(window) | 58 ? GetDefaultShadowElevationForWindow(window) |
| 61 : elevation; | 59 : elevation; |
| 62 } | 60 } |
| 63 | 61 |
| 64 ShadowElevation GetShadowElevationForActiveState(aura::Window* window) { | 62 ShadowElevation GetShadowElevationForActiveState(aura::Window* window) { |
| 65 ShadowElevation elevation = window->GetProperty(kShadowElevationKey); | 63 ShadowElevation elevation = window->GetProperty(kShadowElevationKey); |
| 66 if (elevation != ShadowElevation::DEFAULT) | 64 if (elevation != ShadowElevation::DEFAULT) |
| 67 return elevation; | 65 return elevation; |
| 68 | 66 |
| 69 if (IsActiveWindow(window)) | 67 if (IsActiveWindow(window)) |
| 70 return kActiveNormalShadowElevation; | 68 return ShadowController::kActiveNormalShadowElevation; |
| 71 | 69 |
| 72 return GetDefaultShadowElevationForWindow(window); | 70 return GetDefaultShadowElevationForWindow(window); |
| 73 } | 71 } |
| 74 | 72 |
| 75 // Returns the shadow style to be applied to |losing_active| when it is losing | 73 // Returns the shadow style to be applied to |losing_active| when it is losing |
| 76 // active to |gaining_active|. |gaining_active| may be of a type that hides when | 74 // active to |gaining_active|. |gaining_active| may be of a type that hides when |
| 77 // inactive, and as such we do not want to render |losing_active| as inactive. | 75 // inactive, and as such we do not want to render |losing_active| as inactive. |
| 78 ShadowElevation GetShadowElevationForWindowLosingActive( | 76 ShadowElevation GetShadowElevationForWindowLosingActive( |
| 79 aura::Window* losing_active, | 77 aura::Window* losing_active, |
| 80 aura::Window* gaining_active) { | 78 aura::Window* gaining_active) { |
| 81 if (gaining_active && aura::client::GetHideOnDeactivate(gaining_active)) { | 79 if (gaining_active && aura::client::GetHideOnDeactivate(gaining_active)) { |
| 82 aura::Window::Windows::const_iterator it = | 80 aura::Window::Windows::const_iterator it = |
| 83 std::find(GetTransientChildren(losing_active).begin(), | 81 std::find(GetTransientChildren(losing_active).begin(), |
| 84 GetTransientChildren(losing_active).end(), | 82 GetTransientChildren(losing_active).end(), |
| 85 gaining_active); | 83 gaining_active); |
| 86 if (it != GetTransientChildren(losing_active).end()) | 84 if (it != GetTransientChildren(losing_active).end()) |
| 87 return kActiveNormalShadowElevation; | 85 return ShadowController::kActiveNormalShadowElevation; |
| 88 } | 86 } |
| 89 return kInactiveNormalShadowElevation; | 87 return kInactiveNormalShadowElevation; |
| 90 } | 88 } |
| 91 | 89 |
| 92 } // namespace | 90 } // namespace |
| 93 | 91 |
| 94 // ShadowController::Impl ------------------------------------------------------ | 92 // ShadowController::Impl ------------------------------------------------------ |
| 95 | 93 |
| 96 // Real implementation of the ShadowController. ShadowController observes | 94 // Real implementation of the ShadowController. ShadowController observes |
| 97 // ActivationChangeObserver, which are per ActivationClient, where as there is | 95 // ActivationChangeObserver, which are per ActivationClient, where as there is |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 activation_client_->RemoveObserver(this); | 278 activation_client_->RemoveObserver(this); |
| 281 } | 279 } |
| 282 | 280 |
| 283 void ShadowController::OnWindowActivated(ActivationReason reason, | 281 void ShadowController::OnWindowActivated(ActivationReason reason, |
| 284 aura::Window* gained_active, | 282 aura::Window* gained_active, |
| 285 aura::Window* lost_active) { | 283 aura::Window* lost_active) { |
| 286 impl_->OnWindowActivated(reason, gained_active, lost_active); | 284 impl_->OnWindowActivated(reason, gained_active, lost_active); |
| 287 } | 285 } |
| 288 | 286 |
| 289 } // namespace wm | 287 } // namespace wm |
| OLD | NEW |