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

Side by Side Diff: ash/system/status_area_widget_delegate.cc

Issue 185143002: Revert of Ash:Shelf - Cleanup of Alternate Shelf (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ash/shelf/shelf_view_unittest.cc ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shell.h" 10 #include "ash/shell.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 void StatusAreaWidgetDelegate::UpdateLayout() { 83 void StatusAreaWidgetDelegate::UpdateLayout() {
84 // Use a grid layout so that the trays can be centered in each cell, and 84 // Use a grid layout so that the trays can be centered in each cell, and
85 // so that the widget gets laid out correctly when tray sizes change. 85 // so that the widget gets laid out correctly when tray sizes change.
86 views::GridLayout* layout = new views::GridLayout(this); 86 views::GridLayout* layout = new views::GridLayout(this);
87 SetLayoutManager(layout); 87 SetLayoutManager(layout);
88 88
89 views::ColumnSet* columns = layout->AddColumnSet(0); 89 views::ColumnSet* columns = layout->AddColumnSet(0);
90 if (alignment_ == SHELF_ALIGNMENT_BOTTOM || 90 if (alignment_ == SHELF_ALIGNMENT_BOTTOM ||
91 alignment_ == SHELF_ALIGNMENT_TOP) { 91 alignment_ == SHELF_ALIGNMENT_TOP) {
92 // Alternate shelf layout insets are all handled by tray_background_view.
93 if (!ash::switches::UseAlternateShelfLayout()) {
94 if (alignment_ == SHELF_ALIGNMENT_TOP)
95 layout->SetInsets(kStatusTrayOffsetFromScreenEdge, 0, 0, 0);
96 else
97 layout->SetInsets(0, 0, kStatusTrayOffsetFromScreenEdge, 0);
98 }
92 bool is_first_visible_child = true; 99 bool is_first_visible_child = true;
93 for (int c = 0; c < child_count(); ++c) { 100 for (int c = 0; c < child_count(); ++c) {
94 views::View* child = child_at(c); 101 views::View* child = child_at(c);
95 if (!child->visible()) 102 if (!child->visible())
96 continue; 103 continue;
97 if (!is_first_visible_child) 104 if (!is_first_visible_child)
98 columns->AddPaddingColumn(0, GetTraySpacing()); 105 columns->AddPaddingColumn(0, GetTraySpacing());
99 is_first_visible_child = false; 106 is_first_visible_child = false;
100 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 107 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL,
101 0, /* resize percent */ 108 0, /* resize percent */
102 views::GridLayout::USE_PREF, 0, 0); 109 views::GridLayout::USE_PREF, 0, 0);
103 } 110 }
104 layout->StartRow(0, 0); 111 layout->StartRow(0, 0);
105 for (int c = child_count() - 1; c >= 0; --c) { 112 for (int c = child_count() - 1; c >= 0; --c) {
106 views::View* child = child_at(c); 113 views::View* child = child_at(c);
107 if (child->visible()) 114 if (child->visible())
108 layout->AddView(child); 115 layout->AddView(child);
109 } 116 }
110 } else { 117 } else {
118 if (!ash::switches::UseAlternateShelfLayout()) {
119 if (alignment_ == SHELF_ALIGNMENT_LEFT)
120 layout->SetInsets(0, kStatusTrayOffsetFromScreenEdge, 0, 0);
121 else
122 layout->SetInsets(0, 0, 0, kStatusTrayOffsetFromScreenEdge);
123 }
111 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 124 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
112 0, /* resize percent */ 125 0, /* resize percent */
113 views::GridLayout::USE_PREF, 0, 0); 126 views::GridLayout::USE_PREF, 0, 0);
114 bool is_first_visible_child = true; 127 bool is_first_visible_child = true;
115 for (int c = child_count() - 1; c >= 0; --c) { 128 for (int c = child_count() - 1; c >= 0; --c) {
116 views::View* child = child_at(c); 129 views::View* child = child_at(c);
117 if (!child->visible()) 130 if (!child->visible())
118 continue; 131 continue;
119 if (!is_first_visible_child) 132 if (!is_first_visible_child)
120 layout->AddPaddingRow(0, GetTraySpacing()); 133 layout->AddPaddingRow(0, GetTraySpacing());
(...skipping 15 matching lines...) Expand all
136 UpdateLayout(); 149 UpdateLayout();
137 } 150 }
138 151
139 void StatusAreaWidgetDelegate::UpdateWidgetSize() { 152 void StatusAreaWidgetDelegate::UpdateWidgetSize() {
140 if (GetWidget()) 153 if (GetWidget())
141 GetWidget()->SetSize(GetPreferredSize()); 154 GetWidget()->SetSize(GetPreferredSize());
142 } 155 }
143 156
144 } // namespace internal 157 } // namespace internal
145 } // namespace ash 158 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_view_unittest.cc ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698