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 3 // found in the LICENSE file. 4 5 #ifndef ASH_WM_RESIZE_SHADOW_CONTROLLER_H_ 6 #define ASH_WM_RESIZE_SHADOW_CONTROLLER_H_ 7 8 #include <map> 9 10 #include "ash/ash_export.h" 11 #include "base/basictypes.h" 12 #include "base/compiler_specific.h" 13 #include "base/memory/linked_ptr.h" 14 #include "ui/aura/window_observer.h" 15 16 namespace aura { 17 class Window; 18 } 19 20 namespace ash { 21 namespace internal { 22 23 class ResizeShadow; 24 25 // ResizeShadowController observes changes to resizable windows and shows 26 // a resize handle visual effect when the cursor is near the edges. 27 class ASH_EXPORT ResizeShadowController : public aura::WindowObserver { 28 public: 29 ResizeShadowController(); 30 virtual ~ResizeShadowController(); 31 32 // Shows the appropriate shadow for a given |window| and |hit_test| location. 33 void ShowShadow(aura::Window* window, int hit_test); 34 35 // Hides the shadow for a |window|, if it has one. 36 void HideShadow(aura::Window* window); 37 38 ResizeShadow* GetShadowForWindowForTest(aura::Window* window); 39 40 // aura::WindowObserver overrides: 41 virtual void OnWindowBoundsChanged( 42 aura::Window* window, 43 const gfx::Rect& old_bounds, 44 const gfx::Rect& new_bounds) OVERRIDE; 45 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; 46 47 private: 48 typedef std::map<aura::Window*, linked_ptr<ResizeShadow> > WindowShadowMap; 49 50 // Creates a shadow for a given window and returns it. |window_shadows_| 51 // owns the memory. 52 ResizeShadow* CreateShadow(aura::Window* window); 53 54 // Returns the resize shadow for |window| or NULL if no shadow exists. 55 ResizeShadow* GetShadowForWindow(aura::Window* window); 56 57 WindowShadowMap window_shadows_; 58 59 DISALLOW_COPY_AND_ASSIGN(ResizeShadowController); 60 }; 61 62 } // namespace internal 63 } // namespace ash 64 65 #endif // ASH_WM_RESIZE_SHADOW_CONTROLLER_H_ 66