OLD | NEW |
| (Empty) |
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 CHROME_BROWSER_UI_VIEWS_ASH_WINDOW_POSITIONER_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_ASH_WINDOW_POSITIONER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "ui/gfx/rect.h" | |
10 | |
11 namespace aura { | |
12 class Window; | |
13 } | |
14 | |
15 // WindowPositioner is used by the browser to move new popups automatically to | |
16 // a usable position on the closest work area (of the active window). | |
17 class WindowPositioner { | |
18 public: | |
19 WindowPositioner(); | |
20 ~WindowPositioner(); | |
21 | |
22 // Find a suitable screen position for a popup window and return it. The | |
23 // passed input position is only used to retrieve the width and height. | |
24 // The position is determined on the left / right / top / bottom first. If | |
25 // no smart space is found, the position will follow the standard what other | |
26 // operating systems do (default cascading style). | |
27 gfx::Rect GetPopupPosition(const gfx::Rect& old_pos); | |
28 | |
29 protected: | |
30 // Find a smart way to position the popup window. If there is no space this | |
31 // function will return an empty rectangle. | |
32 gfx::Rect SmartPopupPosition(const gfx::Rect& old_pos, | |
33 const gfx::Rect& work_area, | |
34 int grid); | |
35 | |
36 // Find the next available cascading popup position (on the given screen). | |
37 gfx::Rect NormalPopupPosition(const gfx::Rect& old_pos, | |
38 const gfx::Rect& work_area); | |
39 | |
40 // Align the location to the grid / snap to the right / bottom corner. | |
41 gfx::Rect AlignPopupPosition(const gfx::Rect &pos, | |
42 const gfx::Rect &work_area, | |
43 int grid); | |
44 | |
45 // Constants to identify the type of resize. | |
46 static const int kBoundsChange_None; | |
47 | |
48 // The offset in X and Y for the next popup which opens. | |
49 int pop_position_offset_increment_x; | |
50 int pop_position_offset_increment_y; | |
51 | |
52 // The position on the screen for the first popup which gets shown if no | |
53 // empty space can be found. | |
54 int popup_position_offset_from_screen_corner_x; | |
55 int popup_position_offset_from_screen_corner_y; | |
56 | |
57 // The last used position. | |
58 int last_popup_position_x_; | |
59 int last_popup_position_y_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(WindowPositioner); | |
62 }; | |
63 | |
64 #endif // CHROME_BROWSER_UI_VIEWS_ASH_WINDOW_POSITIONER_H_ | |
OLD | NEW |