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

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

Issue 22291003: ash:Shelf Update Alternate Layout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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/ash_switches.h"
8 #include "ash/focus_cycler.h" 9 #include "ash/focus_cycler.h"
9 #include "ash/shell.h" 10 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
11 #include "ash/system/tray/tray_constants.h" 12 #include "ash/system/tray/tray_constants.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "ui/aura/root_window.h" 14 #include "ui/aura/root_window.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
17 #include "ui/views/accessible_pane_view.h" 18 #include "ui/views/accessible_pane_view.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 if (alignment_ == SHELF_ALIGNMENT_TOP) 92 if (alignment_ == SHELF_ALIGNMENT_TOP)
92 layout->SetInsets(kStatusTrayOffsetFromScreenEdge, 0, 0, 0); 93 layout->SetInsets(kStatusTrayOffsetFromScreenEdge, 0, 0, 0);
93 else 94 else
94 layout->SetInsets(0, 0, kStatusTrayOffsetFromScreenEdge, 0); 95 layout->SetInsets(0, 0, kStatusTrayOffsetFromScreenEdge, 0);
95 bool is_first_visible_child = true; 96 bool is_first_visible_child = true;
96 for (int c = 0; c < child_count(); ++c) { 97 for (int c = 0; c < child_count(); ++c) {
97 views::View* child = child_at(c); 98 views::View* child = child_at(c);
98 if (!child->visible()) 99 if (!child->visible())
99 continue; 100 continue;
100 if (!is_first_visible_child) 101 if (!is_first_visible_child)
101 columns->AddPaddingColumn(0, kTraySpacing); 102 columns->AddPaddingColumn(0, ash::switches::UseAlternateShelfLayout() ?
103 kAlternateTraySpacing : kTraySpacing);
Mr4D (OOO till 08-26) 2013/08/06 21:10:34 You might want to populate a variable before the f
Harry McCleave 2013/08/06 22:41:06 Done.
102 is_first_visible_child = false; 104 is_first_visible_child = false;
103 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 105 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL,
104 0, /* resize percent */ 106 0, /* resize percent */
105 views::GridLayout::USE_PREF, 0, 0); 107 views::GridLayout::USE_PREF, 0, 0);
106 } 108 }
107 layout->StartRow(0, 0); 109 layout->StartRow(0, 0);
108 for (int c = child_count() - 1; c >= 0; --c) { 110 for (int c = child_count() - 1; c >= 0; --c) {
109 views::View* child = child_at(c); 111 views::View* child = child_at(c);
110 if (child->visible()) 112 if (child->visible())
111 layout->AddView(child); 113 layout->AddView(child);
112 } 114 }
113 } else { 115 } else {
114 if (alignment_ == SHELF_ALIGNMENT_LEFT) 116 if (alignment_ == SHELF_ALIGNMENT_LEFT)
115 layout->SetInsets(0, kStatusTrayOffsetFromScreenEdge, 0, 0); 117 layout->SetInsets(0, kStatusTrayOffsetFromScreenEdge, 0, 0);
116 else 118 else
117 layout->SetInsets(0, 0, 0, kStatusTrayOffsetFromScreenEdge); 119 layout->SetInsets(0, 0, 0, kStatusTrayOffsetFromScreenEdge);
118 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 120 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
119 0, /* resize percent */ 121 0, /* resize percent */
120 views::GridLayout::USE_PREF, 0, 0); 122 views::GridLayout::USE_PREF, 0, 0);
121 bool is_first_visible_child = true; 123 bool is_first_visible_child = true;
122 for (int c = child_count() - 1; c >= 0; --c) { 124 for (int c = child_count() - 1; c >= 0; --c) {
123 views::View* child = child_at(c); 125 views::View* child = child_at(c);
124 if (!child->visible()) 126 if (!child->visible())
125 continue; 127 continue;
126 if (!is_first_visible_child) 128 if (!is_first_visible_child)
127 layout->AddPaddingRow(0, kTraySpacing); 129 layout->AddPaddingRow(0, ash::switches::UseAlternateShelfLayout() ?
130 kAlternateTraySpacing : kTraySpacing);
128 is_first_visible_child = false; 131 is_first_visible_child = false;
129 layout->StartRow(0, 0); 132 layout->StartRow(0, 0);
130 layout->AddView(child); 133 layout->AddView(child);
131 } 134 }
132 } 135 }
133 Layout(); 136 Layout();
134 UpdateWidgetSize(); 137 UpdateWidgetSize();
135 } 138 }
136 139
137 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) { 140 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) {
138 // Need to resize the window when trays or items are added/removed. 141 // Need to resize the window when trays or items are added/removed.
139 UpdateWidgetSize(); 142 UpdateWidgetSize();
140 } 143 }
141 144
142 void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) { 145 void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) {
143 UpdateLayout(); 146 UpdateLayout();
144 } 147 }
145 148
146 void StatusAreaWidgetDelegate::UpdateWidgetSize() { 149 void StatusAreaWidgetDelegate::UpdateWidgetSize() {
147 if (GetWidget()) 150 if (GetWidget())
148 GetWidget()->SetSize(GetPreferredSize()); 151 GetWidget()->SetSize(GetPreferredSize());
149 } 152 }
150 153
151 } // namespace internal 154 } // namespace internal
152 } // namespace ash 155 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698