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

Side by Side Diff: ash/frame/caption_buttons/frame_maximize_button.h

Issue 263083005: Remove "Alternate frame caption button style" command line flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ASH_FRAME_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_
6 #define ASH_FRAME_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_
7
8 #include "ash/ash_export.h"
9 #include "ash/frame/caption_buttons/caption_button_types.h"
10 #include "ash/frame/caption_buttons/frame_caption_button.h"
11 #include "ash/wm/workspace/snap_types.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h"
14 #include "base/timer/timer.h"
15 #include "ui/aura/window_observer.h"
16 #include "ui/views/widget/widget_observer.h"
17
18 namespace views {
19 class Widget;
20 }
21
22 namespace ash {
23 class FrameMaximizeButtonObserver;
24 class MaximizeBubbleController;
25 class PhantomWindowController;
26
27 // Button used for the maximize control on the frame. Handles snapping logic.
28 class ASH_EXPORT FrameMaximizeButton : public FrameCaptionButton,
29 public views::WidgetObserver,
30 public aura::WindowObserver {
31 public:
32 FrameMaximizeButton(views::ButtonListener* listener,
33 views::Widget* frame);
34 virtual ~FrameMaximizeButton();
35
36 void AddObserver(FrameMaximizeButtonObserver* observer);
37 void RemoveObserver(FrameMaximizeButtonObserver* observer);
38
39 // Updates |snap_type_| based on a a given snap type. This is used by
40 // external hover events from the button menu.
41 void SnapButtonHovered(SnapType type);
42
43 // The user clicked the |type| button and the action needs to be performed,
44 // which will at the same time close the window.
45 void ExecuteSnapAndCloseMenu(SnapType type);
46
47 // Called by the MaximizeBubbleController when the maximize bubble is shown.
48 void OnMaximizeBubbleShown(views::Widget* bubble);
49
50 // Remove the maximize menu from the screen (and destroy it).
51 void DestroyMaximizeMenu();
52
53 // Returns true when the user clicks and drags the button.
54 bool is_snap_enabled() const { return is_snap_enabled_; }
55
56 // WindowObserver overrides:
57 virtual void OnWindowBoundsChanged(aura::Window* window,
58 const gfx::Rect& old_bounds,
59 const gfx::Rect& new_bounds) OVERRIDE;
60 virtual void OnWindowPropertyChanged(aura::Window* window,
61 const void* key,
62 intptr_t old) OVERRIDE;
63 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
64
65 // WidgetObserver overrides:
66 virtual void OnWidgetActivationChanged(views::Widget* widget,
67 bool active) OVERRIDE;
68
69 // ImageButton overrides:
70 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
71 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
72 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
73 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
74 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
75 virtual void OnMouseCaptureLost() OVERRIDE;
76
77 // ui::EventHandler overrides:
78 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
79
80 // views::View overwrite:
81 virtual void SetVisible(bool visible) OVERRIDE;
82
83 // Unit test overwrite: Change the UI delay used for the bubble show up.
84 void set_bubble_appearance_delay_ms(int bubble_appearance_delay_ms) {
85 bubble_appearance_delay_ms_ = bubble_appearance_delay_ms;
86 }
87
88 // Unit test accessor for the maximize bubble.
89 MaximizeBubbleController* maximizer() { return maximizer_.get(); }
90
91 // Unit test to see if phantom window is open.
92 bool phantom_window_open() { return phantom_window_.get() != NULL; }
93
94 private:
95 class EscapeEventFilter;
96
97 // Initializes the snap-gesture based on the event. This should only be called
98 // when the event is confirmed to have started a snap gesture.
99 void ProcessStartEvent(const ui::LocatedEvent& event);
100
101 // Updates the snap-state based on the current event. This should only be
102 // called after the snap gesture has already started.
103 void ProcessUpdateEvent(const ui::LocatedEvent& event);
104
105 // Returns true if the window was snapped. Returns false otherwise.
106 bool ProcessEndEvent(const ui::LocatedEvent& event);
107
108 // Cancels snap behavior. If |keep_menu_open| is set, a possibly opened
109 // bubble help will remain open.
110 void Cancel(bool keep_menu_open);
111
112 // Installs/uninstalls an EventFilter to track when escape is pressed.
113 void InstallEventFilter();
114 void UninstallEventFilter();
115
116 // Updates the snap position from the event location. This is invoked by
117 // |update_timer_|.
118 void UpdateSnapFromEventLocation();
119
120 // Updates |snap_type_| based on a mouse drag.
121 void UpdateSnap(const gfx::Point& location);
122
123 // Returns the type of snap based on the specified location.
124 SnapType SnapTypeForLocation(const gfx::Point& location) const;
125
126 // Returns the bounds of the resulting window for the specified type.
127 gfx::Rect ScreenBoundsForType(SnapType type) const;
128
129 // Snaps the window to the current snap position determined by |snap_type_|.
130 void Snap();
131
132 // Determine the maximize type of this window.
133 MaximizeBubbleFrameState GetMaximizeBubbleFrameState() const;
134
135 // Widget that the maximize button acts on. This is different than the widget
136 // which contains the button in the case of AppNonClientFrameViewAsh.
137 views::Widget* frame_;
138
139 // True if we have put observers on |frame_|.
140 bool observing_frame_;
141
142 // Renders the snap position.
143 scoped_ptr<PhantomWindowController> phantom_window_;
144
145 // Is snapping enabled? Set on press so that in drag we know whether we
146 // should show the snap locations.
147 bool is_snap_enabled_;
148
149 // Did the user drag far enough to trigger snapping?
150 bool exceeded_drag_threshold_;
151
152 // Location of the press.
153 gfx::Point press_location_;
154
155 // Current snap type.
156 SnapType snap_type_;
157
158 scoped_ptr<EscapeEventFilter> escape_event_filter_;
159
160 base::OneShotTimer<FrameMaximizeButton> update_timer_;
161
162 scoped_ptr<MaximizeBubbleController> maximizer_;
163
164 // The delay of the bubble appearance.
165 int bubble_appearance_delay_ms_;
166
167 ObserverList<FrameMaximizeButtonObserver> observer_list_;
168
169 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton);
170 };
171
172 } // namespace ash
173
174 #endif // ASH_FRAME_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698