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