Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Unified Diff: ash/wm/workspace/workspace_window_resizer.h

Issue 9706059: Centralizes snap sizing and implements spec'd behavior. Three resize (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better comments Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/workspace/snap_sizer.cc ('k') | ash/wm/workspace/workspace_window_resizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/workspace_window_resizer.h
diff --git a/ash/wm/workspace/workspace_window_resizer.h b/ash/wm/workspace/workspace_window_resizer.h
index eaa2b1d79475c287eace17be1e224cf13ad0f451..db2202e08656c850f2aeb5ec0b3a7f920134c78a 100644
--- a/ash/wm/workspace/workspace_window_resizer.h
+++ b/ash/wm/workspace/workspace_window_resizer.h
@@ -17,6 +17,7 @@ namespace internal {
class PhantomWindowController;
class RootWindowEventFilter;
+class SnapSizer;
// WindowResizer implementation for workspaces. This enforces that windows are
// not allowed to vertically move or resize outside of the work area. As windows
@@ -25,25 +26,13 @@ class RootWindowEventFilter;
// attempt to restore the old height.
class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
public:
- // Used when the window is dragged against the edge of the screen.
- enum EdgeType {
- LEFT_EDGE,
- RIGHT_EDGE
- };
-
// When dragging an attached window this is the min size we'll make sure is
- // visibile. In the vertical direction we take the max of this and that from
+ // visible. In the vertical direction we take the max of this and that from
// the delegate.
static const int kMinOnscreenSize;
virtual ~WorkspaceWindowResizer();
- // Returns the bounds for a window along the specified edge.
- static gfx::Rect GetBoundsForWindowAlongEdge(
- aura::Window* window,
- EdgeType edge,
- int grid_size);
-
static WorkspaceWindowResizer* Create(
aura::Window* window,
const gfx::Point& location,
@@ -68,21 +57,17 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
const std::vector<aura::Window*>& attached_windows);
private:
- // Location of the phanton window.
- enum PhantomType {
- TYPE_LEFT_EDGE,
- TYPE_RIGHT_EDGE,
- TYPE_DESTINATION,
- TYPE_NONE
- };
+ // Type of snapping.
+ enum SnapType {
+ // Snap to the left/right edge of the screen.
+ SNAP_LEFT_EDGE,
+ SNAP_RIGHT_EDGE,
- // Type and bounds of the phantom window.
- struct PhantomPlacement {
- PhantomPlacement();
- ~PhantomPlacement();
+ // Snap to the final bounds. Used when there is a grid.
+ SNAP_DESTINATION,
- PhantomType type;
- gfx::Rect bounds;
+ // No snap position.
+ SNAP_NONE
};
// Returns the final bounds to place the window at. This differs from
@@ -116,14 +101,9 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
// Updates the bounds of the phantom window.
void UpdatePhantomWindow(const gfx::Point& location);
- // Updates |phantom_placement_| when type is one of TYPE_LEFT_EDGE or
- // TYPE_RIGHT_EDGE.
- void UpdatePhantomWindowBoundsAlongEdge(
- const PhantomPlacement& last_placement);
-
- // Returns a PhantomPlacement for the specified point. TYPE_NONE is used if
- // the location doesn't have a valid phantom location.
- PhantomPlacement GetPhantomPlacement(const gfx::Point& location);
+ // Returns the SnapType for the specified point. SNAP_NONE is used if no
+ // snapping should be used.
+ SnapType GetSnapType(const gfx::Point& location) const;
aura::Window* window() const { return details_.window; }
@@ -162,8 +142,11 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
// is a grid and the caption is being dragged.
scoped_ptr<PhantomWindowController> phantom_window_controller_;
- // Last PhantomPlacement.
- PhantomPlacement phantom_placement_;
+ // Used to determine the target position of a snap.
+ scoped_ptr<SnapSizer> snap_sizer_;
+
+ // Last SnapType.
+ SnapType snap_type_;
// Number of mouse moves since the last bounds change. Only used for phantom
// placement to track when the mouse is moved while pushed against the edge of
« no previous file with comments | « ash/wm/workspace/snap_sizer.cc ('k') | ash/wm/workspace/workspace_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698