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