Chromium Code Reviews| Index: ui/app_list/views/contents_switcher_view.cc |
| diff --git a/ui/app_list/views/contents_switcher_view.cc b/ui/app_list/views/contents_switcher_view.cc |
| index 95669439fdb2f06df7d6ed6533d0e8d832cb101b..fc8052fccdfe7ec961295bad70a900e3eb3a2059 100644 |
| --- a/ui/app_list/views/contents_switcher_view.cc |
| +++ b/ui/app_list/views/contents_switcher_view.cc |
| @@ -6,17 +6,34 @@ |
| #include "ui/app_list/app_list_constants.h" |
| #include "ui/app_list/views/contents_view.h" |
| +#include "ui/views/background.h" |
| #include "ui/views/controls/button/custom_button.h" |
| #include "ui/views/controls/button/image_button.h" |
| #include "ui/views/layout/box_layout.h" |
| +#include "ui/views/layout/fill_layout.h" |
| namespace app_list { |
| namespace { |
| -const int kPreferredHeight = 32; |
| +const int kPageIndicatorHeight = 1; |
| +const int kPreferredHeight = 32 + kPageIndicatorHeight; |
|
calamity
2014/07/09 05:50:19
Pull out 32 into kButtonImageSize.
kcarattini
2014/07/09 06:45:22
Done.
|
| const int kButtonSpacing = 4; |
| +class ContentsPageIndicatorView : public views::View { |
| + public: |
| + ContentsPageIndicatorView() {}; |
| + virtual ~ContentsPageIndicatorView() {}; |
| + |
| + // Overridden from views::View: |
| + virtual gfx::Size GetPreferredSize() const OVERRIDE { |
| + return gfx::Size(0, kPageIndicatorHeight); |
| + }; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ContentsPageIndicatorView); |
| +}; |
| + |
| } // namespace |
| ContentsSwitcherView::ContentsSwitcherView(ContentsView* contents_view) |
| @@ -37,7 +54,29 @@ void ContentsSwitcherView::AddSwitcherButton(int resource_id, int page_index) { |
| ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id)); |
| } |
| button->set_tag(page_index); |
| - buttons_->AddChildView(button); |
| + |
| + // Add an indicator for the current launcher page. |
| + app_list::ContentsPageIndicatorView* indicator = |
| + new app_list::ContentsPageIndicatorView(); |
| + indicator->set_background( |
| + views::Background::CreateSolidBackground(0, 0, 255)); |
|
calamity
2014/07/09 05:50:19
Use app_list::kPagerSelectedColor.
kcarattini
2014/07/09 06:45:21
Done.
|
| + indicator->SetFillsBoundsOpaquely(true); |
|
calamity
2014/07/09 05:50:19
I don't think this does anything. This is an optio
kcarattini
2014/07/09 06:45:22
Done.
|
| + indicator->SetVisible(false); |
| + |
| + views::View* indicator_container = new views::View(); |
|
calamity
2014/07/09 05:50:19
// A container view that will consume space when i
kcarattini
2014/07/09 06:45:21
Done.
|
| + indicator_container->SetLayoutManager(new views::FillLayout()); |
| + indicator_container->AddChildView(indicator); |
| + |
| + views::View* button_indicator_container = new views::View(); |
|
calamity
2014/07/09 05:50:19
Maybe button_container? Either way, this should ha
kcarattini
2014/07/09 06:45:22
Done.
|
| + views::BoxLayout* layout_manager = |
| + new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); |
| + layout_manager->set_main_axis_alignment( |
| + views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
| + button_indicator_container->SetLayoutManager(layout_manager); |
| + button_indicator_container->AddChildView(indicator_container); |
| + button_indicator_container->AddChildView(button); |
| + |
| + buttons_->AddChildView(button_indicator_container); |
| } |
| gfx::Size ContentsSwitcherView::GetPreferredSize() const { |
| @@ -61,4 +100,16 @@ void ContentsSwitcherView::ButtonPressed(views::Button* sender, |
| contents_view_->SetActivePage(sender->tag()); |
| } |
| +void ContentsSwitcherView::SelectedPageChanged(int old_selected, |
| + int new_selected) { |
| + if (old_selected >= 0 && old_selected < buttons_->child_count()) { |
| + buttons_->child_at(old_selected)->child_at(0)->child_at(0)->SetVisible( |
| + false); |
| + } |
| + if (new_selected >= 0 && new_selected < buttons_->child_count()) { |
| + buttons_->child_at(new_selected)->child_at(0)->child_at(0)->SetVisible( |
| + true); |
|
calamity
2014/07/09 05:50:18
It would be better to make a private member
// Ow
kcarattini
2014/07/09 06:45:21
Done.
|
| + } |
| +} |
| + |
| } // namespace app_list |