summaryrefslogtreecommitdiffstats
path: root/ash/wm/window_positioner.h
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-04 03:20:01 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-04 03:20:01 +0000
commite9a71317209f27bb07ccd72d34e6c40e8469556f (patch)
treeaccfb9eda5029197dbd71d3a44f22e46b9015f21 /ash/wm/window_positioner.h
parent919b2f83216c7a9f07d2e3569ad74ab8c1a06675 (diff)
downloadchromium_src-e9a71317209f27bb07ccd72d34e6c40e8469556f.zip
chromium_src-e9a71317209f27bb07ccd72d34e6c40e8469556f.tar.gz
chromium_src-e9a71317209f27bb07ccd72d34e6c40e8469556f.tar.bz2
Move WindowPositioner to ash/wm
WindowPositioner doesn't depend on chrome at all. window_positioner_unittest remains c/b/ui/ash as it depends on browser. I'll add separate tests in ash for this. BUG=272460 TBR=sky@chromium.org Review URL: https://codereview.chromium.org/25852004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226941 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/window_positioner.h')
-rw-r--r--ash/wm/window_positioner.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/ash/wm/window_positioner.h b/ash/wm/window_positioner.h
new file mode 100644
index 0000000..8a95b2e
--- /dev/null
+++ b/ash/wm/window_positioner.h
@@ -0,0 +1,75 @@
+// Copyright 2013 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_WINDOW_POSITIONER_H_
+#define ASH_WM_WINDOW_POSITIONER_H_
+
+#include "ash/ash_export.h"
+#include "base/basictypes.h"
+#include "ui/gfx/rect.h"
+
+namespace aura {
+class Window;
+}
+
+namespace ash {
+
+namespace test {
+class WindowPositionerTest;
+}
+
+// WindowPositioner is used by the browser to move new popups automatically to
+// a usable position on the closest work area (of the active window).
+class ASH_EXPORT WindowPositioner {
+ public:
+ WindowPositioner();
+ ~WindowPositioner();
+
+ // Find a suitable screen position for a popup window and return it. The
+ // passed input position is only used to retrieve the width and height.
+ // The position is determined on the left / right / top / bottom first. If
+ // no smart space is found, the position will follow the standard what other
+ // operating systems do (default cascading style).
+ gfx::Rect GetPopupPosition(const gfx::Rect& old_pos);
+
+ protected:
+ friend class test::WindowPositionerTest;
+
+ // Find a smart way to position the popup window. If there is no space this
+ // function will return an empty rectangle.
+ gfx::Rect SmartPopupPosition(const gfx::Rect& old_pos,
+ const gfx::Rect& work_area,
+ int grid);
+
+ // Find the next available cascading popup position (on the given screen).
+ gfx::Rect NormalPopupPosition(const gfx::Rect& old_pos,
+ const gfx::Rect& work_area);
+
+ // Align the location to the grid / snap to the right / bottom corner.
+ gfx::Rect AlignPopupPosition(const gfx::Rect &pos,
+ const gfx::Rect &work_area,
+ int grid);
+
+ // Constant exposed for unittest.
+ static const int kMinimumWindowOffset;
+
+ // The offset in X and Y for the next popup which opens.
+ int pop_position_offset_increment_x;
+ int pop_position_offset_increment_y;
+
+ // The position on the screen for the first popup which gets shown if no
+ // empty space can be found.
+ int popup_position_offset_from_screen_corner_x;
+ int popup_position_offset_from_screen_corner_y;
+
+ // The last used position.
+ int last_popup_position_x_;
+ int last_popup_position_y_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowPositioner);
+};
+
+} // namespace ash
+
+#endif // ASH_WM_WINDOW_POSITIONER_H_