blob: 2bd3f1227e7435d4248ca7033fafa9c3d3a3045e [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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
Ben Murdochba5b9a62013-08-12 14:20:17 +010010#include "ash/ash_export.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000011#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
16namespace aura {
17class Window;
18}
19
20namespace ash {
Torne (Richard Coles)58218062012-11-14 11:43:16 +000021class ResizeShadow;
22
23// ResizeShadowController observes changes to resizable windows and shows
24// a resize handle visual effect when the cursor is near the edges.
Ben Murdochba5b9a62013-08-12 14:20:17 +010025class ASH_EXPORT ResizeShadowController : public aura::WindowObserver {
Torne (Richard Coles)58218062012-11-14 11:43:16 +000026 public:
27 ResizeShadowController();
28 virtual ~ResizeShadowController();
29
30 // Shows the appropriate shadow for a given |window| and |hit_test| location.
31 void ShowShadow(aura::Window* window, int hit_test);
32
33 // Hides the shadow for a |window|, if it has one.
34 void HideShadow(aura::Window* window);
35
Ben Murdochba5b9a62013-08-12 14:20:17 +010036 ResizeShadow* GetShadowForWindowForTest(aura::Window* window);
37
Torne (Richard Coles)58218062012-11-14 11:43:16 +000038 // aura::WindowObserver overrides:
39 virtual void OnWindowBoundsChanged(
40 aura::Window* window,
41 const gfx::Rect& old_bounds,
42 const gfx::Rect& new_bounds) OVERRIDE;
43 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
44
45 private:
46 typedef std::map<aura::Window*, linked_ptr<ResizeShadow> > WindowShadowMap;
47
48 // Creates a shadow for a given window and returns it. |window_shadows_|
49 // owns the memory.
50 ResizeShadow* CreateShadow(aura::Window* window);
51
52 // Returns the resize shadow for |window| or NULL if no shadow exists.
53 ResizeShadow* GetShadowForWindow(aura::Window* window);
54
55 WindowShadowMap window_shadows_;
56
57 DISALLOW_COPY_AND_ASSIGN(ResizeShadowController);
58};
59
Torne (Richard Coles)58218062012-11-14 11:43:16 +000060} // namespace ash
61
62#endif // ASH_WM_RESIZE_SHADOW_CONTROLLER_H_