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

Side by Side Diff: ash/wm/workspace/frame_maximize_button.cc

Issue 9956063: Merge 130064 - Changes the maximize button to only minimize for panels. This resulted (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: Created 8 years, 8 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
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 #include "ash/wm/workspace/frame_maximize_button.h" 5 #include "ash/wm/workspace/frame_maximize_button.h"
6 6
7 #include "ash/screen_ash.h" 7 #include "ash/screen_ash.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/wm/property_util.h" 9 #include "ash/wm/property_util.h"
10 #include "ash/launcher/launcher.h" 10 #include "ash/launcher/launcher.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return ui::GESTURE_STATUS_UNKNOWN; 89 return ui::GESTURE_STATUS_UNKNOWN;
90 } 90 }
91 91
92 // FrameMaximizeButton --------------------------------------------------------- 92 // FrameMaximizeButton ---------------------------------------------------------
93 93
94 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener, 94 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener,
95 views::NonClientFrameView* frame) 95 views::NonClientFrameView* frame)
96 : ImageButton(listener), 96 : ImageButton(listener),
97 frame_(frame), 97 frame_(frame),
98 is_snap_enabled_(false), 98 is_snap_enabled_(false),
99 is_left_right_enabled_(true),
100 is_maximize_enabled_(true),
101 exceeded_drag_threshold_(false), 99 exceeded_drag_threshold_(false),
102 snap_type_(SNAP_NONE) { 100 snap_type_(SNAP_NONE) {
103 // TODO(sky): nuke this. It's temporary while we don't have good images. 101 // TODO(sky): nuke this. It's temporary while we don't have good images.
104 SetImageAlignment(ALIGN_LEFT, ALIGN_BOTTOM); 102 SetImageAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
105 SetTooltipText(l10n_util::GetStringUTF16(IDS_FRAME_MAXIMIZE_BUTTON_TOOLTIP)); 103 SetTooltipText(l10n_util::GetStringUTF16(IDS_FRAME_MAXIMIZE_BUTTON_TOOLTIP));
106 } 104 }
107 105
108 FrameMaximizeButton::~FrameMaximizeButton() { 106 FrameMaximizeButton::~FrameMaximizeButton() {
109 } 107 }
110 108
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } else { 155 } else {
158 ImageButton::OnMouseReleased(event); 156 ImageButton::OnMouseReleased(event);
159 } 157 }
160 } 158 }
161 159
162 void FrameMaximizeButton::OnMouseCaptureLost() { 160 void FrameMaximizeButton::OnMouseCaptureLost() {
163 Cancel(); 161 Cancel();
164 ImageButton::OnMouseCaptureLost(); 162 ImageButton::OnMouseCaptureLost();
165 } 163 }
166 164
167 void FrameMaximizeButton::SetIsLeftRightEnabled(bool e) {
168 is_left_right_enabled_ = e;
169 int id = is_left_right_enabled_ ?
170 IDS_FRAME_MAXIMIZE_BUTTON_TOOLTIP :
171 IDS_FRAME_MAXIMIZE_BUTTON_NO_SIDE_SNAP_TOOLTIP;
172 SetTooltipText(l10n_util::GetStringUTF16(id));
173 }
174
175 SkBitmap FrameMaximizeButton::GetImageToPaint() { 165 SkBitmap FrameMaximizeButton::GetImageToPaint() {
176 if (is_snap_enabled_) { 166 if (is_snap_enabled_) {
177 int id = 0; 167 int id = 0;
178 if (frame_->GetWidget()->IsMaximized()) { 168 if (frame_->GetWidget()->IsMaximized()) {
179 switch (snap_type_) { 169 switch (snap_type_) {
180 case SNAP_LEFT: 170 case SNAP_LEFT:
181 id = IDR_AURA_WINDOW_MAXIMIZED_RESTORE_SNAP_LEFT_P; 171 id = IDR_AURA_WINDOW_MAXIMIZED_RESTORE_SNAP_LEFT_P;
182 break; 172 break;
183 case SNAP_RIGHT: 173 case SNAP_RIGHT:
184 id = IDR_AURA_WINDOW_MAXIMIZED_RESTORE_SNAP_RIGHT_P; 174 id = IDR_AURA_WINDOW_MAXIMIZED_RESTORE_SNAP_RIGHT_P;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 LocationForSnapSizer(location), 256 LocationForSnapSizer(location),
267 snap_edge, grid_size)); 257 snap_edge, grid_size));
268 } 258 }
269 if (!phantom_window_.get()) { 259 if (!phantom_window_.get()) {
270 phantom_window_.reset(new internal::PhantomWindowController( 260 phantom_window_.reset(new internal::PhantomWindowController(
271 frame_->GetWidget()->GetNativeWindow())); 261 frame_->GetWidget()->GetNativeWindow()));
272 } 262 }
273 phantom_window_->Show(BoundsForType(snap_type_)); 263 phantom_window_->Show(BoundsForType(snap_type_));
274 } 264 }
275 265
276 bool FrameMaximizeButton::AllowMaximize() const {
277 return !frame_->GetWidget()->IsMaximized() && is_maximize_enabled_;
278 }
279
280 FrameMaximizeButton::SnapType FrameMaximizeButton::SnapTypeForLocation( 266 FrameMaximizeButton::SnapType FrameMaximizeButton::SnapTypeForLocation(
281 const gfx::Point& location) const { 267 const gfx::Point& location) const {
282 int delta_x = location.x() - press_location_.x(); 268 int delta_x = location.x() - press_location_.x();
283 int delta_y = location.y() - press_location_.y(); 269 int delta_y = location.y() - press_location_.y();
284 if (!views::View::ExceededDragThreshold(delta_x, delta_y)) 270 if (!views::View::ExceededDragThreshold(delta_x, delta_y))
285 return AllowMaximize() ? SNAP_MAXIMIZE : SNAP_NONE; 271 return !frame_->GetWidget()->IsMaximized() ? SNAP_MAXIMIZE : SNAP_RESTORE;
286 else if (delta_x < 0 && delta_y > delta_x && delta_y < -delta_x) 272 else if (delta_x < 0 && delta_y > delta_x && delta_y < -delta_x)
287 return is_left_right_enabled_ ? SNAP_LEFT : SNAP_NONE; 273 return SNAP_LEFT;
288 else if (delta_x > 0 && delta_y > -delta_x && delta_y < delta_x) 274 else if (delta_x > 0 && delta_y > -delta_x && delta_y < delta_x)
289 return is_left_right_enabled_ ? SNAP_RIGHT : SNAP_NONE; 275 return SNAP_RIGHT;
290 else if (delta_y > 0) 276 else if (delta_y > 0)
291 return SNAP_MINIMIZE; 277 return SNAP_MINIMIZE;
292 else if (AllowMaximize()) 278 return !frame_->GetWidget()->IsMaximized() ? SNAP_MAXIMIZE : SNAP_RESTORE;
293 return SNAP_MAXIMIZE;
294 return SNAP_NONE;
295 } 279 }
296 280
297 gfx::Rect FrameMaximizeButton::BoundsForType(SnapType type) const { 281 gfx::Rect FrameMaximizeButton::BoundsForType(SnapType type) const {
298 aura::Window* window = frame_->GetWidget()->GetNativeWindow(); 282 aura::Window* window = frame_->GetWidget()->GetNativeWindow();
299 switch (type) { 283 switch (type) {
300 case SNAP_LEFT: 284 case SNAP_LEFT:
301 case SNAP_RIGHT: 285 case SNAP_RIGHT:
302 return snap_sizer_->target_bounds(); 286 return snap_sizer_->target_bounds();
303 case SNAP_MAXIMIZE: 287 case SNAP_MAXIMIZE:
304 return ScreenAsh::GetMaximizedWindowBounds(window); 288 return ScreenAsh::GetMaximizedWindowBounds(window);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 break; 327 break;
344 case SNAP_MINIMIZE: 328 case SNAP_MINIMIZE:
345 frame_->GetWidget()->Minimize(); 329 frame_->GetWidget()->Minimize();
346 break; 330 break;
347 default: 331 default:
348 NOTREACHED(); 332 NOTREACHED();
349 } 333 }
350 } 334 }
351 335
352 } // namespace ash 336 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/frame_maximize_button.h ('k') | chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698