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

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

Issue 9958039: Changes the maximize button to only minimize for panels. This resulted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Spelling 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return ui::GESTURE_STATUS_UNKNOWN; 96 return ui::GESTURE_STATUS_UNKNOWN;
97 } 97 }
98 98
99 // FrameMaximizeButton --------------------------------------------------------- 99 // FrameMaximizeButton ---------------------------------------------------------
100 100
101 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener, 101 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener,
102 views::NonClientFrameView* frame) 102 views::NonClientFrameView* frame)
103 : ImageButton(listener), 103 : ImageButton(listener),
104 frame_(frame), 104 frame_(frame),
105 is_snap_enabled_(false), 105 is_snap_enabled_(false),
106 is_left_right_enabled_(true),
107 is_maximize_enabled_(true),
108 exceeded_drag_threshold_(false), 106 exceeded_drag_threshold_(false),
109 snap_type_(SNAP_NONE) { 107 snap_type_(SNAP_NONE) {
110 // TODO(sky): nuke this. It's temporary while we don't have good images. 108 // TODO(sky): nuke this. It's temporary while we don't have good images.
111 SetImageAlignment(ALIGN_LEFT, ALIGN_BOTTOM); 109 SetImageAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
112 SetTooltipText(l10n_util::GetStringUTF16(IDS_FRAME_MAXIMIZE_BUTTON_TOOLTIP)); 110 SetTooltipText(l10n_util::GetStringUTF16(IDS_FRAME_MAXIMIZE_BUTTON_TOOLTIP));
113 } 111 }
114 112
115 FrameMaximizeButton::~FrameMaximizeButton() { 113 FrameMaximizeButton::~FrameMaximizeButton() {
116 } 114 }
117 115
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } else { 167 } else {
170 ImageButton::OnMouseReleased(event); 168 ImageButton::OnMouseReleased(event);
171 } 169 }
172 } 170 }
173 171
174 void FrameMaximizeButton::OnMouseCaptureLost() { 172 void FrameMaximizeButton::OnMouseCaptureLost() {
175 Cancel(); 173 Cancel();
176 ImageButton::OnMouseCaptureLost(); 174 ImageButton::OnMouseCaptureLost();
177 } 175 }
178 176
179 void FrameMaximizeButton::SetIsLeftRightEnabled(bool e) {
180 is_left_right_enabled_ = e;
181 int id = is_left_right_enabled_ ?
182 IDS_FRAME_MAXIMIZE_BUTTON_TOOLTIP :
183 IDS_FRAME_MAXIMIZE_BUTTON_NO_SIDE_SNAP_TOOLTIP;
184 SetTooltipText(l10n_util::GetStringUTF16(id));
185 }
186
187 SkBitmap FrameMaximizeButton::GetImageToPaint() { 177 SkBitmap FrameMaximizeButton::GetImageToPaint() {
188 if (is_snap_enabled_) { 178 if (is_snap_enabled_) {
189 int id = 0; 179 int id = 0;
190 if (frame_->GetWidget()->IsMaximized()) { 180 if (frame_->GetWidget()->IsMaximized()) {
191 switch (snap_type_) { 181 switch (snap_type_) {
192 case SNAP_LEFT: 182 case SNAP_LEFT:
193 id = IDR_AURA_WINDOW_MAXIMIZED_RESTORE_SNAP_LEFT_P; 183 id = IDR_AURA_WINDOW_MAXIMIZED_RESTORE_SNAP_LEFT_P;
194 break; 184 break;
195 case SNAP_RIGHT: 185 case SNAP_RIGHT:
196 id = IDR_AURA_WINDOW_MAXIMIZED_RESTORE_SNAP_RIGHT_P; 186 id = IDR_AURA_WINDOW_MAXIMIZED_RESTORE_SNAP_RIGHT_P;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 LocationForSnapSizer(location), 281 LocationForSnapSizer(location),
292 snap_edge, grid_size)); 282 snap_edge, grid_size));
293 } 283 }
294 if (!phantom_window_.get()) { 284 if (!phantom_window_.get()) {
295 phantom_window_.reset(new internal::PhantomWindowController( 285 phantom_window_.reset(new internal::PhantomWindowController(
296 frame_->GetWidget()->GetNativeWindow())); 286 frame_->GetWidget()->GetNativeWindow()));
297 } 287 }
298 phantom_window_->Show(BoundsForType(snap_type_)); 288 phantom_window_->Show(BoundsForType(snap_type_));
299 } 289 }
300 290
301 bool FrameMaximizeButton::AllowMaximize() const {
302 return !frame_->GetWidget()->IsMaximized() && is_maximize_enabled_;
303 }
304
305 FrameMaximizeButton::SnapType FrameMaximizeButton::SnapTypeForLocation( 291 FrameMaximizeButton::SnapType FrameMaximizeButton::SnapTypeForLocation(
306 const gfx::Point& location) const { 292 const gfx::Point& location) const {
307 int delta_x = location.x() - press_location_.x(); 293 int delta_x = location.x() - press_location_.x();
308 int delta_y = location.y() - press_location_.y(); 294 int delta_y = location.y() - press_location_.y();
309 if (!views::View::ExceededDragThreshold(delta_x, delta_y)) 295 if (!views::View::ExceededDragThreshold(delta_x, delta_y))
310 return AllowMaximize() ? SNAP_MAXIMIZE : SNAP_RESTORE; 296 return !frame_->GetWidget()->IsMaximized() ? SNAP_MAXIMIZE : SNAP_RESTORE;
311 else if (delta_x < 0 && delta_y > delta_x && delta_y < -delta_x) 297 else if (delta_x < 0 && delta_y > delta_x && delta_y < -delta_x)
312 return is_left_right_enabled_ ? SNAP_LEFT : SNAP_NONE; 298 return SNAP_LEFT;
313 else if (delta_x > 0 && delta_y > -delta_x && delta_y < delta_x) 299 else if (delta_x > 0 && delta_y > -delta_x && delta_y < delta_x)
314 return is_left_right_enabled_ ? SNAP_RIGHT : SNAP_NONE; 300 return SNAP_RIGHT;
315 else if (delta_y > 0) 301 else if (delta_y > 0)
316 return SNAP_MINIMIZE; 302 return SNAP_MINIMIZE;
317 return AllowMaximize() ? SNAP_MAXIMIZE : SNAP_RESTORE; 303 return !frame_->GetWidget()->IsMaximized() ? SNAP_MAXIMIZE : SNAP_RESTORE;
318 } 304 }
319 305
320 gfx::Rect FrameMaximizeButton::BoundsForType(SnapType type) const { 306 gfx::Rect FrameMaximizeButton::BoundsForType(SnapType type) const {
321 aura::Window* window = frame_->GetWidget()->GetNativeWindow(); 307 aura::Window* window = frame_->GetWidget()->GetNativeWindow();
322 switch (type) { 308 switch (type) {
323 case SNAP_LEFT: 309 case SNAP_LEFT:
324 case SNAP_RIGHT: 310 case SNAP_RIGHT:
325 return snap_sizer_->target_bounds(); 311 return snap_sizer_->target_bounds();
326 case SNAP_MAXIMIZE: 312 case SNAP_MAXIMIZE:
327 return ScreenAsh::GetMaximizedWindowBounds(window); 313 return ScreenAsh::GetMaximizedWindowBounds(window);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 break; 359 break;
374 case SNAP_RESTORE: 360 case SNAP_RESTORE:
375 frame_->GetWidget()->Restore(); 361 frame_->GetWidget()->Restore();
376 break; 362 break;
377 case SNAP_NONE: 363 case SNAP_NONE:
378 NOTREACHED(); 364 NOTREACHED();
379 } 365 }
380 } 366 }
381 367
382 } // namespace ash 368 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698