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

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

Issue 198063003: Revert of Shelf Cleanup (- binary files) (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/system/session/logout_button_tray.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"
11 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
12 #include "ash/system/tray/tray_constants.h" 12 #include "ash/system/tray/tray_constants.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "ui/aura/window_event_dispatcher.h" 14 #include "ui/aura/window_event_dispatcher.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
18 #include "ui/views/accessible_pane_view.h" 18 #include "ui/views/accessible_pane_view.h"
19 #include "ui/views/layout/grid_layout.h" 19 #include "ui/views/layout/grid_layout.h"
20 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
21 21
22 namespace ash { 22 namespace ash {
23 namespace internal { 23 namespace internal {
24 namespace {
25
26 const int kStatusTrayOffsetFromScreenEdge = 4;
27
28 }
24 29
25 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate() 30 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate()
26 : focus_cycler_for_testing_(NULL), 31 : focus_cycler_for_testing_(NULL),
27 alignment_(SHELF_ALIGNMENT_BOTTOM) { 32 alignment_(SHELF_ALIGNMENT_BOTTOM) {
28 // Allow the launcher to surrender the focus to another window upon 33 // Allow the launcher to surrender the focus to another window upon
29 // navigation completion by the user. 34 // navigation completion by the user.
30 set_allow_deactivate_on_esc(true); 35 set_allow_deactivate_on_esc(true);
31 } 36 }
32 37
33 StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() { 38 StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 82
78 void StatusAreaWidgetDelegate::UpdateLayout() { 83 void StatusAreaWidgetDelegate::UpdateLayout() {
79 // 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
80 // 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.
81 views::GridLayout* layout = new views::GridLayout(this); 86 views::GridLayout* layout = new views::GridLayout(this);
82 SetLayoutManager(layout); 87 SetLayoutManager(layout);
83 88
84 views::ColumnSet* columns = layout->AddColumnSet(0); 89 views::ColumnSet* columns = layout->AddColumnSet(0);
85 if (alignment_ == SHELF_ALIGNMENT_BOTTOM || 90 if (alignment_ == SHELF_ALIGNMENT_BOTTOM ||
86 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 }
87 bool is_first_visible_child = true; 99 bool is_first_visible_child = true;
88 for (int c = 0; c < child_count(); ++c) { 100 for (int c = 0; c < child_count(); ++c) {
89 views::View* child = child_at(c); 101 views::View* child = child_at(c);
90 if (!child->visible()) 102 if (!child->visible())
91 continue; 103 continue;
92 if (!is_first_visible_child) 104 if (!is_first_visible_child)
93 columns->AddPaddingColumn(0, kTraySpacing); 105 columns->AddPaddingColumn(0, GetTraySpacing());
94 is_first_visible_child = false; 106 is_first_visible_child = false;
95 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 107 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL,
96 0, /* resize percent */ 108 0, /* resize percent */
97 views::GridLayout::USE_PREF, 0, 0); 109 views::GridLayout::USE_PREF, 0, 0);
98 } 110 }
99 layout->StartRow(0, 0); 111 layout->StartRow(0, 0);
100 for (int c = child_count() - 1; c >= 0; --c) { 112 for (int c = child_count() - 1; c >= 0; --c) {
101 views::View* child = child_at(c); 113 views::View* child = child_at(c);
102 if (child->visible()) 114 if (child->visible())
103 layout->AddView(child); 115 layout->AddView(child);
104 } 116 }
105 } 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 }
106 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 124 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
107 0, /* resize percent */ 125 0, /* resize percent */
108 views::GridLayout::USE_PREF, 0, 0); 126 views::GridLayout::USE_PREF, 0, 0);
109 bool is_first_visible_child = true; 127 bool is_first_visible_child = true;
110 for (int c = child_count() - 1; c >= 0; --c) { 128 for (int c = child_count() - 1; c >= 0; --c) {
111 views::View* child = child_at(c); 129 views::View* child = child_at(c);
112 if (!child->visible()) 130 if (!child->visible())
113 continue; 131 continue;
114 if (!is_first_visible_child) 132 if (!is_first_visible_child)
115 layout->AddPaddingRow(0, kTraySpacing); 133 layout->AddPaddingRow(0, GetTraySpacing());
116 is_first_visible_child = false; 134 is_first_visible_child = false;
117 layout->StartRow(0, 0); 135 layout->StartRow(0, 0);
118 layout->AddView(child); 136 layout->AddView(child);
119 } 137 }
120 } 138 }
121 Layout(); 139 Layout();
122 UpdateWidgetSize(); 140 UpdateWidgetSize();
123 } 141 }
124 142
125 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) { 143 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) {
126 // Need to resize the window when trays or items are added/removed. 144 // Need to resize the window when trays or items are added/removed.
127 UpdateWidgetSize(); 145 UpdateWidgetSize();
128 } 146 }
129 147
130 void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) { 148 void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) {
131 UpdateLayout(); 149 UpdateLayout();
132 } 150 }
133 151
134 void StatusAreaWidgetDelegate::UpdateWidgetSize() { 152 void StatusAreaWidgetDelegate::UpdateWidgetSize() {
135 if (GetWidget()) 153 if (GetWidget())
136 GetWidget()->SetSize(GetPreferredSize()); 154 GetWidget()->SetSize(GetPreferredSize());
137 } 155 }
138 156
139 } // namespace internal 157 } // namespace internal
140 } // namespace ash 158 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/session/logout_button_tray.cc ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698