OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_VIEWS_PANELS_X11_PANEL_RESIZER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PANELS_X11_PANEL_RESIZER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PANELS_X11_PANEL_RESIZER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PANELS_X11_PANEL_RESIZER_H_ |
7 | 7 |
8 #include "ui/events/event_handler.h" | 8 #include "ui/events/event_handler.h" |
9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
10 | 10 |
11 namespace aura { | 11 namespace aura { |
12 class Window; | 12 class Window; |
13 } | 13 } |
14 | 14 |
15 class Panel; | 15 class Panel; |
16 | 16 |
17 // EventHandler which implements special handling for resizing panels. Panels | 17 // EventHandler which implements special handling for resizing panels. Panels |
18 // should use X11PanelResizer instead of X11WindowEventFilter. | 18 // should use X11PanelResizer instead of X11WindowEventFilter. |
19 // When resizing a panel: | 19 // When resizing a panel: |
20 // - The panel bounds should update in sync with the user's mouse movement | 20 // - The panel bounds should update in sync with the user's mouse movement |
21 // during the resize operation. | 21 // during the resize operation. |
22 // - The layout of all of the panels should be updated once the resize operation | 22 // - The layout of all of the panels should be updated once the resize operation |
23 // completes. | 23 // completes. |
24 // X11PanelResizer does not hand off resizing to the window manager because it | 24 // X11PanelResizer does not hand off resizing to the window manager because it |
25 // is not possible to determine when the window manager has finished resizing. | 25 // is not possible to determine when the window manager has finished resizing. |
26 class X11PanelResizer : public ui::EventHandler { | 26 class X11PanelResizer : public ui::EventHandler { |
27 public: | 27 public: |
28 X11PanelResizer(Panel* panel, aura::Window* window); | 28 X11PanelResizer(Panel* panel, aura::Window* window); |
29 virtual ~X11PanelResizer(); | 29 ~X11PanelResizer() override; |
30 | 30 |
31 private: | 31 private: |
32 enum ResizeState { | 32 enum ResizeState { |
33 NOT_RESIZING, | 33 NOT_RESIZING, |
34 | 34 |
35 // The user has clicked on one of the panel's edges. | 35 // The user has clicked on one of the panel's edges. |
36 RESIZE_CAN_START, | 36 RESIZE_CAN_START, |
37 | 37 |
38 // The user has dragged one of the panel's edges far enough for resizing to | 38 // The user has dragged one of the panel's edges far enough for resizing to |
39 // begin. | 39 // begin. |
40 RESIZE_IN_PROGRESS | 40 RESIZE_IN_PROGRESS |
41 }; | 41 }; |
42 | 42 |
43 // Called as a result of ET_MOUSE_PRESSED. | 43 // Called as a result of ET_MOUSE_PRESSED. |
44 void OnMousePressed(ui::MouseEvent* event); | 44 void OnMousePressed(ui::MouseEvent* event); |
45 | 45 |
46 // Called as a result of ET_MOUSE_DRAGGED. | 46 // Called as a result of ET_MOUSE_DRAGGED. |
47 void OnMouseDragged(ui::MouseEvent* event); | 47 void OnMouseDragged(ui::MouseEvent* event); |
48 | 48 |
49 // Stops the resize operation if one is in progress. Consumes |event| if it | 49 // Stops the resize operation if one is in progress. Consumes |event| if it |
50 // is not NULL and the resize operation was stopped. | 50 // is not NULL and the resize operation was stopped. |
51 void StopResizing(ui::MouseEvent* event, bool canceled); | 51 void StopResizing(ui::MouseEvent* event, bool canceled); |
52 | 52 |
53 // ui::EventHandler: | 53 // ui::EventHandler: |
54 virtual void OnMouseEvent(ui::MouseEvent* event) override; | 54 void OnMouseEvent(ui::MouseEvent* event) override; |
55 | 55 |
56 // The panel being resized. | 56 // The panel being resized. |
57 Panel* panel_; | 57 Panel* panel_; |
58 | 58 |
59 // |panel|'s window. | 59 // |panel|'s window. |
60 aura::Window* window_; | 60 aura::Window* window_; |
61 | 61 |
62 ResizeState resize_state_; | 62 ResizeState resize_state_; |
63 | 63 |
64 // The edge that the user is resizing. | 64 // The edge that the user is resizing. |
65 int resize_component_; | 65 int resize_component_; |
66 | 66 |
67 // The location of the mouse click on the window border. | 67 // The location of the mouse click on the window border. |
68 gfx::Point initial_press_location_in_screen_; | 68 gfx::Point initial_press_location_in_screen_; |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(X11PanelResizer); | 70 DISALLOW_COPY_AND_ASSIGN(X11PanelResizer); |
71 }; | 71 }; |
72 | 72 |
73 #endif // CHROME_BROWSER_UI_VIEWS_PANELS_X11_PANEL_RESIZER_H_ | 73 #endif // CHROME_BROWSER_UI_VIEWS_PANELS_X11_PANEL_RESIZER_H_ |
OLD | NEW |