| 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 "ui/app_list/page_switcher.h" | 5 #include "ui/app_list/page_switcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "third_party/skia/include/core/SkPath.h" | 9 #include "third_party/skia/include/core/SkPath.h" |
| 10 #include "ui/app_list/pagination_model.h" | 10 #include "ui/app_list/pagination_model.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 gfx::Rect rect(GetContentsBounds()); | 182 gfx::Rect rect(GetContentsBounds()); |
| 183 | 183 |
| 184 CalculateButtonWidthAndSpacing(rect.width()); | 184 CalculateButtonWidthAndSpacing(rect.width()); |
| 185 | 185 |
| 186 // Makes |buttons_| horizontally center and vertically fill. | 186 // Makes |buttons_| horizontally center and vertically fill. |
| 187 gfx::Size buttons_size(buttons_->GetPreferredSize()); | 187 gfx::Size buttons_size(buttons_->GetPreferredSize()); |
| 188 gfx::Rect buttons_bounds(rect.CenterPoint().x() - buttons_size.width() / 2, | 188 gfx::Rect buttons_bounds(rect.CenterPoint().x() - buttons_size.width() / 2, |
| 189 rect.y(), | 189 rect.y(), |
| 190 buttons_size.width(), | 190 buttons_size.width(), |
| 191 rect.height()); | 191 rect.height()); |
| 192 rect.Intersect(buttons_bounds); | 192 buttons_->SetBoundsRect(gfx::Intersection(rect, buttons_bounds)); |
| 193 buttons_->SetBoundsRect(rect); | |
| 194 } | 193 } |
| 195 | 194 |
| 196 void PageSwitcher::CalculateButtonWidthAndSpacing(int contents_width) { | 195 void PageSwitcher::CalculateButtonWidthAndSpacing(int contents_width) { |
| 197 const int button_count = buttons_->child_count(); | 196 const int button_count = buttons_->child_count(); |
| 198 if (!button_count) | 197 if (!button_count) |
| 199 return; | 198 return; |
| 200 | 199 |
| 201 contents_width -= 2 * kButtonStripPadding; | 200 contents_width -= 2 * kButtonStripPadding; |
| 202 | 201 |
| 203 int button_width = kMinButtonWidth; | 202 int button_width = kMinButtonWidth; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 remaining = -remaining; | 261 remaining = -remaining; |
| 263 progress = -progress; | 262 progress = -progress; |
| 264 } | 263 } |
| 265 | 264 |
| 266 GetButtonByIndex(buttons_, current_page)->SetSelectedRange(remaining); | 265 GetButtonByIndex(buttons_, current_page)->SetSelectedRange(remaining); |
| 267 if (model_->is_valid_page(target_page)) | 266 if (model_->is_valid_page(target_page)) |
| 268 GetButtonByIndex(buttons_, target_page)->SetSelectedRange(progress); | 267 GetButtonByIndex(buttons_, target_page)->SetSelectedRange(progress); |
| 269 } | 268 } |
| 270 | 269 |
| 271 } // namespace app_list | 270 } // namespace app_list |
| OLD | NEW |