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_TOPLEVEL_WINDOW_EVENT_FILTER_H_ | |
6 #define UI_AURA_SHELL_TOPLEVEL_WINDOW_EVENT_FILTER_H_ | |
7 #pragma once | |
8 | |
9 #include <set> | |
10 | |
11 #include "base/compiler_specific.h" | |
12 #include "ui/aura/event_filter.h" | |
13 #include "ui/aura_shell/aura_shell_export.h" | |
14 #include "ui/gfx/point.h" | |
15 #include "ui/gfx/rect.h" | |
16 | |
17 namespace aura { | |
18 class LocatedEvent; | |
19 class MouseEvent; | |
20 class Window; | |
21 } | |
22 | |
23 namespace aura_shell { | |
24 | |
25 class AURA_SHELL_EXPORT ToplevelWindowEventFilter : public aura::EventFilter { | |
26 public: | |
27 explicit ToplevelWindowEventFilter(aura::Window* owner); | |
28 virtual ~ToplevelWindowEventFilter(); | |
29 | |
30 // Overridden from aura::EventFilter: | |
31 virtual bool PreHandleKeyEvent(aura::Window* target, | |
32 aura::KeyEvent* event) OVERRIDE; | |
33 virtual bool PreHandleMouseEvent(aura::Window* target, | |
34 aura::MouseEvent* event) OVERRIDE; | |
35 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, | |
36 aura::TouchEvent* event) OVERRIDE; | |
37 | |
38 protected: | |
39 // Returns the |window_component_|. See the variable definition below for | |
40 // more details. | |
41 int window_component() const { return window_component_; } | |
42 | |
43 private: | |
44 // Moves the target window and all of its parents to the front of their | |
45 // respective z-orders. | |
46 // NOTE: this does NOT activate the window. | |
47 void MoveWindowToFront(aura::Window* target); | |
48 | |
49 // Called during a drag to resize/position the window. | |
50 // The return value is returned by OnMouseEvent() above. | |
51 bool HandleDrag(aura::Window* target, aura::LocatedEvent* event); | |
52 | |
53 // Updates the event location to window. | |
54 void UpdateLocationFromEvent(aura::Window* target, | |
55 aura::LocatedEvent* event); | |
56 | |
57 // Updates the |window_component_| using the |event|'s location. | |
58 void UpdateWindowComponentForEvent(aura::Window* window, | |
59 aura::LocatedEvent* event); | |
60 | |
61 // Calculates the new origin of the window during a drag. | |
62 gfx::Point GetOriginForDrag(int bounds_change, | |
63 int delta_x, | |
64 int delta_y) const; | |
65 | |
66 // Calculates the new size of the |target| window during a drag. | |
67 // If the size is constrained, |delta_x| and |delta_y| may be clamped. | |
68 gfx::Size GetSizeForDrag(int bounds_change, | |
69 aura::Window* target, | |
70 int* delta_x, | |
71 int* delta_y) const; | |
72 | |
73 // Calculates new width of a window during a drag where the mouse | |
74 // position changed by |delta_x|. |delta_x| may be clamped if the window | |
75 // size is constrained by |min_width|. | |
76 int GetWidthForDrag(int size_change_direction, | |
77 int min_width, | |
78 int* delta_x) const; | |
79 | |
80 // Calculates new height of a window during a drag where the mouse | |
81 // position changed by |delta_y|. |delta_y| may be clamped if the window | |
82 // size is constrained by |min_height|. | |
83 int GetHeightForDrag(int size_change_direction, | |
84 int min_height, | |
85 int* delta_y) const; | |
86 | |
87 // The mouse position in the target window when the mouse was pressed, in | |
88 // the target window's parent's coordinates. | |
89 gfx::Point mouse_down_offset_in_parent_; | |
90 | |
91 // The bounds of the target window when the mouse was pressed. | |
92 gfx::Rect mouse_down_bounds_; | |
93 | |
94 // The window component (hit-test code) the mouse is currently over. | |
95 int window_component_; | |
96 | |
97 // Set of touch ids currently pressed. | |
98 std::set<int> pressed_touch_ids_; | |
99 | |
100 DISALLOW_COPY_AND_ASSIGN(ToplevelWindowEventFilter); | |
101 }; | |
102 | |
103 } // namespace aura | |
104 | |
105 #endif // UI_AURA_SHELL_TOPLEVEL_WINDOW_EVENT_FILTER_H_ | |
OLD | NEW |