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

Side by Side Diff: ui/wm/core/shadow_controller.cc

Issue 2555373004: Apply new MD shadows to CrOS tray bubbles. (Closed)
Patch Set: leave activation alone Created 4 years 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
« ui/wm/core/shadow.cc ('K') | « ui/wm/core/shadow.cc ('k') | 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) 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"
(...skipping 28 matching lines...) Expand all
39 case ui::wm::WINDOW_TYPE_PANEL: 39 case ui::wm::WINDOW_TYPE_PANEL:
40 case ui::wm::WINDOW_TYPE_MENU: 40 case ui::wm::WINDOW_TYPE_MENU:
41 case ui::wm::WINDOW_TYPE_TOOLTIP: 41 case ui::wm::WINDOW_TYPE_TOOLTIP:
42 return SHADOW_TYPE_RECTANGULAR; 42 return SHADOW_TYPE_RECTANGULAR;
43 default: 43 default:
44 break; 44 break;
45 } 45 }
46 return SHADOW_TYPE_NONE; 46 return SHADOW_TYPE_NONE;
47 } 47 }
48 48
49 bool ShouldUseSmallShadowForWindow(aura::Window* window) { 49 Shadow::Style GetShadowStyleForWindow(aura::Window* window) {
50 switch (window->type()) { 50 switch (window->type()) {
51 case ui::wm::WINDOW_TYPE_MENU: 51 case ui::wm::WINDOW_TYPE_MENU:
52 case ui::wm::WINDOW_TYPE_TOOLTIP: 52 case ui::wm::WINDOW_TYPE_TOOLTIP:
53 return true; 53 return Shadow::STYLE_SMALL;
54
55 // System tray bubbles render like active windows. TODO(estade): this
56 // mechanism will need to be revisited for applying WM shadows to other
57 // types of bubbles which don't want to render such large shadows.
58 case ui::wm::WINDOW_TYPE_POPUP:
James Cook 2016/12/09 19:40:13 From the code this looks like it will apply large
Evan Stade 2016/12/09 21:09:18 I'll look into it. I had hoped that other popups w
Evan Stade 2016/12/09 21:20:32 Do you have an example of a drag widget? When I dr
59 return Shadow::STYLE_ACTIVE;
60
54 default: 61 default:
55 break; 62 return IsActiveWindow(window) ? Shadow::STYLE_ACTIVE
63 : Shadow::STYLE_INACTIVE;
56 } 64 }
57 return false;
58 }
59
60 Shadow::Style GetShadowStyleForWindow(aura::Window* window) {
61 return ShouldUseSmallShadowForWindow(window) ? Shadow::STYLE_SMALL :
62 (IsActiveWindow(window) ? Shadow::STYLE_ACTIVE : Shadow::STYLE_INACTIVE);
63 } 65 }
64 66
65 // Returns the shadow style to be applied to |losing_active| when it is losing 67 // Returns the shadow style to be applied to |losing_active| when it is losing
66 // active to |gaining_active|. |gaining_active| may be of a type that hides when 68 // active to |gaining_active|. |gaining_active| may be of a type that hides when
67 // inactive, and as such we do not want to render |losing_active| as inactive. 69 // inactive, and as such we do not want to render |losing_active| as inactive.
68 Shadow::Style GetShadowStyleForWindowLosingActive( 70 Shadow::Style GetShadowStyleForWindowLosingActive(
69 aura::Window* losing_active, 71 aura::Window* losing_active,
70 aura::Window* gaining_active) { 72 aura::Window* gaining_active) {
71 if (gaining_active && aura::client::GetHideOnDeactivate(gaining_active)) { 73 if (gaining_active && aura::client::GetHideOnDeactivate(gaining_active)) {
72 aura::Window::Windows::const_iterator it = 74 aura::Window::Windows::const_iterator it =
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 void ShadowController::Impl::OnWindowDestroyed(aura::Window* window) { 189 void ShadowController::Impl::OnWindowDestroyed(aura::Window* window) {
188 window->ClearProperty(kShadowLayerKey); 190 window->ClearProperty(kShadowLayerKey);
189 observer_manager_.Remove(window); 191 observer_manager_.Remove(window);
190 } 192 }
191 193
192 void ShadowController::Impl::OnWindowActivated(ActivationReason reason, 194 void ShadowController::Impl::OnWindowActivated(ActivationReason reason,
193 aura::Window* gained_active, 195 aura::Window* gained_active,
194 aura::Window* lost_active) { 196 aura::Window* lost_active) {
195 if (gained_active) { 197 if (gained_active) {
196 Shadow* shadow = GetShadowForWindow(gained_active); 198 Shadow* shadow = GetShadowForWindow(gained_active);
197 if (shadow && !ShouldUseSmallShadowForWindow(gained_active)) 199 if (shadow)
198 shadow->SetStyle(Shadow::STYLE_ACTIVE); 200 shadow->SetStyle(GetShadowStyleForWindow(gained_active));
199 } 201 }
200 if (lost_active) { 202 if (lost_active) {
201 Shadow* shadow = GetShadowForWindow(lost_active); 203 Shadow* shadow = GetShadowForWindow(lost_active);
202 if (shadow && !ShouldUseSmallShadowForWindow(lost_active)) { 204 if (shadow &&
205 GetShadowStyleForWindow(lost_active) == Shadow::STYLE_INACTIVE) {
James Cook 2016/12/09 19:40:13 Shouldn't you be checking if the window that lost
Evan Stade 2016/12/09 21:09:18 I don't think this change affects the behavior at
James Cook 2016/12/10 00:19:16 What if |lost_active| had shadow style Shadow::STY
203 shadow->SetStyle(GetShadowStyleForWindowLosingActive(lost_active, 206 shadow->SetStyle(GetShadowStyleForWindowLosingActive(lost_active,
204 gained_active)); 207 gained_active));
205 } 208 }
206 } 209 }
207 } 210 }
208 211
209 bool ShadowController::Impl::ShouldShowShadowForWindow( 212 bool ShadowController::Impl::ShouldShowShadowForWindow(
210 aura::Window* window) const { 213 aura::Window* window) const {
211 ui::WindowShowState show_state = 214 ui::WindowShowState show_state =
212 window->GetProperty(aura::client::kShowStateKey); 215 window->GetProperty(aura::client::kShowStateKey);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 activation_client_->RemoveObserver(this); 280 activation_client_->RemoveObserver(this);
278 } 281 }
279 282
280 void ShadowController::OnWindowActivated(ActivationReason reason, 283 void ShadowController::OnWindowActivated(ActivationReason reason,
281 aura::Window* gained_active, 284 aura::Window* gained_active,
282 aura::Window* lost_active) { 285 aura::Window* lost_active) {
283 impl_->OnWindowActivated(reason, gained_active, lost_active); 286 impl_->OnWindowActivated(reason, gained_active, lost_active);
284 } 287 }
285 288
286 } // namespace wm 289 } // namespace wm
OLDNEW
« ui/wm/core/shadow.cc ('K') | « ui/wm/core/shadow.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698