| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 virtual ~FrameMaximizeButton(); | 28 virtual ~FrameMaximizeButton(); |
| 29 | 29 |
| 30 // ImageButton overrides: | 30 // ImageButton overrides: |
| 31 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | 31 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; |
| 32 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; | 32 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; |
| 33 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; | 33 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; |
| 34 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; | 34 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; |
| 35 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; | 35 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; |
| 36 virtual void OnMouseCaptureLost() OVERRIDE; | 36 virtual void OnMouseCaptureLost() OVERRIDE; |
| 37 | 37 |
| 38 // Sets is_left_right_enabled_ and updates tooltip. | |
| 39 void SetIsLeftRightEnabled(bool e); | |
| 40 | |
| 41 void set_is_maximize_enabled(bool e) { is_maximize_enabled_ = e; } | |
| 42 | |
| 43 protected: | 38 protected: |
| 44 // ImageButton overrides: | 39 // ImageButton overrides: |
| 45 virtual SkBitmap GetImageToPaint() OVERRIDE; | 40 virtual SkBitmap GetImageToPaint() OVERRIDE; |
| 46 | 41 |
| 47 private: | 42 private: |
| 48 class EscapeEventFilter; | 43 class EscapeEventFilter; |
| 49 | 44 |
| 50 // Where to snap to. | 45 // Where to snap to. |
| 51 enum SnapType { | 46 enum SnapType { |
| 52 SNAP_LEFT, | 47 SNAP_LEFT, |
| 53 SNAP_RIGHT, | 48 SNAP_RIGHT, |
| 54 SNAP_MAXIMIZE, | 49 SNAP_MAXIMIZE, |
| 55 SNAP_MINIMIZE, | 50 SNAP_MINIMIZE, |
| 56 SNAP_NONE | 51 SNAP_NONE |
| 57 }; | 52 }; |
| 58 | 53 |
| 59 // Cancels snap behavior. | 54 // Cancels snap behavior. |
| 60 void Cancel(); | 55 void Cancel(); |
| 61 | 56 |
| 62 // Installs/uninstalls an EventFilter to track when escape is pressed. | 57 // Installs/uninstalls an EventFilter to track when escape is pressed. |
| 63 void InstallEventFilter(); | 58 void InstallEventFilter(); |
| 64 void UninstallEventFilter(); | 59 void UninstallEventFilter(); |
| 65 | 60 |
| 66 // Updates |snap_type_| based on a mouse drag. | 61 // Updates |snap_type_| based on a mouse drag. |
| 67 void UpdateSnap(const gfx::Point& location); | 62 void UpdateSnap(const gfx::Point& location); |
| 68 | 63 |
| 69 // Returns true if maximizing is allowed. | |
| 70 bool AllowMaximize() const; | |
| 71 | |
| 72 // Returns the type of snap based on the specified location. | 64 // Returns the type of snap based on the specified location. |
| 73 SnapType SnapTypeForLocation(const gfx::Point& location) const; | 65 SnapType SnapTypeForLocation(const gfx::Point& location) const; |
| 74 | 66 |
| 75 // Returns the bounds of the resulting window for the specified type. | 67 // Returns the bounds of the resulting window for the specified type. |
| 76 gfx::Rect BoundsForType(SnapType type) const; | 68 gfx::Rect BoundsForType(SnapType type) const; |
| 77 | 69 |
| 78 // Converts location to screen coordinates and returns it. These are the | 70 // Converts location to screen coordinates and returns it. These are the |
| 79 // coordinates used by the SnapSizer. | 71 // coordinates used by the SnapSizer. |
| 80 gfx::Point LocationForSnapSizer(const gfx::Point& location) const; | 72 gfx::Point LocationForSnapSizer(const gfx::Point& location) const; |
| 81 | 73 |
| 82 // Snaps the window to the current snap position. | 74 // Snaps the window to the current snap position. |
| 83 void Snap(); | 75 void Snap(); |
| 84 | 76 |
| 85 // Frame that the maximize button acts on. | 77 // Frame that the maximize button acts on. |
| 86 views::NonClientFrameView* frame_; | 78 views::NonClientFrameView* frame_; |
| 87 | 79 |
| 88 // Renders the snap position. | 80 // Renders the snap position. |
| 89 scoped_ptr<internal::PhantomWindowController> phantom_window_; | 81 scoped_ptr<internal::PhantomWindowController> phantom_window_; |
| 90 | 82 |
| 91 // Is snapping enabled? Set on press so that in drag we know whether we | 83 // Is snapping enabled? Set on press so that in drag we know whether we |
| 92 // should show the snap locations. | 84 // should show the snap locations. |
| 93 bool is_snap_enabled_; | 85 bool is_snap_enabled_; |
| 94 | 86 |
| 95 // Selectively enable/disable button functionality. | |
| 96 bool is_left_right_enabled_; | |
| 97 bool is_maximize_enabled_; | |
| 98 | |
| 99 // Did the user drag far enough to trigger snapping? | 87 // Did the user drag far enough to trigger snapping? |
| 100 bool exceeded_drag_threshold_; | 88 bool exceeded_drag_threshold_; |
| 101 | 89 |
| 102 // Location of the press. | 90 // Location of the press. |
| 103 gfx::Point press_location_; | 91 gfx::Point press_location_; |
| 104 | 92 |
| 105 // Current snap type. | 93 // Current snap type. |
| 106 SnapType snap_type_; | 94 SnapType snap_type_; |
| 107 | 95 |
| 108 scoped_ptr<internal::SnapSizer> snap_sizer_; | 96 scoped_ptr<internal::SnapSizer> snap_sizer_; |
| 109 | 97 |
| 110 scoped_ptr<EscapeEventFilter> escape_event_filter_; | 98 scoped_ptr<EscapeEventFilter> escape_event_filter_; |
| 111 | 99 |
| 112 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); | 100 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); |
| 113 }; | 101 }; |
| 114 | 102 |
| 115 } // namespace ash | 103 } // namespace ash |
| 116 | 104 |
| 117 #endif // ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ | 105 #endif // ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ |
| OLD | NEW |