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

Side by Side Diff: ash/common/system/tray/tray_background_view.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 unified diff | Download patch
« no previous file with comments | « ash/common/system/tray/tray_background_view.h ('k') | ash/common/system/user/tray_user.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/system/tray/tray_background_view.h" 5 #include "ash/common/system/tray/tray_background_view.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/shelf/shelf_constants.h" 8 #include "ash/common/shelf/shelf_constants.h"
9 #include "ash/common/shelf/wm_shelf.h" 9 #include "ash/common/shelf/wm_shelf.h"
10 #include "ash/common/shelf/wm_shelf_util.h" 10 #include "ash/common/shelf/wm_shelf_util.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 UpdateLayout(); 196 UpdateLayout();
197 } 197 }
198 198
199 void TrayBackgroundView::TrayContainer::SetMargin(int main_axis_margin, 199 void TrayBackgroundView::TrayContainer::SetMargin(int main_axis_margin,
200 int cross_axis_margin) { 200 int cross_axis_margin) {
201 main_axis_margin_ = main_axis_margin; 201 main_axis_margin_ = main_axis_margin;
202 cross_axis_margin_ = cross_axis_margin; 202 cross_axis_margin_ = cross_axis_margin;
203 UpdateLayout(); 203 UpdateLayout();
204 } 204 }
205 205
206 gfx::Size TrayBackgroundView::TrayContainer::GetPreferredSize() const {
207 if (size_.IsEmpty())
208 return views::View::GetPreferredSize();
209 return size_;
210 }
211
212 void TrayBackgroundView::TrayContainer::ChildPreferredSizeChanged( 206 void TrayBackgroundView::TrayContainer::ChildPreferredSizeChanged(
213 views::View* child) { 207 views::View* child) {
214 PreferredSizeChanged(); 208 PreferredSizeChanged();
215 } 209 }
216 210
217 void TrayBackgroundView::TrayContainer::ChildVisibilityChanged(View* child) { 211 void TrayBackgroundView::TrayContainer::ChildVisibilityChanged(View* child) {
218 PreferredSizeChanged(); 212 PreferredSizeChanged();
219 } 213 }
220 214
221 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( 215 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged(
(...skipping 16 matching lines...) Expand all
238 kHitRegionPadding + kSeparatorWidth) 232 kHitRegionPadding + kSeparatorWidth)
239 : gfx::Insets(kHitRegionPadding, 0, 233 : gfx::Insets(kHitRegionPadding, 0,
240 kHitRegionPadding + kSeparatorWidth, 0) 234 kHitRegionPadding + kSeparatorWidth, 0)
241 : gfx::Insets(kBackgroundAdjustPadding)); 235 : gfx::Insets(kBackgroundAdjustPadding));
242 const gfx::Insets margin( 236 const gfx::Insets margin(
243 is_horizontal ? gfx::Insets(cross_axis_margin_, main_axis_margin_) 237 is_horizontal ? gfx::Insets(cross_axis_margin_, main_axis_margin_)
244 : gfx::Insets(main_axis_margin_, cross_axis_margin_)); 238 : gfx::Insets(main_axis_margin_, cross_axis_margin_));
245 SetBorder(views::Border::CreateEmptyBorder(insets + margin)); 239 SetBorder(views::Border::CreateEmptyBorder(insets + margin));
246 240
247 views::BoxLayout* layout = new views::BoxLayout(orientation, 0, 0, 0); 241 views::BoxLayout* layout = new views::BoxLayout(orientation, 0, 0, 0);
248 layout->SetDefaultFlex(1); 242 if (!ash::MaterialDesignController::IsShelfMaterial())
243 layout->SetDefaultFlex(1);
249 layout->set_minimum_cross_axis_size(kTrayItemSize); 244 layout->set_minimum_cross_axis_size(kTrayItemSize);
250 views::View::SetLayoutManager(layout); 245 views::View::SetLayoutManager(layout);
251 246
252 PreferredSizeChanged(); 247 PreferredSizeChanged();
253 } 248 }
254 249
255 //////////////////////////////////////////////////////////////////////////////// 250 ////////////////////////////////////////////////////////////////////////////////
256 // TrayBackgroundView 251 // TrayBackgroundView
257 252
258 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) 253 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf)
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 paint.setAntiAlias(true); 566 paint.setAntiAlias(true);
572 567
573 const gfx::Rect bounds = horizontal_shelf ? gfx::Rect(x, y, width, height) 568 const gfx::Rect bounds = horizontal_shelf ? gfx::Rect(x, y, width, height)
574 : gfx::Rect(y, x, height, width); 569 : gfx::Rect(y, x, height, width);
575 gfx::RectF rect(gfx::ScaleRect(gfx::RectF(bounds), scale)); 570 gfx::RectF rect(gfx::ScaleRect(gfx::RectF(bounds), scale));
576 canvas->DrawLine(horizontal_shelf ? rect.top_right() : rect.bottom_left(), 571 canvas->DrawLine(horizontal_shelf ? rect.top_right() : rect.bottom_left(),
577 rect.bottom_right(), paint); 572 rect.bottom_right(), paint);
578 } 573 }
579 574
580 } // namespace ash 575 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_background_view.h ('k') | ash/common/system/user/tray_user.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698