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

Side by Side 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: Created 4 years, 7 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/system/status_area_widget_delegate.h" 5 #include "ash/system/status_area_widget_delegate.h"
6 6
7 #include "ash/ash_export.h" 7 #include "ash/ash_export.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/focus_cycler.h" 9 #include "ash/focus_cycler.h"
10 #include "ash/shelf/shelf_util.h" 10 #include "ash/shelf/shelf_util.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 SetLayoutManager(layout); 114 SetLayoutManager(layout);
115 115
116 views::ColumnSet* columns = layout->AddColumnSet(0); 116 views::ColumnSet* columns = layout->AddColumnSet(0);
117 if (wm::IsHorizontalAlignment(alignment_)) { 117 if (wm::IsHorizontalAlignment(alignment_)) {
118 bool is_first_visible_child = true; 118 bool is_first_visible_child = true;
119 for (int c = 0; c < child_count(); ++c) { 119 for (int c = 0; c < child_count(); ++c) {
120 views::View* child = child_at(c); 120 views::View* child = child_at(c);
121 if (!child->visible()) 121 if (!child->visible())
122 continue; 122 continue;
123 if (!is_first_visible_child) 123 if (!is_first_visible_child)
124 columns->AddPaddingColumn(0, kTraySpacing); 124 columns->AddPaddingColumn(0, GetShelfStatusAreaInset(TRAY_SPACING));
125 is_first_visible_child = false; 125 is_first_visible_child = false;
126 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 126 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL,
127 0, /* resize percent */ 127 0, /* resize percent */
128 views::GridLayout::USE_PREF, 0, 0); 128 views::GridLayout::USE_PREF, 0, 0);
129 } 129 }
130 columns->AddPaddingColumn(
131 0, GetShelfStatusAreaInset(PADDING_FROM_EDGE_OF_SHELF));
130 layout->StartRow(0, 0); 132 layout->StartRow(0, 0);
131 for (int c = child_count() - 1; c >= 0; --c) { 133 for (int c = child_count() - 1; c >= 0; --c) {
132 views::View* child = child_at(c); 134 views::View* child = child_at(c);
133 if (child->visible()) 135 if (child->visible())
134 layout->AddView(child); 136 layout->AddView(child);
135 } 137 }
136 } else { 138 } else {
137 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 139 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
138 0, /* resize percent */ 140 0, /* resize percent */
139 views::GridLayout::USE_PREF, 0, 0); 141 views::GridLayout::USE_PREF, 0, 0);
140 bool is_first_visible_child = true; 142 bool is_first_visible_child = true;
141 for (int c = child_count() - 1; c >= 0; --c) { 143 for (int c = child_count() - 1; c >= 0; --c) {
142 views::View* child = child_at(c); 144 views::View* child = child_at(c);
143 if (!child->visible()) 145 if (!child->visible())
144 continue; 146 continue;
145 if (!is_first_visible_child) 147 if (!is_first_visible_child)
146 layout->AddPaddingRow(0, kTraySpacing); 148 layout->AddPaddingRow(0, GetShelfStatusAreaInset(TRAY_SPACING));
147 is_first_visible_child = false; 149 is_first_visible_child = false;
148 layout->StartRow(0, 0); 150 layout->StartRow(0, 0);
149 layout->AddView(child); 151 layout->AddView(child);
150 } 152 }
153 layout->AddPaddingRow(0,
154 GetShelfStatusAreaInset(PADDING_FROM_EDGE_OF_SHELF));
151 } 155 }
152 156
153 layer()->GetAnimator()->StopAnimating(); 157 layer()->GetAnimator()->StopAnimating();
154 StatusAreaWidgetDelegateAnimationSettings settings(layer()); 158 StatusAreaWidgetDelegateAnimationSettings settings(layer());
155 159
156 Layout(); 160 Layout();
157 UpdateWidgetSize(); 161 UpdateWidgetSize();
158 } 162 }
159 163
160 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) { 164 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) {
161 // Need to resize the window when trays or items are added/removed. 165 // Need to resize the window when trays or items are added/removed.
162 StatusAreaWidgetDelegateAnimationSettings settings(layer()); 166 StatusAreaWidgetDelegateAnimationSettings settings(layer());
163 UpdateWidgetSize(); 167 UpdateWidgetSize();
164 } 168 }
165 169
166 void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) { 170 void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) {
167 UpdateLayout(); 171 UpdateLayout();
168 } 172 }
169 173
170 void StatusAreaWidgetDelegate::UpdateWidgetSize() { 174 void StatusAreaWidgetDelegate::UpdateWidgetSize() {
171 if (GetWidget()) 175 if (GetWidget())
172 GetWidget()->SetSize(GetPreferredSize()); 176 GetWidget()->SetSize(GetPreferredSize());
173 } 177 }
174 178
175 } // namespace ash 179 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698