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

Unified Diff: ash/wm/default_window_resizer.h

Issue 9599007: Minor refactoring of window resize code. I wasn't too happy with (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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/ash.gyp ('k') | ash/wm/default_window_resizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/default_window_resizer.h
===================================================================
--- ash/wm/default_window_resizer.h (revision 124905)
+++ ash/wm/default_window_resizer.h (working copy)
@@ -2,27 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_WM_WINDOW_RESIZER_H_
-#define ASH_WM_WINDOW_RESIZER_H_
+#ifndef ASH_WM_DEFAULT_WINDOW_RESIZER_H_
+#define ASH_WM_DEFAULT_WINDOW_RESIZER_H_
#pragma once
-#include "ash/ash_export.h"
-#include "base/basictypes.h"
-#include "ui/gfx/rect.h"
+#include "ash/wm/window_resizer.h"
+#include "base/compiler_specific.h"
-namespace aura {
-class Window;
-}
-
namespace ash {
namespace internal {
class RootWindowEventFilter;
}
-// WindowResizer is used by ToplevelWindowEventFilter to handle dragging,
-// moving or resizing a window.
-class ASH_EXPORT WindowResizer {
+// WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving
+// or resizing a window. All coordinates passed to this are in the parent
+// windows coordiantes.
+class ASH_EXPORT DefaultWindowResizer : public WindowResizer {
public:
// Constants to identify the type of resize.
static const int kBoundsChange_None;
@@ -34,101 +30,36 @@
static const int kBoundsChangeDirection_Horizontal;
static const int kBoundsChangeDirection_Vertical;
- WindowResizer(aura::Window* window,
- const gfx::Point& location,
- int window_component,
- int grid_size);
- virtual ~WindowResizer();
+ virtual ~DefaultWindowResizer();
- // Returns a bitmask of the kBoundsChange_ values.
- static int GetBoundsChangeForWindowComponent(int component);
+ // Creates a new DefaultWindowResizer. The caller takes ownership of the
+ // returned object. Returns NULL if not resizable.
+ static DefaultWindowResizer* Create(aura::Window* window,
+ const gfx::Point& location,
+ int window_component,
+ int grid_size);
- // Returns a location >= |location| that is aligned to fall on increments of
- // |grid_size|.
- static int AlignToGrid(int location, int grid_size);
-
- // Invoked to drag/move/resize the window. |location| is in the coordinates
- // of the window supplied to the constructor.
- void Drag(const gfx::Point& location);
-
- // Invoked to complete the drag.
- virtual void CompleteDrag();
-
- // Reverts the drag.
- virtual void RevertDrag();
-
// Returns true if the drag will result in changing the window in anyway.
- bool is_resizable() const { return is_resizable_; }
+ bool is_resizable() const { return details_.is_resizable; }
- // See description above members for details.
- const gfx::Rect& initial_bounds() const { return initial_bounds_; }
- const gfx::Point& initial_location_in_parent() const {
- return initial_location_in_parent_;
- }
- int window_component() const { return window_component_; }
- aura::Window* window() const { return window_; }
- int grid_size() const { return grid_size_; }
- bool did_move_or_resize() const { return did_move_or_resize_; }
- int bounds_change() const { return bounds_change_; }
+ // WindowResizer overides:
+ virtual void Drag(const gfx::Point& location) OVERRIDE;
+ virtual void CompleteDrag() OVERRIDE;
+ virtual void RevertDrag() OVERRIDE;
- protected:
- // Returns the bounds to give to the window once the mouse has moved to
- // |location|.
- virtual gfx::Rect GetBoundsForDrag(const gfx::Point& location);
-
- // Returns the final bounds. This differs from current bounds if a grid_size
- // was specified.
- virtual gfx::Rect GetFinalBounds();
-
private:
- // Returns the new origin of the window. The arguments are the difference
- // between the current location and the initial location.
- gfx::Point GetOriginForDrag(int delta_x, int delta_y) const;
+ explicit DefaultWindowResizer(const Details& details);
- // Returns the size of the window for the drag.
- gfx::Size GetSizeForDrag(int* delta_x, int* delta_y) const;
+ const Details details_;
- // Returns the width of the window.
- int GetWidthForDrag(int min_width, int* delta_x) const;
-
- // Returns the height of the drag.
- int GetHeightForDrag(int min_height, int* delta_y) const;
-
- // The window we're resizing.
- aura::Window* window_;
-
- // Initial bounds of the window.
- const gfx::Rect initial_bounds_;
-
- // Location passed to the constructor, in |window->parent()|'s coordinates.
- const gfx::Point initial_location_in_parent_;
-
- // The component the user pressed on.
- const int window_component_;
-
- // Bitmask of the |kBoundsChange_| constants.
- const int bounds_change_;
-
- // Bitmask of the |kBoundsChangeDirection_| constants.
- const int position_change_direction_;
-
- // Bitmask of the |kBoundsChangeDirection_| constants.
- const int size_change_direction_;
-
- // Will the drag actually modify the window?
- const bool is_resizable_;
-
- // Size of the grid.
- const int grid_size_;
-
// Set to true once Drag() is invoked and the bounds of the window change.
bool did_move_or_resize_;
internal::RootWindowEventFilter* root_filter_;
- DISALLOW_COPY_AND_ASSIGN(WindowResizer);
+ DISALLOW_COPY_AND_ASSIGN(DefaultWindowResizer);
};
} // namespace aura
-#endif // ASH_WM_WINDOW_RESIZER_H_
+#endif // ASH_WM_DEFAULT_WINDOW_RESIZER_H_
« no previous file with comments | « ash/ash.gyp ('k') | ash/wm/default_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698