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

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

Issue 14731020: Merge 199451 "Removes the space for notification icon if it's no..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1500/src/
Patch Set: Created 7 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 | Annotate | Revision Log
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/focus_cycler.h" 8 #include "ash/focus_cycler.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 void StatusAreaWidgetDelegate::UpdateLayout() { 77 void StatusAreaWidgetDelegate::UpdateLayout() {
78 // Use a grid layout so that the trays can be centered in each cell, and 78 // Use a grid layout so that the trays can be centered in each cell, and
79 // so that the widget gets laid out correctly when tray sizes change. 79 // so that the widget gets laid out correctly when tray sizes change.
80 views::GridLayout* layout = new views::GridLayout(this); 80 views::GridLayout* layout = new views::GridLayout(this);
81 SetLayoutManager(layout); 81 SetLayoutManager(layout);
82 82
83 views::ColumnSet* columns = layout->AddColumnSet(0); 83 views::ColumnSet* columns = layout->AddColumnSet(0);
84 if (alignment_ == SHELF_ALIGNMENT_BOTTOM || 84 if (alignment_ == SHELF_ALIGNMENT_BOTTOM ||
85 alignment_ == SHELF_ALIGNMENT_TOP) { 85 alignment_ == SHELF_ALIGNMENT_TOP) {
86 bool is_first_visible_child = true;
86 for (int c = 0; c < child_count(); ++c) { 87 for (int c = 0; c < child_count(); ++c) {
87 if (c != 0) 88 views::View* child = child_at(c);
89 if (!child->visible())
90 continue;
91 if (!is_first_visible_child)
88 columns->AddPaddingColumn(0, kTraySpacing); 92 columns->AddPaddingColumn(0, kTraySpacing);
93 is_first_visible_child = false;
89 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 94 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL,
90 0, /* resize percent */ 95 0, /* resize percent */
91 views::GridLayout::USE_PREF, 0, 0); 96 views::GridLayout::USE_PREF, 0, 0);
92 } 97 }
93 layout->StartRow(0, 0); 98 layout->StartRow(0, 0);
94 for (int c = child_count() - 1; c >= 0; --c) 99 for (int c = child_count() - 1; c >= 0; --c) {
95 layout->AddView(child_at(c)); 100 views::View* child = child_at(c);
101 if (child->visible())
102 layout->AddView(child);
103 }
96 } else { 104 } else {
97 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 105 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
98 0, /* resize percent */ 106 0, /* resize percent */
99 views::GridLayout::USE_PREF, 0, 0); 107 views::GridLayout::USE_PREF, 0, 0);
108 bool is_first_visible_child = true;
100 for (int c = child_count() - 1; c >= 0; --c) { 109 for (int c = child_count() - 1; c >= 0; --c) {
101 if (c != child_count() - 1) 110 views::View* child = child_at(c);
111 if (!child->visible())
112 continue;
113 if (!is_first_visible_child)
102 layout->AddPaddingRow(0, kTraySpacing); 114 layout->AddPaddingRow(0, kTraySpacing);
115 is_first_visible_child = false;
103 layout->StartRow(0, 0); 116 layout->StartRow(0, 0);
104 layout->AddView(child_at(c)); 117 layout->AddView(child);
105 } 118 }
106 } 119 }
107 Layout(); 120 Layout();
108 UpdateWidgetSize(); 121 UpdateWidgetSize();
109 } 122 }
110 123
111 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) { 124 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) {
112 // Need to resize the window when trays or items are added/removed. 125 // Need to resize the window when trays or items are added/removed.
113 UpdateWidgetSize(); 126 UpdateWidgetSize();
114 } 127 }
115 128
129 void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) {
130 UpdateLayout();
131 }
132
116 void StatusAreaWidgetDelegate::UpdateWidgetSize() { 133 void StatusAreaWidgetDelegate::UpdateWidgetSize() {
117 if (GetWidget()) 134 if (GetWidget())
118 GetWidget()->SetSize(GetPreferredSize()); 135 GetWidget()->SetSize(GetPreferredSize());
119 } 136 }
120 137
121 } // namespace internal 138 } // namespace internal
122 } // namespace ash 139 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/status_area_widget_delegate.h ('k') | ash/wm/panels/panel_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698