Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2671)

Unified Diff: ash/wm/workspace/frame_maximize_button.h

Issue 10823025: Adding new maximize menu according to spec (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Found some edge cases for menu destruction Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b2d1147de7f354b1d4bf848be70eec2202ddbbd9 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 MaximizeBubble;
+
// 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 {
+ 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,12 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton {
// Did the user drag far enough to trigger snapping?
bool exceeded_drag_threshold_;
+ // A window listener for window move / size operations was installed for
+ // this window. It monitors window changes so that the menu can get removed
+ // if it moves. The listener will automatically be removed when the attached
+ // window gets deleted.
+ aura::Window* window_moved_listener_installed_for_;
sky 2012/07/31 16:11:06 Name this |window_| with a comment indicating this
Mr4D (OOO till 08-26) 2012/08/01 20:48:22 Done.
+
// Location of the press.
gfx::Point press_location_;
@@ -118,6 +151,8 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton {
base::OneShotTimer<FrameMaximizeButton> update_timer_;
+ scoped_ptr<MaximizeBubble> maximizer_;
+
DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton);
};

Powered by Google App Engine
This is Rietveld 408576698