Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: ash/common/system/tray/tray_item_more.cc

Issue 2468533002: [ash-md] Applied Material Design layout to TrayItemMore system menu rows. (Closed)
Patch Set: Merge branch 'master' into md_system_menu_tray_item_more_layout Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/tray/tray_item_more.h ('k') | ash/common/system/tray/tray_popup_layout_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/tray/tray_item_more.cc
diff --git a/ash/common/system/tray/tray_item_more.cc b/ash/common/system/tray/tray_item_more.cc
index 681c08b58edc621c2402787500963048d5788abd..4638c410bf375c4071f61e02a483a6d8ff1297b9 100644
--- a/ash/common/system/tray/tray_item_more.cc
+++ b/ash/common/system/tray/tray_item_more.cc
@@ -5,10 +5,11 @@
#include "ash/common/system/tray/tray_item_more.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/system_tray_item.h"
#include "ash/common/system/tray/tray_constants.h"
#include "ash/common/system/tray/tray_popup_item_style.h"
+#include "ash/common/system/tray/tray_popup_utils.h"
+#include "ash/common/system/tray/tri_view.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "base/memory/ptr_util.h"
#include "grit/ash_resources.h"
@@ -19,6 +20,7 @@
#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"
namespace ash {
@@ -28,27 +30,27 @@ TrayItemMore::TrayItemMore(SystemTrayItem* owner, bool show_more)
icon_(nullptr),
label_(nullptr),
more_(nullptr) {
- SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
- kTrayPopupPaddingHorizontal, 0,
- kTrayPopupPaddingBetweenItems));
+ TriView* tri_view = TrayPopupUtils::CreateDefaultRowView();
+ AddChildView(tri_view);
+ SetLayoutManager(new views::FillLayout);
- icon_ = new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT));
- AddChildView(icon_);
+ icon_ = TrayPopupUtils::CreateMainImageView();
+ tri_view->AddView(TriView::Container::START, icon_);
- label_ = new views::Label;
- label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- AddChildView(label_);
+ label_ = TrayPopupUtils::CreateDefaultLabel();
+ tri_view->AddView(TriView::Container::CENTER, label_);
if (show_more) {
- more_ = new views::ImageView;
- more_->EnableCanvasFlippingForRTLUI(true);
+ more_ = TrayPopupUtils::CreateMoreImageView();
if (!MaterialDesignController::IsSystemTrayMenuMaterial()) {
// The icon doesn't change in non-md.
more_->SetImage(ui::ResourceBundle::GetSharedInstance()
.GetImageNamed(IDR_AURA_UBER_TRAY_MORE)
.ToImageSkia());
}
- AddChildView(more_);
+ tri_view->AddView(TriView::Container::END, more_);
+ } else {
+ tri_view->SetContainerVisible(TriView::Container::END, false);
}
}
@@ -94,29 +96,6 @@ bool TrayItemMore::PerformAction(const ui::Event& event) {
return true;
}
-void TrayItemMore::Layout() {
- // Let the box-layout do the layout first. Then move the '>' arrow to right
- // align.
- views::View::Layout();
-
- if (!show_more_)
- return;
-
- // Make sure the chevron always has the full size.
- gfx::Size size = more_->GetPreferredSize();
- gfx::Rect bounds(size);
- bounds.set_x(width() - size.width() - kTrayPopupPaddingBetweenItems);
- bounds.set_y((height() - size.height()) / 2);
- more_->SetBoundsRect(bounds);
-
- // Adjust the label's bounds in case it got cut off by |more_|.
- if (label_->bounds().Intersects(more_->bounds())) {
- gfx::Rect bounds = label_->bounds();
- bounds.set_width(more_->x() - kTrayPopupPaddingBetweenItems - label_->x());
- label_->SetBoundsRect(bounds);
- }
-}
-
void TrayItemMore::GetAccessibleState(ui::AXViewState* state) {
ActionableView::GetAccessibleState(state);
if (!accessible_name_.empty())
« no previous file with comments | « ash/common/system/tray/tray_item_more.h ('k') | ash/common/system/tray/tray_popup_layout_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698