OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_AURA_SHELL_SHADOW_CONTROLLER_H_ |
| 6 #define UI_AURA_SHELL_SHADOW_CONTROLLER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/linked_ptr.h" |
| 14 #include "ui/aura/desktop_observer.h" |
| 15 #include "ui/aura/window_observer.h" |
| 16 |
| 17 namespace aura { |
| 18 class Window; |
| 19 } |
| 20 namespace gfx { |
| 21 class Rect; |
| 22 } |
| 23 |
| 24 namespace aura_shell { |
| 25 namespace internal { |
| 26 |
| 27 class Shadow; |
| 28 |
| 29 // ShadowController observes changes to windows and creates and updates drop |
| 30 // shadows as needed. |
| 31 class ShadowController : public aura::DesktopObserver, |
| 32 public aura::WindowObserver { |
| 33 public: |
| 34 class TestApi { |
| 35 public: |
| 36 explicit TestApi(ShadowController* controller) : controller_(controller) {} |
| 37 ~TestApi() {} |
| 38 |
| 39 Shadow* GetShadowForWindow(aura::Window* window) { |
| 40 return controller_->GetShadowForWindow(window); |
| 41 } |
| 42 |
| 43 private: |
| 44 ShadowController* controller_; // not owned |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(TestApi); |
| 47 }; |
| 48 |
| 49 explicit ShadowController(); |
| 50 virtual ~ShadowController(); |
| 51 |
| 52 // aura::DesktopObserver override: |
| 53 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; |
| 54 |
| 55 // aura::WindowObserver overrides: |
| 56 virtual void OnWindowParentChanged( |
| 57 aura::Window* window, aura::Window* parent) OVERRIDE; |
| 58 virtual void OnPropertyChanged( |
| 59 aura::Window* window, const char* name, void* old) OVERRIDE; |
| 60 virtual void OnWindowVisibilityChanged( |
| 61 aura::Window* window, bool visible) OVERRIDE; |
| 62 virtual void OnWindowBoundsChanged( |
| 63 aura::Window* window, const gfx::Rect& bounds) OVERRIDE; |
| 64 virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE; |
| 65 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
| 66 |
| 67 private: |
| 68 typedef std::map<aura::Window*, linked_ptr<Shadow> > WindowShadowMap; |
| 69 |
| 70 // Checks if |window| is visible and contains a property requesting a shadow. |
| 71 bool ShouldShowShadowForWindow(aura::Window* window) const; |
| 72 |
| 73 // Returns |window|'s shadow from |window_shadows_|, or NULL if no shadow |
| 74 // exists. |
| 75 Shadow* GetShadowForWindow(aura::Window* window); |
| 76 |
| 77 // Shows or hides |window|'s shadow as needed (creating the shadow if |
| 78 // necessary). |
| 79 void HandlePossibleShadowVisibilityChange(aura::Window* window); |
| 80 |
| 81 // Creates a new shadow for |window| and stores it in |window_shadows_|. The |
| 82 // shadow's visibility, bounds, and stacking are initialized appropriately. |
| 83 void CreateShadowForWindow(aura::Window* window); |
| 84 |
| 85 // Stacks |shadow|'s layer directly beneath |window|'s layer. |
| 86 void StackShadowBelowWindow(Shadow* shadow, aura::Window* window); |
| 87 |
| 88 WindowShadowMap window_shadows_; |
| 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(ShadowController); |
| 91 }; |
| 92 |
| 93 } // namepsace aura_shell |
| 94 } // namepsace internal |
| 95 |
| 96 #endif // UI_AURA_SHELL_SHADOW_CONTROLLER_H_ |
OLD | NEW |