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

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

Issue 2461693003: MD cros - Fix padding in system tray (Closed)
Patch Set: self review Created 4 years, 2 months 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') | ash/common/system/user/tray_user.cc » ('J')
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 1aa43d3100e309f6e3329b7bf808d6bf8197506b..2b24d6a622cb9d8d23189b5606944f37c0a0c763 100644
--- a/ash/common/system/tray/system_tray.cc
+++ b/ash/common/system/tray/system_tray.cc
@@ -74,6 +74,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 {}
+
+ // Overridden from SystemTrayItem.
tdanderson 2016/10/31 21:29:09 nit: just "SystemTrayItem:"
Evan Stade 2016/10/31 22:11:56 I will make this change, but don't want to switch
tdanderson 2016/11/01 00:00:35 Acknowledged.
+ 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;
@@ -182,8 +215,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() {
@@ -221,6 +252,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.
@@ -272,6 +308,9 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
AddTrayItem(tray_update_);
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') | ash/common/system/user/tray_user.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698