Chromium Code Reviews| Index: ash/system/status_area_widget_delegate.cc |
| diff --git a/ash/system/status_area_widget_delegate.cc b/ash/system/status_area_widget_delegate.cc |
| index 0c1b574fad32f209c871a37bb8762d3af4a0704a..aca472737ce8608e04cfeff0612461cd28a66257 100644 |
| --- a/ash/system/status_area_widget_delegate.cc |
| +++ b/ash/system/status_area_widget_delegate.cc |
| @@ -6,12 +6,15 @@ |
| #include "ash/ash_export.h" |
| #include "ash/ash_switches.h" |
| +#include "ash/common/material_design/material_design_controller.h" |
| +#include "ash/common/shelf/shelf_constants.h" |
| #include "ash/common/shelf/wm_shelf_util.h" |
| #include "ash/common/shell_window_ids.h" |
| #include "ash/common/system/tray/tray_constants.h" |
| #include "ash/focus_cycler.h" |
| #include "ash/shelf/shelf_util.h" |
| #include "ash/shell.h" |
| +#include "ash/system/tray/tray_background_view.h" |
|
James Cook
2016/06/13 21:43:17
Do you need this include?
yiyix
2016/06/14 05:55:26
Done.
|
| #include "base/strings/utf_string_conversions.h" |
| #include "ui/aura/window_event_dispatcher.h" |
| #include "ui/compositor/layer.h" |
| @@ -112,15 +115,26 @@ void StatusAreaWidgetDelegate::UpdateLayout() { |
| views::GridLayout* layout = new views::GridLayout(this); |
| SetLayoutManager(layout); |
| + // Update tray border based on layout. |
| + bool is_child_on_edge = true; |
| + for (int c = 0; c < child_count(); ++c) { |
| + views::View* child = child_at(c); |
| + if (!child->visible()) |
| + continue; |
| + SetBorderOnChild(child, is_child_on_edge); |
| + is_child_on_edge = false; |
| + } |
| + |
| views::ColumnSet* columns = layout->AddColumnSet(0); |
| + |
| if (IsHorizontalAlignment(alignment_)) { |
| bool is_first_visible_child = true; |
| - for (int c = 0; c < child_count(); ++c) { |
| + for (int c = child_count() - 1; c >= 0; --c) { |
| views::View* child = child_at(c); |
| if (!child->visible()) |
| continue; |
| if (!is_first_visible_child) |
| - columns->AddPaddingColumn(0, kTraySpacing); |
| + columns->AddPaddingColumn(0, GetTrayConstant(TRAY_SPACING)); |
| is_first_visible_child = false; |
| columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, |
| 0, /* resize percent */ |
| @@ -133,16 +147,16 @@ void StatusAreaWidgetDelegate::UpdateLayout() { |
| layout->AddView(child); |
| } |
| } else { |
| + bool is_first_visible_child = true; |
|
James Cook
2016/06/13 21:43:17
move this back down to where it was before
yiyix
2016/06/14 05:55:26
Done.
|
| columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, |
| 0, /* resize percent */ |
| views::GridLayout::USE_PREF, 0, 0); |
| - bool is_first_visible_child = true; |
| for (int c = child_count() - 1; c >= 0; --c) { |
| views::View* child = child_at(c); |
| if (!child->visible()) |
| continue; |
| if (!is_first_visible_child) |
| - layout->AddPaddingRow(0, kTraySpacing); |
| + layout->AddPaddingRow(0, GetTrayConstant(TRAY_SPACING)); |
| is_first_visible_child = false; |
| layout->StartRow(0, 0); |
| layout->AddView(child); |
| @@ -171,4 +185,60 @@ void StatusAreaWidgetDelegate::UpdateWidgetSize() { |
| GetWidget()->SetSize(GetPreferredSize()); |
| } |
| +void StatusAreaWidgetDelegate::SetBorderOnChild(views::View* child, |
| + bool extend_border_to_edge) { |
| + int top_edge, left_edge, bottom_edge, right_edge; |
| + // Tray views are laid out right-to-left or bottom-to-top |
| + if (MaterialDesignController::IsShelfMaterial()) { |
| + if (extend_border_to_edge) { |
| + if (IsHorizontalAlignment(alignment_)) { |
| + top_edge = (GetShelfConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| + left_edge = 0; |
| + bottom_edge = (GetShelfConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| + right_edge = GetTrayConstant(PADDING_FROM_EDGE_OF_SHELF); |
| + } else { |
| + top_edge = 0; |
| + left_edge = (GetShelfConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| + bottom_edge = GetTrayConstant(PADDING_FROM_EDGE_OF_SHELF); |
| + right_edge = (GetShelfConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| + } |
| + } else { |
| + if (IsHorizontalAlignment(alignment_)) { |
| + top_edge = (GetShelfConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| + left_edge = 0; |
| + bottom_edge = (GetShelfConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| + right_edge = 0; |
| + } else { |
| + top_edge = 0; |
| + left_edge = (GetShelfConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| + bottom_edge = 0; |
| + right_edge = (GetShelfConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| + } |
| + } |
| + } else { |
| + bool on_edge = (child == child_at(0)); |
| + if (IsHorizontalAlignment(alignment_)) { |
| + top_edge = kShelfItemInset; |
| + left_edge = 0; |
| + bottom_edge = |
| + GetShelfConstant(SHELF_SIZE) - kShelfItemInset - kShelfItemHeight; |
| + right_edge = on_edge ? GetTrayConstant(PADDING_FROM_EDGE_OF_SHELF) : 0; |
| + } else if (alignment_ == SHELF_ALIGNMENT_LEFT) { |
| + top_edge = 0; |
| + left_edge = |
| + GetShelfConstant(SHELF_SIZE) - kShelfItemInset - kShelfItemHeight; |
| + bottom_edge = on_edge ? GetTrayConstant(PADDING_FROM_EDGE_OF_SHELF) : 0; |
| + right_edge = kShelfItemInset; |
| + } else { // SHELF_ALIGNMENT_RIGHT |
| + top_edge = 0; |
| + left_edge = kShelfItemInset; |
| + bottom_edge = on_edge ? GetTrayConstant(PADDING_FROM_EDGE_OF_SHELF) : 0; |
| + right_edge = |
| + GetShelfConstant(SHELF_SIZE) - kShelfItemInset - kShelfItemHeight; |
| + } |
| + } |
| + child->SetBorder(views::Border::CreateEmptyBorder(top_edge, left_edge, |
| + bottom_edge, right_edge)); |
| +} |
| + |
| } // namespace ash |