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

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

Issue 2461693003: MD cros - Fix padding in system tray (Closed)
Patch Set: nit + rebase 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 | « no previous file | ash/common/system/tray/tray_background_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/tray/system_tray.cc
diff --git a/ash/common/system/tray/system_tray.cc b/ash/common/system/tray/system_tray.cc
index eaaab2e9d7a34667ceedfa54c8004b50ea531819..865d10e3277b44d6d6ef4d4cb1bae8db3248702f 100644
--- a/ash/common/system/tray/system_tray.cc
+++ b/ash/common/system/tray/system_tray.cc
@@ -75,6 +75,39 @@ using views::TrayBubbleView;
namespace ash {
+namespace {
+
+// A tray item that just reserves space in the tray.
+class PaddingTrayItem : public SystemTrayItem {
+ public:
+ PaddingTrayItem() : SystemTrayItem(nullptr, UMA_NOT_RECORDED) {}
+ ~PaddingTrayItem() override {}
+
+ // SystemTrayItem:
+ views::View* CreateTrayView(LoginStatus status) override {
+ return new PaddingView();
+ }
+
+ private:
+ class PaddingView : public views::View {
+ public:
+ PaddingView() {}
+ ~PaddingView() override {}
+
+ private:
+ gfx::Size GetPreferredSize() const override {
+ return gfx::Size(GetTrayConstant(TRAY_IMAGE_ITEM_PADDING),
+ GetTrayConstant(TRAY_IMAGE_ITEM_PADDING));
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(PaddingView);
+ };
+
+ DISALLOW_COPY_AND_ASSIGN(PaddingTrayItem);
+};
+
+} // namespace
+
// The minimum width of the system tray menu.
const int kMinimumSystemTrayMenuWidth = 300;
const int kMinimumSystemTrayMenuWidthMd = 332;
@@ -184,8 +217,6 @@ SystemTray::SystemTray(WmShelf* wm_shelf)
screen_capture_tray_item_(nullptr),
screen_share_tray_item_(nullptr) {
SetContentsBackground();
- if (MaterialDesignController::IsSystemTrayMenuMaterial())
- tray_container()->SetMargin(GetTrayConstant(TRAY_IMAGE_ITEM_PADDING), 0);
}
SystemTray::~SystemTray() {
@@ -223,6 +254,11 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
for (int i = 0; i < maximum_user_profiles; i++)
AddTrayItem(new TrayUser(this, i));
+ // Crucially, this trailing padding has to be inside the user item(s).
+ // Otherwise it could be a main axis margin on the tray's box layout.
+ if (MaterialDesignController::IsSystemTrayMenuMaterial())
+ AddTrayItem(new PaddingTrayItem());
+
if (maximum_user_profiles > 1) {
// Add a special double line separator between users and the rest of the
// menu if more than one user is logged in.
@@ -282,6 +318,9 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
if (!use_material_design)
AddTrayItem(tray_date_);
#endif
+ // Leading padding.
+ if (MaterialDesignController::IsSystemTrayMenuMaterial())
+ AddTrayItem(new PaddingTrayItem());
}
void SystemTray::AddTrayItem(SystemTrayItem* item) {
« no previous file with comments | « no previous file | ash/common/system/tray/tray_background_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698