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 #ifndef UI_APP_LIST_VIEWS_PAGE_SWITCHER_H_ | 5 #ifndef UI_APP_LIST_VIEWS_PAGE_SWITCHER_VERTICAL_H_ |
| 6 #define UI_APP_LIST_VIEWS_PAGE_SWITCHER_H_ | 6 #define UI_APP_LIST_VIEWS_PAGE_SWITCHER_VERTICAL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "ui/app_list/pagination_model_observer.h" | 9 #include "ui/app_list/pagination_model_observer.h" |
| 10 #include "ui/app_list/views/page_switcher.h" | |
| 10 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
| 11 #include "ui/views/view.h" | |
| 12 | 12 |
| 13 namespace app_list { | 13 namespace app_list { |
| 14 | 14 |
| 15 class PaginationModel; | 15 class PaginationModel; |
| 16 | 16 |
| 17 // PageSwitcher represents its underlying PaginationModel with a button strip. | 17 // PageSwitcher represents its underlying PaginationModel with a button strip. |
| 18 // Each page in the PageinationModel has a button in the strip and when the | 18 // Each page in the PageinationModel has a button in the strip and when the |
| 19 // button is clicked, the corresponding page becomes selected. | 19 // button is clicked, the corresponding page becomes selected. |
| 20 class PageSwitcher : public views::View, | 20 class PageSwitcherVertical : public views::ButtonListener, |
| 21 public views::ButtonListener, | 21 public PaginationModelObserver, |
| 22 public PaginationModelObserver { | 22 public PageSwitcher { |
|
xiyuan
2017/06/13 18:29:55
nit: Make PageSwitcher the first one
weidongg
2017/06/13 21:25:00
Done.
| |
| 23 public: | 23 public: |
| 24 explicit PageSwitcher(PaginationModel* model); | 24 explicit PageSwitcherVertical(PaginationModel* model); |
| 25 ~PageSwitcher() override; | 25 ~PageSwitcherVertical() override; |
| 26 | 26 |
| 27 // Returns the page index of the page switcher button under the point. If no | 27 // Overridden from PageSwitcher: |
| 28 // page switcher button is under the point, -1 is return. |point| is in | 28 int GetPageForPoint(const gfx::Point& point) const override; |
| 29 // PageSwitcher's coordinates. | 29 void UpdateUIForDragPoint(const gfx::Point& point) override; |
| 30 int GetPageForPoint(const gfx::Point& point) const; | |
| 31 | |
| 32 // Shows hover for button under the point. |point| is in PageSwitcher's | |
| 33 // coordinates. | |
| 34 void UpdateUIForDragPoint(const gfx::Point& point); | |
| 35 | 30 |
| 36 // Overridden from views::View: | 31 // Overridden from views::View: |
| 37 gfx::Size CalculatePreferredSize() const override; | 32 gfx::Size CalculatePreferredSize() const override; |
| 38 void Layout() override; | 33 void Layout() override; |
| 39 | 34 |
| 40 private: | 35 private: |
| 41 void CalculateButtonWidthAndSpacing(int contents_width); | 36 void CalculateButtonHeightAndSpacing(int contents_height); |
| 42 | 37 |
| 43 // Overridden from views::ButtonListener: | 38 // Overridden from views::ButtonListener: |
| 44 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 39 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 45 | 40 |
| 46 // Overridden from PaginationModelObserver: | 41 // Overridden from PaginationModelObserver: |
| 47 void TotalPagesChanged() override; | 42 void TotalPagesChanged() override; |
| 48 void SelectedPageChanged(int old_selected, int new_selected) override; | 43 void SelectedPageChanged(int old_selected, int new_selected) override; |
| 49 void TransitionStarted() override; | 44 void TransitionStarted() override; |
| 50 void TransitionChanged() override; | 45 void TransitionChanged() override; |
| 51 | 46 |
| 52 PaginationModel* model_; // Owned by AppsGridView. | 47 PaginationModel* model_; // Owned by AppsGridView. |
| 53 views::View* buttons_; // Owned by views hierarchy. | 48 views::View* buttons_; // Owned by views hierarchy. |
| 54 | 49 |
| 55 DISALLOW_COPY_AND_ASSIGN(PageSwitcher); | 50 DISALLOW_COPY_AND_ASSIGN(PageSwitcherVertical); |
| 56 }; | 51 }; |
| 57 | 52 |
| 58 } // namespace app_list | 53 } // namespace app_list |
| 59 | 54 |
| 60 #endif // UI_APP_LIST_VIEWS_PAGE_SWITCHER_H_ | 55 #endif // UI_APP_LIST_VIEWS_PAGE_SWITCHER_VERTICAL_H_ |
| OLD | NEW |