Chromium Code Reviews| Index: ash/common/system/tray/tray_item_view.cc |
| diff --git a/ash/common/system/tray/tray_item_view.cc b/ash/common/system/tray/tray_item_view.cc |
| index 679189390acf8e7b4c8d6aad2cb9abe63ea3eb3c..aa193b8d23444a6785f320180f04fa83ca5526dd 100644 |
| --- a/ash/common/system/tray/tray_item_view.cc |
| +++ b/ash/common/system/tray/tray_item_view.cc |
| @@ -4,15 +4,17 @@ |
| #include "ash/common/system/tray/tray_item_view.h" |
| +#include "ash/common/material_design/material_design_controller.h" |
| #include "ash/common/shelf/wm_shelf_util.h" |
| #include "ash/common/system/tray/system_tray.h" |
| #include "ash/common/system/tray/system_tray_item.h" |
| +#include "ash/common/system/tray/tray_constants.h" |
| #include "ash/public/cpp/shelf_types.h" |
| #include "ui/compositor/layer.h" |
| #include "ui/gfx/animation/slide_animation.h" |
| #include "ui/views/controls/image_view.h" |
| #include "ui/views/controls/label.h" |
| -#include "ui/views/layout/box_layout.h" |
| +#include "ui/views/layout/fill_layout.h" |
| #include "ui/views/widget/widget.h" |
| namespace { |
| @@ -30,8 +32,7 @@ TrayItemView::TrayItemView(SystemTrayItem* owner) |
| : owner_(owner), label_(NULL), image_view_(NULL) { |
| SetPaintToLayer(true); |
| layer()->SetFillsBoundsOpaquely(false); |
| - SetLayoutManager( |
| - new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| + SetLayoutManager(new views::FillLayout()); |
| } |
| TrayItemView::~TrayItemView() {} |
| @@ -44,11 +45,15 @@ void TrayItemView::DisableAnimationsForTest() { |
| void TrayItemView::CreateLabel() { |
| label_ = new views::Label; |
| AddChildView(label_); |
| + PreferredSizeChanged(); |
| } |
| void TrayItemView::CreateImageView() { |
| image_view_ = new views::ImageView; |
| AddChildView(image_view_); |
| + image_view_->set_background( |
| + views::Background::CreateSolidBackground(SK_ColorGREEN)); |
|
tdanderson
2016/10/27 19:28:01
Is this for debugging?
Evan Stade
2016/10/27 21:36:34
oops.
|
| + PreferredSizeChanged(); |
| } |
| void TrayItemView::SetVisible(bool set_visible) { |
| @@ -74,20 +79,25 @@ void TrayItemView::SetVisible(bool set_visible) { |
| } |
| } |
| -gfx::Size TrayItemView::DesiredSize() const { |
| - return views::View::GetPreferredSize(); |
| -} |
| - |
| int TrayItemView::GetAnimationDurationMS() { |
| return kTrayItemAnimationDurationMS; |
| } |
| gfx::Size TrayItemView::GetPreferredSize() const { |
| - gfx::Size size = DesiredSize(); |
| - if (IsHorizontalAlignment(owner()->system_tray()->shelf_alignment())) |
| - size.set_height(kTrayIconHeight); |
| - else |
| - size.set_width(kTrayIconWidth); |
| + gfx::Size size; |
| + if (MaterialDesignController::UseMaterialDesignSystemIcons()) { |
| + gfx::Size inner_size = views::View::GetPreferredSize(); |
| + if (image_view_ && child_count() == 1) |
| + inner_size = gfx::Size(kTrayIconSize, kTrayIconSize); |
|
tdanderson
2016/10/27 19:28:01
I don't really see the purpose of |inner_size|. Wh
Evan Stade
2016/10/27 21:36:34
another oops. I'm not sure how it worked like this
|
| + const int kInterTrayItemPadding = 6; |
| + size.Enlarge(kInterTrayItemPadding, kInterTrayItemPadding); |
| + } else { |
| + size = views::View::GetPreferredSize(); |
| + if (IsHorizontalAlignment(owner()->system_tray()->shelf_alignment())) |
| + size.set_height(kTrayIconHeight); |
| + else |
| + size.set_width(kTrayIconWidth); |
| + } |
| if (!animation_.get() || !animation_->is_animating()) |
| return size; |
| if (IsHorizontalAlignment(owner()->system_tray()->shelf_alignment())) { |