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..d704e6f2b73f6fa6889c07db3e60bfb373ae256c 100644 |
--- a/ash/wm/workspace/frame_maximize_button.h |
+++ b/ash/wm/workspace/frame_maximize_button.h |
@@ -6,8 +6,10 @@ |
#define ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ |
#include "ash/ash_export.h" |
+#include "ash/wm/workspace/snap_types.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 +23,22 @@ 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: |
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,23 +49,23 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { |
virtual ui::GestureStatus OnGestureEvent( |
const views::GestureEvent& event) OVERRIDE; |
- protected: |
- // ImageButton overrides: |
- virtual gfx::ImageSkia GetImageToPaint() OVERRIDE; |
+ // Updates |snap_type_| based on a a given snap type. This is used by |
+ // external hover events from the button menu. |
+ void SnapButtonHovered(workspace::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(workspace::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_; } |
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); |
@@ -67,7 +78,7 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { |
bool ProcessEndEvent(const views::LocatedEvent& event); |
// Cancels snap behavior. |
- void Cancel(); |
+ void Cancel(bool keep_menu_open); |
// Installs/uninstalls an EventFilter to track when escape is pressed. |
void InstallEventFilter(); |
@@ -81,10 +92,10 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { |
void UpdateSnap(const gfx::Point& location); |
// Returns the type of snap based on the specified location. |
- SnapType SnapTypeForLocation(const gfx::Point& location) const; |
+ workspace::SnapType SnapTypeForLocation(const gfx::Point& location) const; |
// Returns the bounds of the resulting window for the specified type. |
- gfx::Rect ScreenBoundsForType(SnapType type) const; |
+ gfx::Rect ScreenBoundsForType(workspace::SnapType type) const; |
// Converts location to screen coordinates and returns it. These are the |
// coordinates used by the SnapSizer. |
@@ -106,11 +117,14 @@ 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_; |
// Current snap type. |
- SnapType snap_type_; |
+ workspace::SnapType snap_type_; |
scoped_ptr<internal::SnapSizer> snap_sizer_; |
@@ -118,6 +132,8 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { |
base::OneShotTimer<FrameMaximizeButton> update_timer_; |
+ scoped_ptr<MaximizeBubbleController> maximizer_; |
+ |
DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); |
}; |