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

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: Fixed merging issues 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 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/views/controls/button/image_button.h" 11 #include "ui/views/controls/button/image_button.h"
12 12
13 namespace views { 13 namespace views {
14 class NonClientFrameView; 14 class NonClientFrameView;
15 } 15 }
16 16
17 namespace ash { 17 namespace ash {
18 18
19 namespace internal { 19 namespace internal {
20 class PhantomWindowController; 20 class PhantomWindowController;
21 class SnapSizer; 21 class SnapSizer;
22 } 22 }
23 23
24 class MaximizeBubble;
25
24 // Button used for the maximize control on the frame. Handles snapping logic. 26 // Button used for the maximize control on the frame. Handles snapping logic.
25 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton { 27 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton {
26 public: 28 public:
29 // Where to snap to.
30 enum SnapType {
31 SNAP_LEFT,
32 SNAP_RIGHT,
33 SNAP_MAXIMIZE,
34 SNAP_MINIMIZE,
35 SNAP_RESTORE,
36 SNAP_NONE
37 };
38
27 FrameMaximizeButton(views::ButtonListener* listener, 39 FrameMaximizeButton(views::ButtonListener* listener,
28 views::NonClientFrameView* frame); 40 views::NonClientFrameView* frame);
29 virtual ~FrameMaximizeButton(); 41 virtual ~FrameMaximizeButton();
30 42
31 // ImageButton overrides: 43 // ImageButton overrides:
32 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; 44 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
33 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; 45 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
34 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; 46 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
35 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; 47 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
36 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; 48 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
37 virtual void OnMouseCaptureLost() OVERRIDE; 49 virtual void OnMouseCaptureLost() OVERRIDE;
38 virtual ui::GestureStatus OnGestureEvent( 50 virtual ui::GestureStatus OnGestureEvent(
39 const views::GestureEvent& event) OVERRIDE; 51 const views::GestureEvent& event) OVERRIDE;
40 52
53 // Updates |snap_type_| based on a a given snap type. This is used by
54 // external hover events from the button menu.
55 void SnapButtonHovered(SnapType type);
56
57 // The user clicked the |type| button.
58 void SnapButtonClicked(SnapType type);
59
60 // The menu should reflect the user selected type.
61 void UpdateVisibleMenu(SnapType type);
62
63 // Remove the maximize menu from the screen (and destroy it).
64 void DestroyMaximizeMenu();
65
66 // Returns true when the user clicks and drags the button.
67 bool is_snap_enabled() { return is_snap_enabled_; }
68
41 protected: 69 protected:
42 // ImageButton overrides: 70 // ImageButton overrides:
43 virtual gfx::ImageSkia GetImageToPaint() OVERRIDE; 71 virtual gfx::ImageSkia GetImageToPaint() OVERRIDE;
44 72
45 private: 73 private:
46 class EscapeEventFilter; 74 class EscapeEventFilter;
47 75
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 76 // 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. 77 // when the event is confirmed to have started a snap gesture.
60 void ProcessStartEvent(const views::LocatedEvent& event); 78 void ProcessStartEvent(const views::LocatedEvent& event);
61 79
62 // Updates the snap-state based on the current event. This should only be 80 // Updates the snap-state based on the current event. This should only be
63 // called after the snap gesture has already started. 81 // called after the snap gesture has already started.
64 void ProcessUpdateEvent(const views::LocatedEvent& event); 82 void ProcessUpdateEvent(const views::LocatedEvent& event);
65 83
66 // Returns true if the window was snapped. Returns false otherwise. 84 // Returns true if the window was snapped. Returns false otherwise.
67 bool ProcessEndEvent(const views::LocatedEvent& event); 85 bool ProcessEndEvent(const views::LocatedEvent& event);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 129
112 // Current snap type. 130 // Current snap type.
113 SnapType snap_type_; 131 SnapType snap_type_;
114 132
115 scoped_ptr<internal::SnapSizer> snap_sizer_; 133 scoped_ptr<internal::SnapSizer> snap_sizer_;
116 134
117 scoped_ptr<EscapeEventFilter> escape_event_filter_; 135 scoped_ptr<EscapeEventFilter> escape_event_filter_;
118 136
119 base::OneShotTimer<FrameMaximizeButton> update_timer_; 137 base::OneShotTimer<FrameMaximizeButton> update_timer_;
120 138
139 scoped_ptr<MaximizeBubble> maximizer_;
140
121 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); 141 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton);
122 }; 142 };
123 143
124 } // namespace ash 144 } // namespace ash
125 145
126 #endif // ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_ 146 #endif // ASH_WM_WORKSPACE_FRAME_MAXIMIZE_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698