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

Side by Side Diff: ash/system/tray/tray_container.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/tray/tray_container.h ('k') | ash/system/tray/tray_item_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/system/tray/tray_container.h"
6
7 #include <utility>
8
9 #include "ash/shelf/wm_shelf.h"
10 #include "ash/system/tray/tray_constants.h"
11 #include "ui/gfx/geometry/insets.h"
12 #include "ui/views/border.h"
13 #include "ui/views/layout/box_layout.h"
14
15 namespace ash {
16
17 TrayContainer::TrayContainer(WmShelf* wm_shelf) : wm_shelf_(wm_shelf) {
18 DCHECK(wm_shelf_);
19
20 UpdateLayout();
21 }
22
23 TrayContainer::~TrayContainer() {}
24
25 void TrayContainer::UpdateAfterShelfAlignmentChange() {
26 UpdateLayout();
27 }
28
29 void TrayContainer::SetMargin(int main_axis_margin, int cross_axis_margin) {
30 main_axis_margin_ = main_axis_margin;
31 cross_axis_margin_ = cross_axis_margin;
32 UpdateLayout();
33 }
34
35 void TrayContainer::ChildPreferredSizeChanged(views::View* child) {
36 PreferredSizeChanged();
37 }
38
39 void TrayContainer::ChildVisibilityChanged(View* child) {
40 PreferredSizeChanged();
41 }
42
43 void TrayContainer::ViewHierarchyChanged(
44 const ViewHierarchyChangedDetails& details) {
45 if (details.parent == this)
46 PreferredSizeChanged();
47 }
48
49 void TrayContainer::UpdateLayout() {
50 const bool is_horizontal = wm_shelf_->IsHorizontalAlignment();
51
52 // Adjust the size of status tray dark background by adding additional
53 // empty border.
54 views::BoxLayout::Orientation orientation =
55 is_horizontal ? views::BoxLayout::kHorizontal
56 : views::BoxLayout::kVertical;
57
58 const int hit_region_with_separator = kHitRegionPadding + kSeparatorWidth;
59 gfx::Insets insets(
60 is_horizontal
61 ? gfx::Insets(0, kHitRegionPadding, 0, hit_region_with_separator)
62 : gfx::Insets(kHitRegionPadding, 0, hit_region_with_separator, 0));
63 if (base::i18n::IsRTL())
64 insets.Set(insets.top(), insets.right(), insets.bottom(), insets.left());
65 SetBorder(views::CreateEmptyBorder(insets));
66
67 int horizontal_margin = main_axis_margin_;
68 int vertical_margin = cross_axis_margin_;
69 if (!is_horizontal)
70 std::swap(horizontal_margin, vertical_margin);
71 views::BoxLayout* layout =
72 new views::BoxLayout(orientation, horizontal_margin, vertical_margin, 0);
73
74 layout->set_minimum_cross_axis_size(kTrayItemSize);
75 views::View::SetLayoutManager(layout);
76
77 PreferredSizeChanged();
78 }
79
80 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_container.h ('k') | ash/system/tray/tray_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698