Chromium Code Reviews| Index: ash/wm/workspace/frame_maximize_button.h |
| diff --git a/ash/wm/workspace/frame_maximize_button.h b/ash/wm/workspace/frame_maximize_button.h |
| index 0124c2f4159d92d5c4799c1e4a4688c292e3a654..116e3278b6f5c20b9676d2a989b17726b687c832 100644 |
| --- a/ash/wm/workspace/frame_maximize_button.h |
| +++ b/ash/wm/workspace/frame_maximize_button.h |
| @@ -8,6 +8,7 @@ |
| #include "ash/ash_export.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/timer.h" |
| +#include "ui/aura/window_observer.h" |
| #include "ui/views/controls/button/image_button.h" |
| namespace views { |
| @@ -21,13 +22,32 @@ class PhantomWindowController; |
| class SnapSizer; |
| } |
| +class MaximizeBubbleController; |
| + |
| // Button used for the maximize control on the frame. Handles snapping logic. |
| -class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { |
| +class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, |
| + public aura::WindowObserver { |
| public: |
| + // Where to snap to. |
| + enum SnapType { |
|
sky
2012/08/02 18:30:30
Move this to its own file to minimize imports. Nam
Mr4D (OOO till 08-26)
2012/08/02 23:10:38
Done.
|
| + SNAP_LEFT, |
| + SNAP_RIGHT, |
| + SNAP_MAXIMIZE, |
| + SNAP_MINIMIZE, |
| + SNAP_RESTORE, |
| + SNAP_NONE |
| + }; |
| + |
| FrameMaximizeButton(views::ButtonListener* listener, |
| views::NonClientFrameView* frame); |
| virtual ~FrameMaximizeButton(); |
| + // WindowObserver overrides: |
| + virtual void OnWindowBoundsChanged(aura::Window* window, |
| + const gfx::Rect& old_bounds, |
| + const gfx::Rect& new_bounds) OVERRIDE; |
| + virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| + |
| // ImageButton overrides: |
| virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; |
| virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; |
| @@ -38,6 +58,23 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { |
| virtual ui::GestureStatus OnGestureEvent( |
| const views::GestureEvent& event) OVERRIDE; |
| + // Updates |snap_type_| based on a a given snap type. This is used by |
| + // external hover events from the button menu. |
| + void SnapButtonHovered(SnapType type); |
| + |
| + // The user clicked the |type| button and the action needs to be performed, |
| + // which will at the same time close the window. |
| + void ExecuteSnapAndCloseMenu(SnapType type); |
| + |
| + // The menu should reflect the user selected type. |
| + void UpdateVisibleMenu(SnapType type); |
| + |
| + // Remove the maximize menu from the screen (and destroy it). |
| + void DestroyMaximizeMenu(); |
| + |
| + // Returns true when the user clicks and drags the button. |
| + bool is_snap_enabled() { return is_snap_enabled_; } |
| + |
| protected: |
| // ImageButton overrides: |
| virtual gfx::ImageSkia GetImageToPaint() OVERRIDE; |
| @@ -45,16 +82,6 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { |
| private: |
| class EscapeEventFilter; |
| - // Where to snap to. |
| - enum SnapType { |
| - SNAP_LEFT, |
| - SNAP_RIGHT, |
| - SNAP_MAXIMIZE, |
| - SNAP_MINIMIZE, |
| - SNAP_RESTORE, |
| - SNAP_NONE |
| - }; |
| - |
| // Initializes the snap-gesture based on the event. This should only be called |
| // when the event is confirmed to have started a snap gesture. |
| void ProcessStartEvent(const views::LocatedEvent& event); |
| @@ -106,6 +133,9 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { |
| // Did the user drag far enough to trigger snapping? |
| bool exceeded_drag_threshold_; |
| + // This is the window_ we are contained in. |
| + aura::Window* window_; |
| + |
| // Location of the press. |
| gfx::Point press_location_; |
| @@ -118,6 +148,8 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { |
| base::OneShotTimer<FrameMaximizeButton> update_timer_; |
| + scoped_ptr<MaximizeBubbleController> maximizer_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); |
| }; |