OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/tray/tray_popup_utils.h" | 5 #include "ash/system/tray/tray_popup_utils.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "ui/views/painter.h" | 41 #include "ui/views/painter.h" |
42 | 42 |
43 namespace ash { | 43 namespace ash { |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 // Creates a layout manager that positions Views vertically. The Views will be | 47 // Creates a layout manager that positions Views vertically. The Views will be |
48 // stretched horizontally and centered vertically. | 48 // stretched horizontally and centered vertically. |
49 std::unique_ptr<views::LayoutManager> CreateDefaultCenterLayoutManager() { | 49 std::unique_ptr<views::LayoutManager> CreateDefaultCenterLayoutManager() { |
50 // TODO(bruthig): Use constants instead of magic numbers. | 50 // TODO(bruthig): Use constants instead of magic numbers. |
51 auto box_layout = | 51 auto box_layout = base::MakeUnique<views::BoxLayout>( |
52 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kVertical, 4, 8, 0); | 52 views::BoxLayout::kVertical, kTrayPopupLabelHorizontalPadding, 8, 0); |
53 box_layout->set_main_axis_alignment( | 53 box_layout->set_main_axis_alignment( |
54 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); | 54 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
55 box_layout->set_cross_axis_alignment( | 55 box_layout->set_cross_axis_alignment( |
56 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); | 56 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); |
57 return std::move(box_layout); | 57 return std::move(box_layout); |
58 } | 58 } |
59 | 59 |
60 // Creates a layout manager that positions Views horizontally. The Views will be | 60 // Creates a layout manager that positions Views horizontally. The Views will be |
61 // centered along the horizontal and vertical axis. | 61 // centered along the horizontal and vertical axis. |
62 std::unique_ptr<views::LayoutManager> CreateDefaultEndsLayoutManager() { | 62 std::unique_ptr<views::LayoutManager> CreateDefaultEndsLayoutManager() { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 tri_view->SetContainerLayout( | 167 tri_view->SetContainerLayout( |
168 TriView::Container::CENTER, | 168 TriView::Container::CENTER, |
169 CreateDefaultLayoutManager(TriView::Container::CENTER)); | 169 CreateDefaultLayoutManager(TriView::Container::CENTER)); |
170 tri_view->SetContainerLayout( | 170 tri_view->SetContainerLayout( |
171 TriView::Container::END, | 171 TriView::Container::END, |
172 CreateDefaultLayoutManager(TriView::Container::END)); | 172 CreateDefaultLayoutManager(TriView::Container::END)); |
173 | 173 |
174 return tri_view; | 174 return tri_view; |
175 } | 175 } |
176 | 176 |
177 TriView* TrayPopupUtils::CreateSubHeaderRowView() { | 177 TriView* TrayPopupUtils::CreateSubHeaderRowView(bool start_visible) { |
178 TriView* tri_view = CreateMultiTargetRowView(); | 178 TriView* tri_view = CreateDefaultRowView(); |
179 tri_view->SetInsets(gfx::Insets(0, kTrayPopupPaddingHorizontal, 0, 0)); | 179 if (!start_visible) { |
180 tri_view->SetContainerVisible(TriView::Container::START, false); | 180 tri_view->SetInsets(gfx::Insets( |
181 tri_view->SetContainerLayout( | 181 0, kTrayPopupPaddingHorizontal - kTrayPopupLabelHorizontalPadding, 0, |
182 TriView::Container::END, | 182 0)); |
183 CreateDefaultLayoutManager(TriView::Container::END)); | 183 tri_view->SetContainerVisible(TriView::Container::START, false); |
| 184 } |
184 return tri_view; | 185 return tri_view; |
185 } | 186 } |
186 | 187 |
187 views::View* TrayPopupUtils::CreateInfoLabelRowView(int message_id) { | 188 views::View* TrayPopupUtils::CreateInfoLabelRowView(int message_id) { |
188 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); | 189 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); |
189 label->SetText(l10n_util::GetStringUTF16(message_id)); | 190 label->SetText(l10n_util::GetStringUTF16(message_id)); |
190 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SYSTEM_INFO); | 191 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SYSTEM_INFO); |
191 style.SetupLabel(label); | 192 style.SetupLabel(label); |
192 | 193 |
193 TriView* tri_view = CreateMultiTargetRowView(); | 194 TriView* tri_view = CreateMultiTargetRowView(); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 457 |
457 void TrayPopupUtils::UpdateCheckMarkVisibility(HoverHighlightView* container, | 458 void TrayPopupUtils::UpdateCheckMarkVisibility(HoverHighlightView* container, |
458 bool visible) { | 459 bool visible) { |
459 container->SetRightViewVisible(visible); | 460 container->SetRightViewVisible(visible); |
460 container->SetAccessiblityState( | 461 container->SetAccessiblityState( |
461 visible ? HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX | 462 visible ? HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX |
462 : HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); | 463 : HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); |
463 } | 464 } |
464 | 465 |
465 } // namespace ash | 466 } // namespace ash |
OLD | NEW |