forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathresize_shadow.h
70 lines (52 loc) · 2.03 KB
/
resize_shadow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_RESIZE_SHADOW_H_
#define ASH_WM_RESIZE_SHADOW_H_
#include <memory>
#include "base/macros.h"
#include "ui/aura/window_observer.h"
namespace aura {
class Window;
}
namespace ui {
class Layer;
}
namespace ash {
// A class to render the resize edge effect when the user moves their mouse
// over a sizing edge. This is just a visual effect; the actual resize is
// handled by the EventFilter.
class ResizeShadow : public aura::WindowObserver {
public:
explicit ResizeShadow(aura::Window* window);
~ResizeShadow() override;
// aura::WindowObserver:
void OnWindowBoundsChanged(aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) override;
void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override;
void OnWindowStackingChanged(aura::Window* window) override;
// Shows resize effects for one or more edges based on a |hit_test| code, such
// as HTRIGHT or HTBOTTOMRIGHT.
void ShowForHitTest(int hit_test);
// Hides all resize effects.
void Hide();
int GetLastHitTestForTest() const { return last_hit_test_; }
const ui::Layer* GetLayerForTest() const { return layer_.get(); }
private:
// Reparents |layer_| so that it's behind the layer of |window_|.
void ReparentLayer();
// Updates bounds and visibility of |layer_|.
void UpdateBoundsAndVisibility();
aura::Window* window_;
// The layer to which the shadow is drawn. The layer is stacked beneath the
// layer of |window_|.
std::unique_ptr<ui::Layer> layer_;
// Hit test value from last call to ShowForHitTest(). Used to prevent
// repeatedly triggering the same animations for the same hit.
int last_hit_test_;
DISALLOW_COPY_AND_ASSIGN(ResizeShadow);
};
} // namespace ash
#endif // ASH_WM_RESIZE_SHADOW_H_