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

Side by Side 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: Adding mouse watcher Created 8 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ 5 #ifndef ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_
6 #define ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ 6 #define ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/wm/workspace/snap_types.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "base/timer.h" 11 #include "base/timer.h"
12 #include "ui/aura/window_observer.h"
11 #include "ui/views/controls/button/image_button.h" 13 #include "ui/views/controls/button/image_button.h"
12 14
13 namespace views { 15 namespace views {
14 class NonClientFrameView; 16 class NonClientFrameView;
15 } 17 }
16 18
17 namespace ash { 19 namespace ash {
18 20
19 namespace internal { 21 namespace internal {
20 class PhantomWindowController; 22 class PhantomWindowController;
21 class SnapSizer; 23 class SnapSizer;
22 } 24 }
23 25
26 class MaximizeBubbleController;
27
24 // Button used for the maximize control on the frame. Handles snapping logic. 28 // Button used for the maximize control on the frame. Handles snapping logic.
25 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { 29 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton,
30 public aura::WindowObserver {
26 public: 31 public:
27 FrameMaximizeButton(views::ButtonListener* listener, 32 FrameMaximizeButton(views::ButtonListener* listener,
28 views::NonClientFrameView* frame); 33 views::NonClientFrameView* frame);
29 virtual ~FrameMaximizeButton(); 34 virtual ~FrameMaximizeButton();
30 35
36 // WindowObserver overrides:
37 virtual void OnWindowBoundsChanged(aura::Window* window,
38 const gfx::Rect& old_bounds,
39 const gfx::Rect& new_bounds) OVERRIDE;
40 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
41
31 // ImageButton overrides: 42 // ImageButton overrides:
32 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; 43 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
33 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; 44 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
34 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; 45 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
35 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; 46 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
36 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; 47 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
37 virtual void OnMouseCaptureLost() OVERRIDE; 48 virtual void OnMouseCaptureLost() OVERRIDE;
38 virtual ui::GestureStatus OnGestureEvent( 49 virtual ui::GestureStatus OnGestureEvent(
39 const views::GestureEvent& event) OVERRIDE; 50 const views::GestureEvent& event) OVERRIDE;
40 51
41 protected: 52 // Updates |snap_type_| based on a a given snap type. This is used by
sky 2012/08/03 19:42:00 move all non-virtual method to above overrides.
Mr4D (OOO till 08-26) 2012/08/03 20:39:28 Done.
42 // ImageButton overrides: 53 // external hover events from the button menu.
43 virtual gfx::ImageSkia GetImageToPaint() OVERRIDE; 54 void SnapButtonHovered(workspace::SnapType type);
55
56 // The user clicked the |type| button and the action needs to be performed,
57 // which will at the same time close the window.
58 void ExecuteSnapAndCloseMenu(workspace::SnapType type);
59
60 // Remove the maximize menu from the screen (and destroy it).
61 void DestroyMaximizeMenu();
62
63 // Returns true when the user clicks and drags the button.
64 bool is_snap_enabled() { return is_snap_enabled_; }
sky 2012/08/03 19:42:00 const
Mr4D (OOO till 08-26) 2012/08/03 20:39:28 Done.
44 65
45 private: 66 private:
46 class EscapeEventFilter; 67 class EscapeEventFilter;
47 68
48 // Where to snap to.
49 enum SnapType {
50 SNAP_LEFT,
51 SNAP_RIGHT,
52 SNAP_MAXIMIZE,
53 SNAP_MINIMIZE,
54 SNAP_RESTORE,
55 SNAP_NONE
56 };
57
58 // Initializes the snap-gesture based on the event. This should only be called 69 // Initializes the snap-gesture based on the event. This should only be called
59 // when the event is confirmed to have started a snap gesture. 70 // when the event is confirmed to have started a snap gesture.
60 void ProcessStartEvent(const views::LocatedEvent& event); 71 void ProcessStartEvent(const views::LocatedEvent& event);
61 72
62 // Updates the snap-state based on the current event. This should only be 73 // Updates the snap-state based on the current event. This should only be
63 // called after the snap gesture has already started. 74 // called after the snap gesture has already started.
64 void ProcessUpdateEvent(const views::LocatedEvent& event); 75 void ProcessUpdateEvent(const views::LocatedEvent& event);
65 76
66 // Returns true if the window was snapped. Returns false otherwise. 77 // Returns true if the window was snapped. Returns false otherwise.
67 bool ProcessEndEvent(const views::LocatedEvent& event); 78 bool ProcessEndEvent(const views::LocatedEvent& event);
68 79
69 // Cancels snap behavior. 80 // Cancels snap behavior.
70 void Cancel(); 81 void Cancel(bool keep_menu_open);
sky 2012/08/03 19:42:00 Document |keep_menu_open|
Mr4D (OOO till 08-26) 2012/08/03 20:39:28 Done.
71 82
72 // Installs/uninstalls an EventFilter to track when escape is pressed. 83 // Installs/uninstalls an EventFilter to track when escape is pressed.
73 void InstallEventFilter(); 84 void InstallEventFilter();
74 void UninstallEventFilter(); 85 void UninstallEventFilter();
75 86
76 // Updates the snap position from the event location. This is invoked by 87 // Updates the snap position from the event location. This is invoked by
77 // |update_timer_|. 88 // |update_timer_|.
78 void UpdateSnapFromEventLocation(); 89 void UpdateSnapFromEventLocation();
79 90
80 // Updates |snap_type_| based on a mouse drag. 91 // Updates |snap_type_| based on a mouse drag.
81 void UpdateSnap(const gfx::Point& location); 92 void UpdateSnap(const gfx::Point& location);
82 93
83 // Returns the type of snap based on the specified location. 94 // Returns the type of snap based on the specified location.
84 SnapType SnapTypeForLocation(const gfx::Point& location) const; 95 workspace::SnapType SnapTypeForLocation(const gfx::Point& location) const;
85 96
86 // Returns the bounds of the resulting window for the specified type. 97 // Returns the bounds of the resulting window for the specified type.
87 gfx::Rect ScreenBoundsForType(SnapType type) const; 98 gfx::Rect ScreenBoundsForType(workspace::SnapType type) const;
88 99
89 // Converts location to screen coordinates and returns it. These are the 100 // Converts location to screen coordinates and returns it. These are the
90 // coordinates used by the SnapSizer. 101 // coordinates used by the SnapSizer.
91 gfx::Point LocationForSnapSizer(const gfx::Point& location) const; 102 gfx::Point LocationForSnapSizer(const gfx::Point& location) const;
92 103
93 // Snaps the window to the current snap position. 104 // Snaps the window to the current snap position.
94 void Snap(); 105 void Snap();
95 106
96 // Frame that the maximize button acts on. 107 // Frame that the maximize button acts on.
97 views::NonClientFrameView* frame_; 108 views::NonClientFrameView* frame_;
98 109
99 // Renders the snap position. 110 // Renders the snap position.
100 scoped_ptr<internal::PhantomWindowController> phantom_window_; 111 scoped_ptr<internal::PhantomWindowController> phantom_window_;
101 112
102 // Is snapping enabled? Set on press so that in drag we know whether we 113 // Is snapping enabled? Set on press so that in drag we know whether we
103 // should show the snap locations. 114 // should show the snap locations.
104 bool is_snap_enabled_; 115 bool is_snap_enabled_;
105 116
106 // Did the user drag far enough to trigger snapping? 117 // Did the user drag far enough to trigger snapping?
107 bool exceeded_drag_threshold_; 118 bool exceeded_drag_threshold_;
108 119
120 // This is the window_ we are contained in.
sky 2012/08/03 19:42:00 window_ -> Window
Mr4D (OOO till 08-26) 2012/08/03 20:39:28 Done.
121 aura::Window* window_;
122
109 // Location of the press. 123 // Location of the press.
110 gfx::Point press_location_; 124 gfx::Point press_location_;
111 125
112 // Current snap type. 126 // Current snap type.
113 SnapType snap_type_; 127 workspace::SnapType snap_type_;
114 128
115 scoped_ptr<internal::SnapSizer> snap_sizer_; 129 scoped_ptr<internal::SnapSizer> snap_sizer_;
116 130
117 scoped_ptr<EscapeEventFilter> escape_event_filter_; 131 scoped_ptr<EscapeEventFilter> escape_event_filter_;
118 132
119 base::OneShotTimer<FrameMaximizeButton> update_timer_; 133 base::OneShotTimer<FrameMaximizeButton> update_timer_;
120 134
135 scoped_ptr<MaximizeBubbleController> maximizer_;
136
121 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); 137 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton);
122 }; 138 };
123 139
124 } // namespace ash 140 } // namespace ash
125 141
126 #endif // ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ 142 #endif // ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698