Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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_H_ |
| 6 | #define ASH_WM_RESIZE_SHADOW_H_ |
| 7 | |
| 8 | #include "base/basictypes.h" |
| 9 | #include "base/memory/scoped_ptr.h" |
| 10 | |
| 11 | namespace aura { |
| 12 | class Window; |
| 13 | } |
| 14 | namespace gfx { |
| 15 | class Rect; |
| 16 | } |
| 17 | namespace ui { |
| 18 | class Layer; |
| 19 | } |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 20 | namespace wm { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 21 | class ImageGrid; |
| 22 | } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 23 | |
| 24 | namespace ash { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 25 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 26 | // A class to render the resize edge effect when the user moves their mouse |
| 27 | // over a sizing edge. This is just a visual effect; the actual resize is |
| 28 | // handled by the EventFilter. |
| 29 | class ResizeShadow { |
| 30 | public: |
| 31 | ResizeShadow(); |
| 32 | ~ResizeShadow(); |
| 33 | |
| 34 | // Initializes the resize effect layers for a given |window|. |
| 35 | void Init(aura::Window* window); |
| 36 | |
| 37 | // Shows resize effects for one or more edges based on a |hit_test| code, such |
| 38 | // as HTRIGHT or HTBOTTOMRIGHT. |
| 39 | void ShowForHitTest(int hit_test); |
| 40 | |
| 41 | // Hides all resize effects. |
| 42 | void Hide(); |
| 43 | |
| 44 | // Updates the effect positions based on the |bounds| of the window. |
| 45 | void Layout(const gfx::Rect& bounds); |
| 46 | |
Ben Murdoch | ba5b9a6 | 2013-08-12 14:20:17 +0100 | [diff] [blame] | 47 | int GetLastHitTestForTest() const { |
| 48 | return last_hit_test_; |
| 49 | } |
| 50 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 51 | private: |
| 52 | // Images for the shadow effect. |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 53 | scoped_ptr< ::wm::ImageGrid> image_grid_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 54 | |
| 55 | // Hit test value from last call to ShowForHitTest(). Used to prevent |
| 56 | // repeatedly triggering the same animations for the same hit. |
| 57 | int last_hit_test_; |
| 58 | |
| 59 | DISALLOW_COPY_AND_ASSIGN(ResizeShadow); |
| 60 | }; |
| 61 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 62 | } // namespace ash |
| 63 | |
| 64 | #endif // ASH_WM_RESIZE_SHADOW_H_ |