| OLD | NEW |
| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 UpdateLayout(); | 167 UpdateLayout(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void TrayBackgroundView::TrayContainer::SetAlignment(ShelfAlignment alignment) { | 170 void TrayBackgroundView::TrayContainer::SetAlignment(ShelfAlignment alignment) { |
| 171 if (alignment_ == alignment) | 171 if (alignment_ == alignment) |
| 172 return; | 172 return; |
| 173 alignment_ = alignment; | 173 alignment_ = alignment; |
| 174 UpdateLayout(); | 174 UpdateLayout(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void TrayBackgroundView::TrayContainer::SetMargin(const gfx::Insets& margin) { |
| 178 margin_ = margin; |
| 179 UpdateLayout(); |
| 180 } |
| 181 |
| 177 gfx::Size TrayBackgroundView::TrayContainer::GetPreferredSize() const { | 182 gfx::Size TrayBackgroundView::TrayContainer::GetPreferredSize() const { |
| 178 if (size_.IsEmpty()) | 183 if (size_.IsEmpty()) |
| 179 return views::View::GetPreferredSize(); | 184 return views::View::GetPreferredSize(); |
| 180 return size_; | 185 return size_; |
| 181 } | 186 } |
| 182 | 187 |
| 183 void TrayBackgroundView::TrayContainer::ChildPreferredSizeChanged( | 188 void TrayBackgroundView::TrayContainer::ChildPreferredSizeChanged( |
| 184 views::View* child) { | 189 views::View* child) { |
| 185 PreferredSizeChanged(); | 190 PreferredSizeChanged(); |
| 186 } | 191 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 199 // Adjust the size of status tray dark background by adding additional | 204 // Adjust the size of status tray dark background by adding additional |
| 200 // empty border. | 205 // empty border. |
| 201 views::BoxLayout::Orientation orientation = | 206 views::BoxLayout::Orientation orientation = |
| 202 IsHorizontalAlignment(alignment_) ? views::BoxLayout::kHorizontal | 207 IsHorizontalAlignment(alignment_) ? views::BoxLayout::kHorizontal |
| 203 : views::BoxLayout::kVertical; | 208 : views::BoxLayout::kVertical; |
| 204 | 209 |
| 205 if (!ash::MaterialDesignController::IsShelfMaterial()) { | 210 if (!ash::MaterialDesignController::IsShelfMaterial()) { |
| 206 // Additional padding used to adjust the user-visible size of status tray | 211 // Additional padding used to adjust the user-visible size of status tray |
| 207 // dark background. | 212 // dark background. |
| 208 const int padding = 3; | 213 const int padding = 3; |
| 209 SetBorder( | 214 SetBorder(views::Border::CreateEmptyBorder(gfx::Insets(padding) + margin_)); |
| 210 views::Border::CreateEmptyBorder(padding, padding, padding, padding)); | 215 } else { |
| 216 SetBorder(views::Border::CreateEmptyBorder(margin_)); |
| 211 } | 217 } |
| 212 | 218 |
| 213 views::BoxLayout* layout = new views::BoxLayout(orientation, 0, 0, 0); | 219 views::BoxLayout* layout = new views::BoxLayout(orientation, 0, 0, 0); |
| 214 layout->SetDefaultFlex(1); | 220 layout->SetDefaultFlex(1); |
| 215 views::View::SetLayoutManager(layout); | 221 views::View::SetLayoutManager(layout); |
| 216 PreferredSizeChanged(); | 222 PreferredSizeChanged(); |
| 217 } | 223 } |
| 218 | 224 |
| 219 //////////////////////////////////////////////////////////////////////////////// | 225 //////////////////////////////////////////////////////////////////////////////// |
| 220 // TrayBackgroundView | 226 // TrayBackgroundView |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } | 502 } |
| 497 | 503 |
| 498 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) { | 504 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) { |
| 499 if (background_) { | 505 if (background_) { |
| 500 background_->set_alpha(alpha); | 506 background_->set_alpha(alpha); |
| 501 SchedulePaint(); | 507 SchedulePaint(); |
| 502 } | 508 } |
| 503 } | 509 } |
| 504 | 510 |
| 505 } // namespace ash | 511 } // namespace ash |
| OLD | NEW |