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

Unified Diff: ash/system/status_area_widget_delegate.cc

Issue 1998933002: Update shelf spacing in Chrome OS according to the MD specs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/status_area_widget_delegate.h ('k') | ash/system/toast/toast_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ad153791b1b60c2864b20c4c1645ea758ddfe9dd 100644
--- a/ash/system/status_area_widget_delegate.cc
+++ b/ash/system/status_area_widget_delegate.cc
@@ -6,6 +6,8 @@
#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"
@@ -20,6 +22,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
#include "ui/views/accessible_pane_view.h"
+#include "ui/views/border.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/widget/widget.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 */
@@ -142,7 +156,7 @@ void StatusAreaWidgetDelegate::UpdateLayout() {
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,63 @@ 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(TRAY_PADDING_FROM_EDGE_OF_SHELF);
+ } else {
+ top_edge = 0;
+ left_edge = (GetShelfConstant(SHELF_SIZE) - kShelfItemHeight) / 2;
+ bottom_edge = GetTrayConstant(TRAY_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(TRAY_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(TRAY_PADDING_FROM_EDGE_OF_SHELF) : 0;
+ right_edge = kShelfItemInset;
+ } else { // SHELF_ALIGNMENT_RIGHT
+ top_edge = 0;
+ left_edge = kShelfItemInset;
+ bottom_edge =
+ on_edge ? GetTrayConstant(TRAY_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
« no previous file with comments | « ash/system/status_area_widget_delegate.h ('k') | ash/system/toast/toast_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698