| 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/app_list/page_switcher.h" | 5 #include "ui/app_list/page_switcher.h" |
| 6 | 6 |
| 7 #include "ash/app_list/pagination_model.h" | |
| 8 #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" |
| 9 #include "ui/base/animation/throb_animation.h" | 9 #include "ui/base/animation/throb_animation.h" |
| 10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 11 #include "ui/views/controls/button/custom_button.h" | 11 #include "ui/views/controls/button/custom_button.h" |
| 12 #include "ui/views/layout/box_layout.h" | 12 #include "ui/views/layout/box_layout.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 const int kButtonSpacing = 10; | 16 const int kButtonSpacing = 10; |
| 17 const int kButtonWidth = 60; | 17 const int kButtonWidth = 60; |
| 18 const int kButtonHeight = 6; | 18 const int kButtonHeight = 6; |
| 19 const int kButtonHeightPadding = 10; | 19 const int kButtonHeightPadding = 10; |
| 20 const int kButtonCornerRadius = 2; | 20 const int kButtonCornerRadius = 2; |
| 21 | 21 |
| 22 // 0.16 black | 22 // 0.16 black |
| 23 const SkColor kHoverColor = SkColorSetARGB(0x2A, 0x00, 0x00, 0x00); | 23 const SkColor kHoverColor = SkColorSetARGB(0x2A, 0x00, 0x00, 0x00); |
| 24 | 24 |
| 25 // 0.2 black | 25 // 0.2 black |
| 26 const SkColor kNormalColor = SkColorSetARGB(0x33, 0x00, 0x00, 0x00); | 26 const SkColor kNormalColor = SkColorSetARGB(0x33, 0x00, 0x00, 0x00); |
| 27 | 27 |
| 28 // 0.33 black | 28 // 0.33 black |
| 29 const SkColor kSelectedColor = SkColorSetARGB(0x55, 0x00, 0x00, 0x00); | 29 const SkColor kSelectedColor = SkColorSetARGB(0x55, 0x00, 0x00, 0x00); |
| 30 | 30 |
| 31 class PageSwitcherButton : public views::CustomButton { | 31 class PageSwitcherButton : public views::CustomButton { |
| 32 public: | 32 public: |
| 33 PageSwitcherButton(views::ButtonListener* listener) | 33 explicit PageSwitcherButton(views::ButtonListener* listener) |
| 34 : views::CustomButton(listener), | 34 : views::CustomButton(listener), |
| 35 selected_(false) { | 35 selected_(false) { |
| 36 } | 36 } |
| 37 virtual ~PageSwitcherButton() {} | 37 virtual ~PageSwitcherButton() {} |
| 38 | 38 |
| 39 void SetSelected(bool selected) { | 39 void SetSelected(bool selected) { |
| 40 if (selected == selected_) | 40 if (selected == selected_) |
| 41 return; | 41 return; |
| 42 | 42 |
| 43 selected_ = selected; | 43 selected_ = selected; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 DISALLOW_COPY_AND_ASSIGN(PageSwitcherButton); | 90 DISALLOW_COPY_AND_ASSIGN(PageSwitcherButton); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 // Gets PageSwitcherButton at |index| in |buttons|. | 93 // Gets PageSwitcherButton at |index| in |buttons|. |
| 94 PageSwitcherButton* GetButtonByIndex(views::View* buttons, int index) { | 94 PageSwitcherButton* GetButtonByIndex(views::View* buttons, int index) { |
| 95 return static_cast<PageSwitcherButton*>(buttons->child_at(index)); | 95 return static_cast<PageSwitcherButton*>(buttons->child_at(index)); |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace | 98 } // namespace |
| 99 | 99 |
| 100 namespace ash { | 100 namespace app_list { |
| 101 | 101 |
| 102 PageSwitcher::PageSwitcher(PaginationModel* model) | 102 PageSwitcher::PageSwitcher(PaginationModel* model) |
| 103 : model_(model), | 103 : model_(model), |
| 104 buttons_(NULL) { | 104 buttons_(NULL) { |
| 105 buttons_ = new views::View; | 105 buttons_ = new views::View; |
| 106 buttons_->SetLayoutManager(new views::BoxLayout( | 106 buttons_->SetLayoutManager(new views::BoxLayout( |
| 107 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing)); | 107 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing)); |
| 108 AddChildView(buttons_); | 108 AddChildView(buttons_); |
| 109 | 109 |
| 110 TotalPagesChanged(); | 110 TotalPagesChanged(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 Layout(); | 148 Layout(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void PageSwitcher::SelectedPageChanged(int old_selected, int new_selected) { | 151 void PageSwitcher::SelectedPageChanged(int old_selected, int new_selected) { |
| 152 if (old_selected >= 0 && old_selected < buttons_->child_count()) | 152 if (old_selected >= 0 && old_selected < buttons_->child_count()) |
| 153 GetButtonByIndex(buttons_, old_selected)->SetSelected(false); | 153 GetButtonByIndex(buttons_, old_selected)->SetSelected(false); |
| 154 if (new_selected >= 0 && new_selected < buttons_->child_count()) | 154 if (new_selected >= 0 && new_selected < buttons_->child_count()) |
| 155 GetButtonByIndex(buttons_, new_selected)->SetSelected(true); | 155 GetButtonByIndex(buttons_, new_selected)->SetSelected(true); |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace ash | 158 } // namespace app_list |
| OLD | NEW |