| 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 "third_party/skia/include/core/SkPath.h" | 7 #include "third_party/skia/include/core/SkPath.h" |
| 8 #include "ui/app_list/pagination_model.h" | 8 #include "ui/app_list/pagination_model.h" |
| 9 #include "ui/app_list/view_ids.h" |
| 9 #include "ui/base/animation/throb_animation.h" | 10 #include "ui/base/animation/throb_animation.h" |
| 10 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
| 11 #include "ui/views/controls/button/custom_button.h" | 12 #include "ui/views/controls/button/custom_button.h" |
| 12 #include "ui/views/layout/box_layout.h" | 13 #include "ui/views/layout/box_layout.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 const int kButtonSpacing = 10; | 17 const int kButtonSpacing = 10; |
| 17 const int kButtonWidth = 60; | 18 const int kButtonWidth = 60; |
| 18 const int kButtonHeight = 6; | 19 const int kButtonHeight = 6; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return static_cast<PageSwitcherButton*>(buttons->child_at(index)); | 93 return static_cast<PageSwitcherButton*>(buttons->child_at(index)); |
| 93 } | 94 } |
| 94 | 95 |
| 95 } // namespace | 96 } // namespace |
| 96 | 97 |
| 97 namespace app_list { | 98 namespace app_list { |
| 98 | 99 |
| 99 PageSwitcher::PageSwitcher(PaginationModel* model) | 100 PageSwitcher::PageSwitcher(PaginationModel* model) |
| 100 : model_(model), | 101 : model_(model), |
| 101 buttons_(NULL) { | 102 buttons_(NULL) { |
| 103 set_id(VIEW_ID_PAGE_SWITCHER); |
| 104 |
| 102 buttons_ = new views::View; | 105 buttons_ = new views::View; |
| 103 buttons_->SetLayoutManager(new views::BoxLayout( | 106 buttons_->SetLayoutManager(new views::BoxLayout( |
| 104 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing)); | 107 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing)); |
| 105 AddChildView(buttons_); | 108 AddChildView(buttons_); |
| 106 | 109 |
| 107 TotalPagesChanged(); | 110 TotalPagesChanged(); |
| 108 SelectedPageChanged(-1, model->selected_page()); | 111 SelectedPageChanged(-1, model->selected_page()); |
| 109 model_->AddObserver(this); | 112 model_->AddObserver(this); |
| 110 } | 113 } |
| 111 | 114 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 149 } |
| 147 | 150 |
| 148 void PageSwitcher::SelectedPageChanged(int old_selected, int new_selected) { | 151 void PageSwitcher::SelectedPageChanged(int old_selected, int new_selected) { |
| 149 if (old_selected >= 0 && old_selected < buttons_->child_count()) | 152 if (old_selected >= 0 && old_selected < buttons_->child_count()) |
| 150 GetButtonByIndex(buttons_, old_selected)->SetSelected(false); | 153 GetButtonByIndex(buttons_, old_selected)->SetSelected(false); |
| 151 if (new_selected >= 0 && new_selected < buttons_->child_count()) | 154 if (new_selected >= 0 && new_selected < buttons_->child_count()) |
| 152 GetButtonByIndex(buttons_, new_selected)->SetSelected(true); | 155 GetButtonByIndex(buttons_, new_selected)->SetSelected(true); |
| 153 } | 156 } |
| 154 | 157 |
| 155 } // namespace app_list | 158 } // namespace app_list |
| OLD | NEW |