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