| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "ui/views/painter.h" | 42 #include "ui/views/painter.h" |
| 43 | 43 |
| 44 namespace ash { | 44 namespace ash { |
| 45 | 45 |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 // Creates a layout manager that positions Views vertically. The Views will be | 48 // Creates a layout manager that positions Views vertically. The Views will be |
| 49 // stretched horizontally and centered vertically. | 49 // stretched horizontally and centered vertically. |
| 50 std::unique_ptr<views::LayoutManager> CreateDefaultCenterLayoutManager() { | 50 std::unique_ptr<views::LayoutManager> CreateDefaultCenterLayoutManager() { |
| 51 // TODO(bruthig): Use constants instead of magic numbers. | 51 // TODO(bruthig): Use constants instead of magic numbers. |
| 52 auto box_layout = | 52 auto box_layout = base::MakeUnique<views::BoxLayout>( |
| 53 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kVertical, 4, 8, 0); | 53 views::BoxLayout::kVertical, kTrayPopupLabelHorizontalPadding, 8, 0); |
| 54 box_layout->set_main_axis_alignment( | 54 box_layout->set_main_axis_alignment( |
| 55 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); | 55 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
| 56 box_layout->set_cross_axis_alignment( | 56 box_layout->set_cross_axis_alignment( |
| 57 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); | 57 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); |
| 58 return std::move(box_layout); | 58 return std::move(box_layout); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Creates a layout manager that positions Views horizontally. The Views will be | 61 // Creates a layout manager that positions Views horizontally. The Views will be |
| 62 // centered along the horizontal and vertical axis. | 62 // centered along the horizontal and vertical axis. |
| 63 std::unique_ptr<views::LayoutManager> CreateDefaultEndsLayoutManager() { | 63 std::unique_ptr<views::LayoutManager> CreateDefaultEndsLayoutManager() { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 tri_view->SetContainerLayout( | 168 tri_view->SetContainerLayout( |
| 169 TriView::Container::CENTER, | 169 TriView::Container::CENTER, |
| 170 CreateDefaultLayoutManager(TriView::Container::CENTER)); | 170 CreateDefaultLayoutManager(TriView::Container::CENTER)); |
| 171 tri_view->SetContainerLayout( | 171 tri_view->SetContainerLayout( |
| 172 TriView::Container::END, | 172 TriView::Container::END, |
| 173 CreateDefaultLayoutManager(TriView::Container::END)); | 173 CreateDefaultLayoutManager(TriView::Container::END)); |
| 174 | 174 |
| 175 return tri_view; | 175 return tri_view; |
| 176 } | 176 } |
| 177 | 177 |
| 178 TriView* TrayPopupUtils::CreateSubHeaderRowView() { | 178 TriView* TrayPopupUtils::CreateSubHeaderRowView(bool start_visible) { |
| 179 TriView* tri_view = CreateMultiTargetRowView(); | 179 TriView* tri_view = CreateDefaultRowView(); |
| 180 tri_view->SetInsets(gfx::Insets(0, kTrayPopupPaddingHorizontal, 0, 0)); | 180 if (!start_visible) { |
| 181 tri_view->SetContainerVisible(TriView::Container::START, false); | 181 tri_view->SetInsets(gfx::Insets( |
| 182 tri_view->SetContainerLayout( | 182 0, kTrayPopupPaddingHorizontal - kTrayPopupLabelHorizontalPadding, 0, |
| 183 TriView::Container::END, | 183 0)); |
| 184 CreateDefaultLayoutManager(TriView::Container::END)); | 184 tri_view->SetContainerVisible(TriView::Container::START, false); |
| 185 } |
| 185 return tri_view; | 186 return tri_view; |
| 186 } | 187 } |
| 187 | 188 |
| 188 views::View* TrayPopupUtils::CreateInfoLabelRowView(int message_id) { | 189 views::View* TrayPopupUtils::CreateInfoLabelRowView(int message_id) { |
| 189 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); | 190 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); |
| 190 label->SetText(l10n_util::GetStringUTF16(message_id)); | 191 label->SetText(l10n_util::GetStringUTF16(message_id)); |
| 191 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SYSTEM_INFO); | 192 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SYSTEM_INFO); |
| 192 style.SetupLabel(label); | 193 style.SetupLabel(label); |
| 193 | 194 |
| 194 TriView* tri_view = CreateMultiTargetRowView(); | 195 TriView* tri_view = CreateMultiTargetRowView(); |
| (...skipping 261 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 |