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..ace9dd70964eea830141ba289e90c8d1f9e6993b 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" |
| #include "base/strings/utf_string_conversions.h" |
| #include "ui/aura/window_event_dispatcher.h" |
| #include "ui/compositor/layer.h" |
| @@ -99,7 +102,7 @@ bool StatusAreaWidgetDelegate::CanActivate() const { |
| void StatusAreaWidgetDelegate::DeleteDelegate() { |
| } |
| -void StatusAreaWidgetDelegate::AddTray(views::View* tray) { |
| +void StatusAreaWidgetDelegate::AddTray(TrayBackgroundView* tray) { |
|
tdanderson
2016/06/13 19:02:51
views::View*
yiyix
2016/06/13 19:14:00
Done.
|
| SetLayoutManager(NULL); // Reset layout manager before adding a child. |
| AddChildView(tray); |
| // Set the layout manager with the new list of children. |
| @@ -112,15 +115,30 @@ 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; |
| + if (is_child_on_edge) { |
| + SetBorderOnChild(child, true); |
| + } else { |
| + SetBorderOnChild(child, false); |
| + } |
|
tdanderson
2016/06/13 19:02:51
replace lines 124-128 with just SetBorderOnChild(c
yiyix
2016/06/13 19:14:00
haha....lol... that's true, i not using is_child_o
|
| + 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 +151,17 @@ void StatusAreaWidgetDelegate::UpdateLayout() { |
| layout->AddView(child); |
| } |
| } else { |
| + bool is_first_visible_child = true; |
| 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); |
| + if (!is_first_visible_child) { |
|
tdanderson
2016/06/13 19:02:51
nit: remove {}
yiyix
2016/06/13 19:14:00
Done.
|
| + layout->AddPaddingRow(0, GetTrayConstant(TRAY_SPACING)); |
| + } |
| is_first_visible_child = false; |
| layout->StartRow(0, 0); |
| layout->AddView(child); |
| @@ -171,4 +190,60 @@ void StatusAreaWidgetDelegate::UpdateWidgetSize() { |
| GetWidget()->SetSize(GetPreferredSize()); |
| } |
| +void StatusAreaWidgetDelegate::SetBorderOnChild(views::View* child, |
|
tdanderson
2016/06/13 19:02:51
Can probably still be split up into helpers. Will
|
| + 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 |