Chromium Code Reviews| Index: ash/common/system/tray/tray_popup_utils.cc |
| diff --git a/ash/common/system/tray/tray_popup_layout_factory.cc b/ash/common/system/tray/tray_popup_utils.cc |
| similarity index 60% |
| rename from ash/common/system/tray/tray_popup_layout_factory.cc |
| rename to ash/common/system/tray/tray_popup_utils.cc |
| index 16941c23835d874ac235768e8b51fb82837c5614..39cf03faeb783815af41f065332227191b11fb9e 100644 |
| --- a/ash/common/system/tray/tray_popup_layout_factory.cc |
| +++ b/ash/common/system/tray/tray_popup_utils.cc |
| @@ -2,12 +2,17 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "ash/common/system/tray/tray_popup_layout_factory.h" |
| +#include "ash/common/system/tray/tray_popup_utils.h" |
| #include "ash/common/material_design/material_design_controller.h" |
| +#include "ash/common/system/tray/fixed_sized_image_view.h" |
| #include "ash/common/system/tray/tray_constants.h" |
| -#include "ash/common/system/tray/tri_view.h" |
| +#include "ash/common/system/tray/tray_popup_label_button.h" |
| +#include "ui/views/border.h" |
| #include "ui/views/controls/button/label_button.h" |
| +#include "ui/views/controls/image_view.h" |
| +#include "ui/views/controls/label.h" |
| +#include "ui/views/controls/slider.h" |
|
tdanderson
2016/11/01 18:59:44
Is this include needed?
bruthig
2016/11/01 23:00:43
Removed.
|
| #include "ui/views/layout/box_layout.h" |
| namespace ash { |
| @@ -35,13 +40,13 @@ std::unique_ptr<views::LayoutManager> CreateDefaultEndsLayoutManager() { |
| box_layout->set_main_axis_alignment( |
| views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
| box_layout->set_cross_axis_alignment( |
| - views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); |
| + views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); |
|
tdanderson
2016/11/01 18:59:44
It seems CENTER is what you want here instead of S
bruthig
2016/11/01 23:00:43
Actually this should be START if we are trying to
|
| return std::unique_ptr<views::LayoutManager>(box_layout); |
| } |
| } // namespace |
| -TriView* TrayPopupLayoutFactory::CreateDefaultRowView() { |
| +TriView* TrayPopupUtils::CreateDefaultRowView() { |
| TriView* tri_view = new TriView(0 /* padding_between_items */); |
| tri_view->SetInsets( |
| @@ -56,30 +61,59 @@ TriView* TrayPopupLayoutFactory::CreateDefaultRowView() { |
| return tri_view; |
| } |
| -void TrayPopupLayoutFactory::ConfigureDefaultLayout( |
| - TriView* tri_view, |
| +std::unique_ptr<views::LayoutManager> TrayPopupUtils::CreateLayoutManager( |
| TriView::Container container) { |
| switch (container) { |
| case TriView::Container::START: |
| - tri_view->SetContainerLayout(TriView::Container::START, |
| - CreateDefaultEndsLayoutManager()); |
| + case TriView::Container::END: |
| + return CreateDefaultEndsLayoutManager(); |
| + case TriView::Container::CENTER: |
| + return CreateDefaultCenterLayoutManager(); |
| + } |
| + // Required by some compilers. |
| + NOTREACHED(); |
| + return nullptr; |
| +} |
| + |
| +views::Label* TrayPopupUtils::CreateDefaultLabel() { |
| + views::Label* label = new views::Label(); |
| + label->SetBorder( |
| + views::Border::CreateEmptyBorder(0, kTrayPopupLabelHorizontalPadding, 0, |
| + kTrayPopupLabelHorizontalPadding)); |
| + return label; |
| +} |
| + |
| +views::ImageView* TrayPopupUtils::CreateMainImageView() { |
| + return new FixedSizedImageView( |
| + GetTrayConstant(TRAY_POPUP_ITEM_MAIN_IMAGE_CONTAINER_WIDTH), |
| + GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); |
| +} |
| + |
| +views::ImageView* TrayPopupUtils::CreateMoreImageView() { |
| + return new FixedSizedImageView( |
| + GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_CONTAINER_WIDTH), |
| + GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); |
| +} |
| + |
| +void TrayPopupUtils::ConfigureDefaultLayout(TriView* tri_view, |
| + TriView::Container container) { |
| + switch (container) { |
| + case TriView::Container::START: |
| tri_view->SetMinSize( |
| TriView::Container::START, |
| gfx::Size(GetTrayConstant(TRAY_POPUP_ITEM_MIN_START_WIDTH), 0)); |
| break; |
| case TriView::Container::CENTER: |
| - tri_view->SetContainerLayout(TriView::Container::CENTER, |
| - CreateDefaultCenterLayoutManager()); |
| tri_view->SetFlexForContainer(TriView::Container::CENTER, 1.f); |
| break; |
| case TriView::Container::END: |
| - tri_view->SetContainerLayout(TriView::Container::END, |
| - CreateDefaultEndsLayoutManager()); |
| tri_view->SetMinSize( |
| TriView::Container::END, |
| gfx::Size(GetTrayConstant(TRAY_POPUP_ITEM_MIN_END_WIDTH), 0)); |
| break; |
| } |
| + |
| + tri_view->SetContainerLayout(container, CreateLayoutManager(container)); |
| } |
| } // namespace ash |