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

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

Issue 9609016: Initial cut at multi-window resize code. There's still some TODOs, but (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup 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/toplevel_window_event_filter_unittest.cc ('k') | ash/wm/workspace/multi_window_resize_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/multi_window_resize_controller.h
diff --git a/ash/wm/workspace/multi_window_resize_controller.h b/ash/wm/workspace/multi_window_resize_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..d1c83a9f5675916464388eb2fe265bebee6fa2b3
--- /dev/null
+++ b/ash/wm/workspace/multi_window_resize_controller.h
@@ -0,0 +1,145 @@
+// Copyright (c) 2012 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_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_
+#define ASH_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_
+#pragma once
+
+#include "ash/ash_export.h"
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/timer.h"
+#include "ui/gfx/rect.h"
+#include "ui/views/mouse_watcher.h"
+
+namespace aura {
+class Window;
+}
+
+namespace views {
+class Widget;
+}
+
+namespace ash {
+namespace internal {
+
+class WorkspaceWindowResizer;
+
+// Two directions resizes happen in.
+enum Direction {
+ TOP_BOTTOM,
+ LEFT_RIGHT,
+};
+
+// MultiWindowResizeController is responsible for determining and showing a
+// widget that allows resizing multiple windows at the same time.
+// MultiWindowResizeController is driven by WorkspaceEventFilter.
+class ASH_EXPORT MultiWindowResizeController :
+ public views::MouseWatcherListener {
+ public:
+ MultiWindowResizeController();
+ ~MultiWindowResizeController();
Ben Goodger (Google) 2012/03/06 15:40:45 virtual
+
+ // If necessary, shows the resize widget. |window| is the window the mouse
+ // is over, |component| the edge and |point| the location of the mouse.
+ void Show(aura::Window* window, int component, const gfx::Point& point);
+
+ // Hides the resize widget.
+ void Hide();
+
+ void set_grid_size(int grid_size) { grid_size_ = grid_size; }
+
+ // MouseWatcherListenre overrides:
+ virtual void MouseMovedOutOfHost() OVERRIDE;
+
+ private:
+ // Used to track the two resizable windows and direction.
+ struct ResizeWindows {
+ ResizeWindows();
+ ~ResizeWindows();
+
+ // Returns true if |other| equals this ResizeWindows.
+ bool Equals(const ResizeWindows& other) const;
+
+ // Returns true if this ResizeWindows is valid.
+ bool is_valid() const { return window1 && window2; }
+
+ // The left/top window to resize.
+ aura::Window* window1;
+
+ // Other window to resize.
+ aura::Window* window2;
+
+ // Direction
+ Direction direction;
+ };
+
+ class ResizeMouseWatcherHost;
+ class ResizeView;
+
+ // Returns a ResizeWindows based on the specified arguments. Use is_valid()
+ // to test if the return value is a valid multi window resize location.
+ ResizeWindows DetermineWindows(aura::Window* window,
+ int window_component,
+ const gfx::Point& point) const;
+
+ // Finds a window by edge (one of the constants HitTestCompat.
+ aura::Window* FindWindowByEdge(aura::Window* window_to_ignore,
+ int edge_want,
+ int x,
+ int y) const;
+
+ // Shows the widget immediately.
+ void ShowNow();
+
+ // Returns true if the widget is showing.
+ bool IsShowing() const;
+
+ // Initiates a resize.
+ void StartResize(const gfx::Point& screen_location);
+
+ // Resizes to the new location.
+ void Resize(const gfx::Point& screen_location);
+
+ // Completes the resize.
+ void CompleteResize();
+
+ // Cancels the resize.
+ void CancelResize();
+
+ // Returns the bounds for the resize widget.
+ gfx::Rect CalculateResizeWidgetBounds() const;
+
+ // Returns true if |screen_location| is over the resize windows (or the resize
+ // widget itself).
+ bool IsOverWindows(const gfx::Point& screen_location) const;
+
+ // Returns true if |screen_location| is over |window|.
+ bool IsOverWindow(aura::Window* window,
+ const gfx::Point& screen_location) const;
+
+ // Windows and direction to resize.
+ ResizeWindows windows_;
+
+ // Timer used before showing.
+ base::OneShotTimer<MultiWindowResizeController> show_timer_;
+
+ views::Widget* resize_widget_;
+
+ // If non-null we're in a resize loop.
+ scoped_ptr<WorkspaceWindowResizer> window_resizer_;
+
+ // Bounds the widget was last shown at.
+ gfx::Rect show_bounds_;
+
+ // Size of the grid.
+ int grid_size_;
+
+ DISALLOW_COPY_AND_ASSIGN(MultiWindowResizeController);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_
« no previous file with comments | « ash/wm/toplevel_window_event_filter_unittest.cc ('k') | ash/wm/workspace/multi_window_resize_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698