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

Side by Side Diff: ash/wm/shadow_controller.cc

Issue 9169050: aura: No shadow for transparent window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments in #2 Created 8 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « ash/tooltips/tooltip_controller.cc ('k') | ui/aura/window.h » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ash/wm/shadow_controller.h" 5 #include "ash/wm/shadow_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/wm/shadow.h" 10 #include "ash/wm/shadow.h"
11 #include "ash/wm/shadow_types.h" 11 #include "ash/wm/shadow_types.h"
12 #include "ash/wm/window_properties.h" 12 #include "ash/wm/window_properties.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "ui/aura/root_window.h" 15 #include "ui/aura/root_window.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 17
18 using std::make_pair; 18 using std::make_pair;
19 19
20 namespace ash { 20 namespace ash {
21 namespace internal { 21 namespace internal {
22 22
23 namespace { 23 namespace {
24 24
25 ShadowType GetShadowTypeFromWindowType(aura::Window* window) { 25 ShadowType GetShadowTypeFromWindow(aura::Window* window) {
26 // No shadow for transparent window.
27 if (window->transparent())
28 return SHADOW_TYPE_NONE;
29
26 switch (window->type()) { 30 switch (window->type()) {
27 case aura::client::WINDOW_TYPE_NORMAL: 31 case aura::client::WINDOW_TYPE_NORMAL:
28 case aura::client::WINDOW_TYPE_PANEL: 32 case aura::client::WINDOW_TYPE_PANEL:
29 return CommandLine::ForCurrentProcess()->HasSwitch( 33 return CommandLine::ForCurrentProcess()->HasSwitch(
30 switches::kAuraTranslucentFrames) ? 34 switches::kAuraTranslucentFrames) ?
31 SHADOW_TYPE_NONE : SHADOW_TYPE_RECTANGULAR; 35 SHADOW_TYPE_NONE : SHADOW_TYPE_RECTANGULAR;
32 case aura::client::WINDOW_TYPE_MENU: 36 case aura::client::WINDOW_TYPE_MENU:
33 case aura::client::WINDOW_TYPE_TOOLTIP: 37 case aura::client::WINDOW_TYPE_TOOLTIP:
34 return SHADOW_TYPE_RECTANGULAR; 38 return SHADOW_TYPE_RECTANGULAR;
35 default: 39 default:
(...skipping 11 matching lines...) Expand all
47 ShadowController::~ShadowController() { 51 ShadowController::~ShadowController() {
48 for (WindowShadowMap::const_iterator it = window_shadows_.begin(); 52 for (WindowShadowMap::const_iterator it = window_shadows_.begin();
49 it != window_shadows_.end(); ++it) { 53 it != window_shadows_.end(); ++it) {
50 it->first->RemoveObserver(this); 54 it->first->RemoveObserver(this);
51 } 55 }
52 aura::RootWindow::GetInstance()->RemoveRootWindowObserver(this); 56 aura::RootWindow::GetInstance()->RemoveRootWindowObserver(this);
53 } 57 }
54 58
55 void ShadowController::OnWindowInitialized(aura::Window* window) { 59 void ShadowController::OnWindowInitialized(aura::Window* window) {
56 window->AddObserver(this); 60 window->AddObserver(this);
57 SetShadowType(window, GetShadowTypeFromWindowType(window)); 61 SetShadowType(window, GetShadowTypeFromWindow(window));
58 HandlePossibleShadowVisibilityChange(window); 62 HandlePossibleShadowVisibilityChange(window);
59 } 63 }
60 64
61 void ShadowController::OnWindowPropertyChanged(aura::Window* window, 65 void ShadowController::OnWindowPropertyChanged(aura::Window* window,
62 const char* name, 66 const char* name,
63 void* old) { 67 void* old) {
64 if (name == kShadowTypeKey) 68 if (name == kShadowTypeKey)
65 HandlePossibleShadowVisibilityChange(window); 69 HandlePossibleShadowVisibilityChange(window);
66 } 70 }
67 71
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 window_shadows_.insert(make_pair(window, shadow)); 113 window_shadows_.insert(make_pair(window, shadow));
110 114
111 shadow->Init(); 115 shadow->Init();
112 shadow->SetContentBounds(gfx::Rect(window->bounds().size())); 116 shadow->SetContentBounds(gfx::Rect(window->bounds().size()));
113 shadow->layer()->SetVisible(ShouldShowShadowForWindow(window)); 117 shadow->layer()->SetVisible(ShouldShowShadowForWindow(window));
114 window->layer()->Add(shadow->layer()); 118 window->layer()->Add(shadow->layer());
115 } 119 }
116 120
117 } // namespace internal 121 } // namespace internal
118 } // namespace ash 122 } // namespace ash
OLDNEW
« no previous file with comments | « ash/tooltips/tooltip_controller.cc ('k') | ui/aura/window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698