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

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: Removed radial 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 "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/timer.h" 10 #include "base/timer.h"
11 #include "ui/aura/window_observer.h"
11 #include "ui/views/controls/button/image_button.h" 12 #include "ui/views/controls/button/image_button.h"
12 13
13 namespace views { 14 namespace views {
14 class NonClientFrameView; 15 class NonClientFrameView;
15 } 16 }
16 17
17 namespace ash { 18 namespace ash {
18 19
19 namespace internal { 20 namespace internal {
20 class PhantomWindowController; 21 class PhantomWindowController;
21 class SnapSizer; 22 class SnapSizer;
22 } 23 }
23 24
25 class MaximizeBubbleController;
26
24 // Button used for the maximize control on the frame. Handles snapping logic. 27 // Button used for the maximize control on the frame. Handles snapping logic.
25 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { 28 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton,
29 public aura::WindowObserver {
26 public: 30 public:
31 // Where to snap to.
32 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.
33 SNAP_LEFT,
34 SNAP_RIGHT,
35 SNAP_MAXIMIZE,
36 SNAP_MINIMIZE,
37 SNAP_RESTORE,
38 SNAP_NONE
39 };
40
27 FrameMaximizeButton(views::ButtonListener* listener, 41 FrameMaximizeButton(views::ButtonListener* listener,
28 views::NonClientFrameView* frame); 42 views::NonClientFrameView* frame);
29 virtual ~FrameMaximizeButton(); 43 virtual ~FrameMaximizeButton();
30 44
45 // WindowObserver overrides:
46 virtual void OnWindowBoundsChanged(aura::Window* window,
47 const gfx::Rect& old_bounds,
48 const gfx::Rect& new_bounds) OVERRIDE;
49 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
50
31 // ImageButton overrides: 51 // ImageButton overrides:
32 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; 52 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
33 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; 53 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
34 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; 54 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
35 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; 55 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
36 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; 56 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
37 virtual void OnMouseCaptureLost() OVERRIDE; 57 virtual void OnMouseCaptureLost() OVERRIDE;
38 virtual ui::GestureStatus OnGestureEvent( 58 virtual ui::GestureStatus OnGestureEvent(
39 const views::GestureEvent& event) OVERRIDE; 59 const views::GestureEvent& event) OVERRIDE;
40 60
61 // Updates |snap_type_| based on a a given snap type. This is used by
62 // external hover events from the button menu.
63 void SnapButtonHovered(SnapType type);
64
65 // The user clicked the |type| button and the action needs to be performed,
66 // which will at the same time close the window.
67 void ExecuteSnapAndCloseMenu(SnapType type);
68
69 // The menu should reflect the user selected type.
70 void UpdateVisibleMenu(SnapType type);
71
72 // Remove the maximize menu from the screen (and destroy it).
73 void DestroyMaximizeMenu();
74
75 // Returns true when the user clicks and drags the button.
76 bool is_snap_enabled() { return is_snap_enabled_; }
77
41 protected: 78 protected:
42 // ImageButton overrides: 79 // ImageButton overrides:
43 virtual gfx::ImageSkia GetImageToPaint() OVERRIDE; 80 virtual gfx::ImageSkia GetImageToPaint() OVERRIDE;
44 81
45 private: 82 private:
46 class EscapeEventFilter; 83 class EscapeEventFilter;
47 84
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 85 // 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. 86 // when the event is confirmed to have started a snap gesture.
60 void ProcessStartEvent(const views::LocatedEvent& event); 87 void ProcessStartEvent(const views::LocatedEvent& event);
61 88
62 // Updates the snap-state based on the current event. This should only be 89 // Updates the snap-state based on the current event. This should only be
63 // called after the snap gesture has already started. 90 // called after the snap gesture has already started.
64 void ProcessUpdateEvent(const views::LocatedEvent& event); 91 void ProcessUpdateEvent(const views::LocatedEvent& event);
65 92
66 // Returns true if the window was snapped. Returns false otherwise. 93 // Returns true if the window was snapped. Returns false otherwise.
67 bool ProcessEndEvent(const views::LocatedEvent& event); 94 bool ProcessEndEvent(const views::LocatedEvent& event);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Renders the snap position. 126 // Renders the snap position.
100 scoped_ptr<internal::PhantomWindowController> phantom_window_; 127 scoped_ptr<internal::PhantomWindowController> phantom_window_;
101 128
102 // Is snapping enabled? Set on press so that in drag we know whether we 129 // Is snapping enabled? Set on press so that in drag we know whether we
103 // should show the snap locations. 130 // should show the snap locations.
104 bool is_snap_enabled_; 131 bool is_snap_enabled_;
105 132
106 // Did the user drag far enough to trigger snapping? 133 // Did the user drag far enough to trigger snapping?
107 bool exceeded_drag_threshold_; 134 bool exceeded_drag_threshold_;
108 135
136 // This is the window_ we are contained in.
137 aura::Window* window_;
138
109 // Location of the press. 139 // Location of the press.
110 gfx::Point press_location_; 140 gfx::Point press_location_;
111 141
112 // Current snap type. 142 // Current snap type.
113 SnapType snap_type_; 143 SnapType snap_type_;
114 144
115 scoped_ptr<internal::SnapSizer> snap_sizer_; 145 scoped_ptr<internal::SnapSizer> snap_sizer_;
116 146
117 scoped_ptr<EscapeEventFilter> escape_event_filter_; 147 scoped_ptr<EscapeEventFilter> escape_event_filter_;
118 148
119 base::OneShotTimer<FrameMaximizeButton> update_timer_; 149 base::OneShotTimer<FrameMaximizeButton> update_timer_;
120 150
151 scoped_ptr<MaximizeBubbleController> maximizer_;
152
121 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); 153 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton);
122 }; 154 };
123 155
124 } // namespace ash 156 } // namespace ash
125 157
126 #endif // ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ 158 #endif // ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698