OLD | NEW |
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 Loading... |
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 if (alignment_ == SHELF_ALIGNMENT_TOP) | 92 // Alternate shelf layout insets are all handled by tray_background_view. |
93 layout->SetInsets(kStatusTrayOffsetFromScreenEdge, 0, 0, 0); | 93 if (!ash::switches::UseAlternateShelfLayout()) { |
94 else | 94 if (alignment_ == SHELF_ALIGNMENT_TOP) |
95 layout->SetInsets(0, 0, kStatusTrayOffsetFromScreenEdge, 0); | 95 layout->SetInsets(kStatusTrayOffsetFromScreenEdge, 0, 0, 0); |
| 96 else |
| 97 layout->SetInsets(0, 0, kStatusTrayOffsetFromScreenEdge, 0); |
| 98 } |
96 bool is_first_visible_child = true; | 99 bool is_first_visible_child = true; |
97 for (int c = 0; c < child_count(); ++c) { | 100 for (int c = 0; c < child_count(); ++c) { |
98 views::View* child = child_at(c); | 101 views::View* child = child_at(c); |
99 if (!child->visible()) | 102 if (!child->visible()) |
100 continue; | 103 continue; |
101 if (!is_first_visible_child) | 104 if (!is_first_visible_child) |
102 columns->AddPaddingColumn(0, GetTraySpacing()); | 105 columns->AddPaddingColumn(0, GetTraySpacing()); |
103 is_first_visible_child = false; | 106 is_first_visible_child = false; |
104 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, | 107 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, |
105 0, /* resize percent */ | 108 0, /* resize percent */ |
106 views::GridLayout::USE_PREF, 0, 0); | 109 views::GridLayout::USE_PREF, 0, 0); |
107 } | 110 } |
108 layout->StartRow(0, 0); | 111 layout->StartRow(0, 0); |
109 for (int c = child_count() - 1; c >= 0; --c) { | 112 for (int c = child_count() - 1; c >= 0; --c) { |
110 views::View* child = child_at(c); | 113 views::View* child = child_at(c); |
111 if (child->visible()) | 114 if (child->visible()) |
112 layout->AddView(child); | 115 layout->AddView(child); |
113 } | 116 } |
114 } else { | 117 } else { |
115 if (alignment_ == SHELF_ALIGNMENT_LEFT) | 118 if (!ash::switches::UseAlternateShelfLayout()) { |
116 layout->SetInsets(0, kStatusTrayOffsetFromScreenEdge, 0, 0); | 119 if (alignment_ == SHELF_ALIGNMENT_LEFT) |
117 else | 120 layout->SetInsets(0, kStatusTrayOffsetFromScreenEdge, 0, 0); |
118 layout->SetInsets(0, 0, 0, kStatusTrayOffsetFromScreenEdge); | 121 else |
| 122 layout->SetInsets(0, 0, 0, kStatusTrayOffsetFromScreenEdge); |
| 123 } |
119 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, | 124 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, |
120 0, /* resize percent */ | 125 0, /* resize percent */ |
121 views::GridLayout::USE_PREF, 0, 0); | 126 views::GridLayout::USE_PREF, 0, 0); |
122 bool is_first_visible_child = true; | 127 bool is_first_visible_child = true; |
123 for (int c = child_count() - 1; c >= 0; --c) { | 128 for (int c = child_count() - 1; c >= 0; --c) { |
124 views::View* child = child_at(c); | 129 views::View* child = child_at(c); |
125 if (!child->visible()) | 130 if (!child->visible()) |
126 continue; | 131 continue; |
127 if (!is_first_visible_child) | 132 if (!is_first_visible_child) |
128 layout->AddPaddingRow(0, GetTraySpacing()); | 133 layout->AddPaddingRow(0, GetTraySpacing()); |
(...skipping 15 matching lines...) Expand all Loading... |
144 UpdateLayout(); | 149 UpdateLayout(); |
145 } | 150 } |
146 | 151 |
147 void StatusAreaWidgetDelegate::UpdateWidgetSize() { | 152 void StatusAreaWidgetDelegate::UpdateWidgetSize() { |
148 if (GetWidget()) | 153 if (GetWidget()) |
149 GetWidget()->SetSize(GetPreferredSize()); | 154 GetWidget()->SetSize(GetPreferredSize()); |
150 } | 155 } |
151 | 156 |
152 } // namespace internal | 157 } // namespace internal |
153 } // namespace ash | 158 } // namespace ash |
OLD | NEW |