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

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

Issue 2807693002: Make LogoutButtonTray a regular View (Closed)
Patch Set: Rebased Created 3 years, 8 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
« no previous file with comments | « ash/system/status_area_widget_delegate.h ('k') | ash/system/tray/system_tray.h » ('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/focus_cycler.h" 7 #include "ash/focus_cycler.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_constants.h" 9 #include "ash/shelf/shelf_constants.h"
10 #include "ash/shelf/wm_shelf.h" 10 #include "ash/shelf/wm_shelf.h"
11 #include "ash/shelf/wm_shelf_util.h"
12 #include "ash/shell.h" 11 #include "ash/shell.h"
13 #include "ash/system/tray/tray_constants.h" 12 #include "ash/system/tray/tray_constants.h"
14 #include "ash/wm_window.h" 13 #include "ash/wm_window.h"
15 #include "ui/compositor/layer.h" 14 #include "ui/compositor/layer.h"
16 #include "ui/compositor/scoped_layer_animation_settings.h" 15 #include "ui/compositor/scoped_layer_animation_settings.h"
17 #include "ui/gfx/animation/tween.h" 16 #include "ui/gfx/animation/tween.h"
18 #include "ui/views/accessible_pane_view.h" 17 #include "ui/views/accessible_pane_view.h"
19 #include "ui/views/border.h" 18 #include "ui/views/border.h"
20 #include "ui/views/layout/grid_layout.h" 19 #include "ui/views/layout/grid_layout.h"
21 20
(...skipping 17 matching lines...) Expand all
39 ~StatusAreaWidgetDelegateAnimationSettings() override {} 38 ~StatusAreaWidgetDelegateAnimationSettings() override {}
40 39
41 private: 40 private:
42 DISALLOW_COPY_AND_ASSIGN(StatusAreaWidgetDelegateAnimationSettings); 41 DISALLOW_COPY_AND_ASSIGN(StatusAreaWidgetDelegateAnimationSettings);
43 }; 42 };
44 43
45 } // namespace 44 } // namespace
46 45
47 namespace ash { 46 namespace ash {
48 47
49 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate() 48 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate(WmShelf* wm_shelf)
50 : focus_cycler_for_testing_(nullptr), alignment_(SHELF_ALIGNMENT_BOTTOM) { 49 : wm_shelf_(wm_shelf), focus_cycler_for_testing_(nullptr) {
50 DCHECK(wm_shelf_);
51
51 // Allow the launcher to surrender the focus to another window upon 52 // Allow the launcher to surrender the focus to another window upon
52 // navigation completion by the user. 53 // navigation completion by the user.
53 set_allow_deactivate_on_esc(true); 54 set_allow_deactivate_on_esc(true);
54 SetPaintToLayer(); 55 SetPaintToLayer();
55 layer()->SetFillsBoundsOpaquely(false); 56 layer()->SetFillsBoundsOpaquely(false);
56 } 57 }
57 58
58 StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() {} 59 StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() {}
59 60
60 void StatusAreaWidgetDelegate::SetFocusCyclerForTesting( 61 void StatusAreaWidgetDelegate::SetFocusCyclerForTesting(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 for (int c = 0; c < child_count(); ++c) { 115 for (int c = 0; c < child_count(); ++c) {
115 views::View* child = child_at(c); 116 views::View* child = child_at(c);
116 if (!child->visible()) 117 if (!child->visible())
117 continue; 118 continue;
118 SetBorderOnChild(child, is_child_on_edge); 119 SetBorderOnChild(child, is_child_on_edge);
119 is_child_on_edge = false; 120 is_child_on_edge = false;
120 } 121 }
121 122
122 views::ColumnSet* columns = layout->AddColumnSet(0); 123 views::ColumnSet* columns = layout->AddColumnSet(0);
123 124
124 if (IsHorizontalAlignment(alignment_)) { 125 if (wm_shelf_->IsHorizontalAlignment()) {
125 for (int c = child_count() - 1; c >= 0; --c) { 126 for (int c = child_count() - 1; c >= 0; --c) {
126 views::View* child = child_at(c); 127 views::View* child = child_at(c);
127 if (!child->visible()) 128 if (!child->visible())
128 continue; 129 continue;
129 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 130 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL,
130 0, /* resize percent */ 131 0, /* resize percent */
131 views::GridLayout::USE_PREF, 0, 0); 132 views::GridLayout::USE_PREF, 0, 0);
132 } 133 }
133 layout->StartRow(0, 0); 134 layout->StartRow(0, 0);
134 for (int c = child_count() - 1; c >= 0; --c) { 135 for (int c = child_count() - 1; c >= 0; --c) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 168 }
168 169
169 void StatusAreaWidgetDelegate::UpdateWidgetSize() { 170 void StatusAreaWidgetDelegate::UpdateWidgetSize() {
170 if (GetWidget()) 171 if (GetWidget())
171 GetWidget()->SetSize(GetPreferredSize()); 172 GetWidget()->SetSize(GetPreferredSize());
172 } 173 }
173 174
174 void StatusAreaWidgetDelegate::SetBorderOnChild(views::View* child, 175 void StatusAreaWidgetDelegate::SetBorderOnChild(views::View* child,
175 bool extend_border_to_edge) { 176 bool extend_border_to_edge) {
176 // Tray views are laid out right-to-left or bottom-to-top. 177 // Tray views are laid out right-to-left or bottom-to-top.
177 const bool horizontal_alignment = IsHorizontalAlignment(alignment_); 178 const bool horizontal_alignment = wm_shelf_->IsHorizontalAlignment();
178 const int padding = (kShelfSize - kTrayItemSize) / 2; 179 const int padding = (kShelfSize - kTrayItemSize) / 2;
179 180
180 const int top_edge = horizontal_alignment ? padding : 0; 181 const int top_edge = horizontal_alignment ? padding : 0;
181 const int left_edge = horizontal_alignment ? 0 : padding; 182 const int left_edge = horizontal_alignment ? 0 : padding;
182 const int bottom_edge = 183 const int bottom_edge =
183 horizontal_alignment 184 horizontal_alignment
184 ? padding 185 ? padding
185 : (extend_border_to_edge ? kPaddingFromEdgeOfShelf : 0); 186 : (extend_border_to_edge ? kPaddingFromEdgeOfShelf : 0);
186 const int right_edge = 187 const int right_edge =
187 horizontal_alignment 188 horizontal_alignment
188 ? (extend_border_to_edge ? kPaddingFromEdgeOfShelf : 0) 189 ? (extend_border_to_edge ? kPaddingFromEdgeOfShelf : 0)
189 : padding; 190 : padding;
190 child->SetBorder( 191 child->SetBorder(
191 views::CreateEmptyBorder(top_edge, left_edge, bottom_edge, right_edge)); 192 views::CreateEmptyBorder(top_edge, left_edge, bottom_edge, right_edge));
192 193
193 // Layout on |child| needs to be updated based on new border value before 194 // Layout on |child| needs to be updated based on new border value before
194 // displaying; otherwise |child| will be showing with old border size. 195 // displaying; otherwise |child| will be showing with old border size.
195 // Fix for crbug.com/623438. 196 // Fix for crbug.com/623438.
196 child->Layout(); 197 child->Layout();
197 } 198 }
198 199
199 } // namespace ash 200 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/status_area_widget_delegate.h ('k') | ash/system/tray/system_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698