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