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

Side by Side Diff: ash/common/system/tray/tray_background_view.cc

Issue 2369293002: Set status tray height to 37px on login screen (Closed)
Patch Set: 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 unified diff | Download patch
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 UpdateLayout(); 189 UpdateLayout();
190 } 190 }
191 191
192 void TrayBackgroundView::TrayContainer::SetAlignment(ShelfAlignment alignment) { 192 void TrayBackgroundView::TrayContainer::SetAlignment(ShelfAlignment alignment) {
193 if (alignment_ == alignment) 193 if (alignment_ == alignment)
194 return; 194 return;
195 alignment_ = alignment; 195 alignment_ = alignment;
196 UpdateLayout(); 196 UpdateLayout();
197 } 197 }
198 198
199 void TrayBackgroundView::TrayContainer::SetMargin(const gfx::Insets& margin) { 199 void TrayBackgroundView::TrayContainer::SetMargin(int main_axis_margin,
200 margin_ = margin; 200 int cross_axis_margin) {
201 main_axis_margin_ = main_axis_margin;
202 cross_axis_margin_ = cross_axis_margin;
201 UpdateLayout(); 203 UpdateLayout();
202 } 204 }
203 205
204 gfx::Size TrayBackgroundView::TrayContainer::GetPreferredSize() const { 206 gfx::Size TrayBackgroundView::TrayContainer::GetPreferredSize() const {
205 if (size_.IsEmpty()) 207 if (size_.IsEmpty())
206 return views::View::GetPreferredSize(); 208 return views::View::GetPreferredSize();
207 return size_; 209 return size_;
208 } 210 }
209 211
210 void TrayBackgroundView::TrayContainer::ChildPreferredSizeChanged( 212 void TrayBackgroundView::TrayContainer::ChildPreferredSizeChanged(
211 views::View* child) { 213 views::View* child) {
212 PreferredSizeChanged(); 214 PreferredSizeChanged();
213 } 215 }
214 216
215 void TrayBackgroundView::TrayContainer::ChildVisibilityChanged(View* child) { 217 void TrayBackgroundView::TrayContainer::ChildVisibilityChanged(View* child) {
216 PreferredSizeChanged(); 218 PreferredSizeChanged();
217 } 219 }
218 220
219 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( 221 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged(
220 const ViewHierarchyChangedDetails& details) { 222 const ViewHierarchyChangedDetails& details) {
221 if (details.parent == this) 223 if (details.parent == this)
222 PreferredSizeChanged(); 224 PreferredSizeChanged();
223 } 225 }
224 226
225 void TrayBackgroundView::TrayContainer::UpdateLayout() { 227 void TrayBackgroundView::TrayContainer::UpdateLayout() {
228 bool is_horizontal = IsHorizontalAlignment(alignment_);
229
226 // Adjust the size of status tray dark background by adding additional 230 // Adjust the size of status tray dark background by adding additional
227 // empty border. 231 // empty border.
228 views::BoxLayout::Orientation orientation = 232 views::BoxLayout::Orientation orientation =
229 IsHorizontalAlignment(alignment_) ? views::BoxLayout::kHorizontal 233 is_horizontal ? views::BoxLayout::kHorizontal
230 : views::BoxLayout::kVertical; 234 : views::BoxLayout::kVertical;
231 const gfx::Insets insets( 235 const gfx::Insets insets(
232 ash::MaterialDesignController::IsShelfMaterial() 236 ash::MaterialDesignController::IsShelfMaterial()
233 ? gfx::Insets(IsHorizontalAlignment(alignment_) 237 ? is_horizontal ? gfx::Insets(0, kHitRegionPadding, 0,
234 ? gfx::Insets(0, kHitRegionPadding, 0, 238 kHitRegionPadding + kSeparatorWidth)
235 kHitRegionPadding + kSeparatorWidth) 239 : gfx::Insets(kHitRegionPadding, 0,
236 : gfx::Insets(kHitRegionPadding, 0, 240 kHitRegionPadding + kSeparatorWidth, 0)
237 kHitRegionPadding + kSeparatorWidth,
238 0))
239 : gfx::Insets(kBackgroundAdjustPadding)); 241 : gfx::Insets(kBackgroundAdjustPadding));
240 SetBorder(views::Border::CreateEmptyBorder(insets + margin_)); 242 const gfx::Insets margin(
243 is_horizontal ? gfx::Insets(cross_axis_margin_, main_axis_margin_)
244 : gfx::Insets(main_axis_margin_, cross_axis_margin_));
245 SetBorder(views::Border::CreateEmptyBorder(insets + margin));
246
241 views::BoxLayout* layout = new views::BoxLayout(orientation, 0, 0, 0); 247 views::BoxLayout* layout = new views::BoxLayout(orientation, 0, 0, 0);
242 layout->SetDefaultFlex(1); 248 layout->SetDefaultFlex(1);
249 layout->set_minimum_cross_axis_size(kTrayItemSize);
243 views::View::SetLayoutManager(layout); 250 views::View::SetLayoutManager(layout);
251
244 PreferredSizeChanged(); 252 PreferredSizeChanged();
245 } 253 }
246 254
247 //////////////////////////////////////////////////////////////////////////////// 255 ////////////////////////////////////////////////////////////////////////////////
248 // TrayBackgroundView 256 // TrayBackgroundView
249 257
250 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) 258 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf)
251 : ActionableView(nullptr), 259 : ActionableView(nullptr),
252 wm_shelf_(wm_shelf), 260 wm_shelf_(wm_shelf),
253 tray_container_(NULL), 261 tray_container_(NULL),
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 paint.setAntiAlias(true); 571 paint.setAntiAlias(true);
564 572
565 const gfx::Rect bounds = horizontal_shelf ? gfx::Rect(x, y, width, height) 573 const gfx::Rect bounds = horizontal_shelf ? gfx::Rect(x, y, width, height)
566 : gfx::Rect(y, x, height, width); 574 : gfx::Rect(y, x, height, width);
567 gfx::RectF rect(gfx::ScaleRect(gfx::RectF(bounds), scale)); 575 gfx::RectF rect(gfx::ScaleRect(gfx::RectF(bounds), scale));
568 canvas->DrawLine(horizontal_shelf ? rect.top_right() : rect.bottom_left(), 576 canvas->DrawLine(horizontal_shelf ? rect.top_right() : rect.bottom_left(),
569 rect.bottom_right(), paint); 577 rect.bottom_right(), paint);
570 } 578 }
571 579
572 } // namespace ash 580 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698