OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ |
| 6 #define ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ |
| 7 |
| 8 #include "ash/ash_export.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/views/controls/button/image_button.h" |
| 11 |
| 12 namespace ash { |
| 13 |
| 14 namespace internal { |
| 15 class PhantomWindowController; |
| 16 } |
| 17 |
| 18 // Button used for the maximize control on the frame. Handles snapping logic. |
| 19 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { |
| 20 public: |
| 21 explicit FrameMaximizeButton(views::ButtonListener* listener); |
| 22 virtual ~FrameMaximizeButton(); |
| 23 |
| 24 // ImageButton overrides: |
| 25 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; |
| 26 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; |
| 27 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; |
| 28 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; |
| 29 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; |
| 30 virtual void OnMouseCaptureLost() OVERRIDE; |
| 31 |
| 32 protected: |
| 33 // ImageButton overrides: |
| 34 virtual SkBitmap GetImageToPaint() OVERRIDE; |
| 35 |
| 36 private: |
| 37 // Where to snap to. |
| 38 enum SnapType { |
| 39 SNAP_LEFT, |
| 40 SNAP_RIGHT, |
| 41 SNAP_MAXIMIZE, |
| 42 SNAP_MINIMIZE, |
| 43 SNAP_NONE |
| 44 }; |
| 45 |
| 46 // Updates |snap_type_| based on a mouse drag. The parameters are relative to |
| 47 // the mouse pressed location. |
| 48 void UpdateSnap(int delta_x, int delta_y); |
| 49 |
| 50 // Returns the type of snap based on the specified coordaintes (relative to |
| 51 // the press location). |
| 52 SnapType SnapTypeForDelta(int delta_x, int delta_y) const; |
| 53 |
| 54 // Returns the bounds of the resulting window for the specified type. |
| 55 gfx::Rect BoundsForType(SnapType type) const; |
| 56 |
| 57 // Snaps the window to the current snap position. |
| 58 void Snap(); |
| 59 |
| 60 // Renders the snap position. |
| 61 scoped_ptr<internal::PhantomWindowController> phantom_window_; |
| 62 |
| 63 // Is snapping enabled? Set on press so that in drag we know whether we |
| 64 // should show the snap locations. |
| 65 bool is_snap_enabled_; |
| 66 |
| 67 // Did the user drag far enough to trigger snapping? |
| 68 bool exceeded_drag_threshold_; |
| 69 |
| 70 // Location of the press. |
| 71 gfx::Point press_location_; |
| 72 |
| 73 // Current snap type. |
| 74 SnapType snap_type_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); |
| 77 }; |
| 78 |
| 79 } // namespace ash |
| 80 |
| 81 #endif // ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ |
OLD | NEW |