Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/snap_sizer.h" | 5 #include "ash/wm/workspace/snap_sizer.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "ash/ash_switches.h" | |
| 9 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
| 10 #include "ash/wm/property_util.h" | 11 #include "ash/wm/property_util.h" |
| 11 #include "ash/wm/window_resizer.h" | 12 #include "ash/wm/window_resizer.h" |
| 12 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 14 #include "ui/aura/window_delegate.h" | 15 #include "ui/aura/window_delegate.h" |
| 15 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
| 16 | 17 |
| 17 namespace ash { | 18 namespace ash { |
| 18 namespace internal { | 19 namespace internal { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 int GetMaxWidth(aura::Window* window) { | 56 int GetMaxWidth(aura::Window* window) { |
| 56 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window)); | 57 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window)); |
| 57 return std::max(work_area.width() * kMaximumScreenPercent / 100, | 58 return std::max(work_area.width() * kMaximumScreenPercent / 100, |
| 58 GetMinWidth(window)); | 59 GetMinWidth(window)); |
| 59 } | 60 } |
| 60 | 61 |
| 61 // Returns the width that |window| should be snapped to if resizing is disabled | 62 // Returns the width that |window| should be snapped to if resizing is disabled |
| 62 // in the SnapSizer. | 63 // in the SnapSizer. |
| 63 int GetDefaultWidth(aura::Window* window) { | 64 int GetDefaultWidth(aura::Window* window) { |
| 64 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window)); | 65 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window)); |
| 65 int width = std::max(kDefaultWidthSmallScreen, work_area.width() / 2); | 66 |
| 67 int width = 0; | |
| 68 if (ash::switches::UseAlternateFrameCaptionButtonStyle()) { | |
| 69 // Only the 'half of screen' width is supported when using the alternate | |
| 70 // visual style for the frame caption buttons (minimize, maximize, restore, | |
| 71 // and close). | |
| 72 width = work_area.width() / 2; | |
| 73 } else { | |
| 74 width = std::max(kDefaultWidthSmallScreen, work_area.width() / 2); | |
| 75 } | |
| 66 | 76 |
| 67 width = std::min(width, GetMaxWidth(window)); | 77 width = std::min(width, GetMaxWidth(window)); |
| 68 return std::max(width, GetMinWidth(window)); | 78 return std::max(width, GetMinWidth(window)); |
| 69 } | 79 } |
| 70 | 80 |
| 71 // Create the list of possible widths for the current screen configuration: | 81 // Create the list of possible widths for the current screen configuration: |
| 72 // Fill the |usable_width_| list with items from |kIdealWidth| which fit on | 82 // Fill the |usable_width_| list with items from |kIdealWidth| which fit on |
| 73 // the screen and supplement it with the 'half of screen' size. Furthermore, | 83 // the screen and supplement it with the 'half of screen' size. Furthermore, |
| 74 // add an entry for 90% of the screen size if it is smaller than the biggest | 84 // add an entry for 90% of the screen size if it is smaller than the biggest |
| 75 // value in the |kIdealWidth| list (to get a step between the values). | 85 // value in the |kIdealWidth| list (to get a step between the values). |
| 76 std::vector<int> BuildIdealWidthList(aura::Window* window) { | 86 std::vector<int> BuildIdealWidthList(aura::Window* window) { |
| 87 if (ash::switches::UseAlternateFrameCaptionButtonStyle()) { | |
| 88 // Only the 'half of screen' width is supported when using the alternate | |
| 89 // visual style for the frame caption buttons (minimize, maximize, | |
| 90 // restore, and close). | |
|
varkha
2013/09/09 15:47:55
nit: Instead of repeating the comment maybe just r
pkotwicz
2013/09/10 18:22:32
I do not think that this comment is long enough (a
| |
| 91 return std::vector<int>(1u, GetDefaultWidth(window)); | |
| 92 } | |
| 93 | |
| 77 int minimum_width = GetMinWidth(window); | 94 int minimum_width = GetMinWidth(window); |
| 78 int maximum_width = GetMaxWidth(window); | 95 int maximum_width = GetMaxWidth(window); |
| 79 | 96 |
| 80 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window)); | 97 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window)); |
| 81 int half_width = work_area.width() / 2; | 98 int half_width = work_area.width() / 2; |
| 82 if (half_width < minimum_width || half_width > maximum_width) | 99 if (half_width < minimum_width || half_width > maximum_width) |
| 83 half_width = 0; | 100 half_width = 0; |
| 84 | 101 |
| 85 std::vector<int> ideal_width_list; | 102 std::vector<int> ideal_width_list; |
| 86 for (size_t i = 0; i < arraysize(kIdealWidth); i++) { | 103 for (size_t i = 0; i < arraysize(kIdealWidth); i++) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 return GetTargetBoundsForSize(size_index_); | 272 return GetTargetBoundsForSize(size_index_); |
| 256 } | 273 } |
| 257 | 274 |
| 258 bool SnapSizer::AlongEdge(int x) const { | 275 bool SnapSizer::AlongEdge(int x) const { |
| 259 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window_)); | 276 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window_)); |
| 260 return (x <= area.x()) || (x >= area.right() - 1); | 277 return (x <= area.x()) || (x >= area.right() - 1); |
| 261 } | 278 } |
| 262 | 279 |
| 263 } // namespace internal | 280 } // namespace internal |
| 264 } // namespace ash | 281 } // namespace ash |
| OLD | NEW |