OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ | 5 #ifndef ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ |
6 #define ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ | 6 #define ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ui/views/controls/button/image_button.h" | 10 #include "ui/views/controls/button/image_button.h" |
11 | 11 |
12 namespace ash { | 12 namespace ash { |
13 | 13 |
14 namespace internal { | 14 namespace internal { |
15 class PhantomWindowController; | 15 class PhantomWindowController; |
| 16 class SnapSizer; |
16 } | 17 } |
17 | 18 |
18 // Button used for the maximize control on the frame. Handles snapping logic. | 19 // Button used for the maximize control on the frame. Handles snapping logic. |
19 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { | 20 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { |
20 public: | 21 public: |
21 explicit FrameMaximizeButton(views::ButtonListener* listener); | 22 explicit FrameMaximizeButton(views::ButtonListener* listener); |
22 virtual ~FrameMaximizeButton(); | 23 virtual ~FrameMaximizeButton(); |
23 | 24 |
24 // ImageButton overrides: | 25 // ImageButton overrides: |
25 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | 26 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; |
(...skipping 19 matching lines...) Expand all Loading... |
45 SNAP_NONE | 46 SNAP_NONE |
46 }; | 47 }; |
47 | 48 |
48 // Cancels snap behavior. | 49 // Cancels snap behavior. |
49 void Cancel(); | 50 void Cancel(); |
50 | 51 |
51 // Installs/uninstalls an EventFilter to track when escape is pressed. | 52 // Installs/uninstalls an EventFilter to track when escape is pressed. |
52 void InstallEventFilter(); | 53 void InstallEventFilter(); |
53 void UninstallEventFilter(); | 54 void UninstallEventFilter(); |
54 | 55 |
55 // Updates |snap_type_| based on a mouse drag. The parameters are relative to | 56 // Updates |snap_type_| based on a mouse drag. |
56 // the mouse pressed location. | 57 void UpdateSnap(const gfx::Point& location); |
57 void UpdateSnap(int delta_x, int delta_y); | |
58 | 58 |
59 // Returns the type of snap based on the specified coordaintes (relative to | 59 // Returns the type of snap based on the specified location. |
60 // the press location). | 60 SnapType SnapTypeForLocation(const gfx::Point& location) const; |
61 SnapType SnapTypeForDelta(int delta_x, int delta_y) const; | |
62 | 61 |
63 // Returns the bounds of the resulting window for the specified type. | 62 // Returns the bounds of the resulting window for the specified type. |
64 gfx::Rect BoundsForType(SnapType type) const; | 63 gfx::Rect BoundsForType(SnapType type) const; |
65 | 64 |
| 65 // Converts location to screen coordinates and returns it. These are the |
| 66 // coordinates used by the SnapSizer. |
| 67 gfx::Point LocationForSnapSizer(const gfx::Point& location) const; |
| 68 |
66 // Snaps the window to the current snap position. | 69 // Snaps the window to the current snap position. |
67 void Snap(); | 70 void Snap(); |
68 | 71 |
69 // Renders the snap position. | 72 // Renders the snap position. |
70 scoped_ptr<internal::PhantomWindowController> phantom_window_; | 73 scoped_ptr<internal::PhantomWindowController> phantom_window_; |
71 | 74 |
72 // Is snapping enabled? Set on press so that in drag we know whether we | 75 // Is snapping enabled? Set on press so that in drag we know whether we |
73 // should show the snap locations. | 76 // should show the snap locations. |
74 bool is_snap_enabled_; | 77 bool is_snap_enabled_; |
75 | 78 |
76 // Did the user drag far enough to trigger snapping? | 79 // Did the user drag far enough to trigger snapping? |
77 bool exceeded_drag_threshold_; | 80 bool exceeded_drag_threshold_; |
78 | 81 |
79 // Location of the press. | 82 // Location of the press. |
80 gfx::Point press_location_; | 83 gfx::Point press_location_; |
81 | 84 |
82 // Current snap type. | 85 // Current snap type. |
83 SnapType snap_type_; | 86 SnapType snap_type_; |
84 | 87 |
| 88 scoped_ptr<internal::SnapSizer> snap_sizer_; |
| 89 |
85 scoped_ptr<EscapeEventFilter> escape_event_filter_; | 90 scoped_ptr<EscapeEventFilter> escape_event_filter_; |
86 | 91 |
87 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); | 92 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); |
88 }; | 93 }; |
89 | 94 |
90 } // namespace ash | 95 } // namespace ash |
91 | 96 |
92 #endif // ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ | 97 #endif // ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ |
OLD | NEW |