| 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/common/system/tray/tray_popup_utils.h" | 5 #include "ash/common/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/common/ash_constants.h" | 10 #include "ash/common/ash_constants.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 return nullptr; | 79 return nullptr; |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Configures the default size and flex value for the specified |container| | 82 // Configures the default size and flex value for the specified |container| |
| 83 // of the given |tri_view|. Used by CreateDefaultRowView(). | 83 // of the given |tri_view|. Used by CreateDefaultRowView(). |
| 84 void ConfigureDefaultSizeAndFlex(TriView* tri_view, | 84 void ConfigureDefaultSizeAndFlex(TriView* tri_view, |
| 85 TriView::Container container) { | 85 TriView::Container container) { |
| 86 int min_width = 0; | 86 int min_width = 0; |
| 87 switch (container) { | 87 switch (container) { |
| 88 case TriView::Container::START: | 88 case TriView::Container::START: |
| 89 min_width = GetTrayConstant(TRAY_POPUP_ITEM_MIN_START_WIDTH); | 89 min_width = kTrayPopupItemMinStartWidth; |
| 90 break; | 90 break; |
| 91 case TriView::Container::CENTER: | 91 case TriView::Container::CENTER: |
| 92 tri_view->SetFlexForContainer(TriView::Container::CENTER, 1.f); | 92 tri_view->SetFlexForContainer(TriView::Container::CENTER, 1.f); |
| 93 break; | 93 break; |
| 94 case TriView::Container::END: | 94 case TriView::Container::END: |
| 95 min_width = GetTrayConstant(TRAY_POPUP_ITEM_MIN_END_WIDTH); | 95 min_width = kTrayPopupItemMinEndWidth; |
| 96 break; | 96 break; |
| 97 } | 97 } |
| 98 | 98 |
| 99 tri_view->SetMinSize( | 99 tri_view->SetMinSize(container, |
| 100 gfx::Size(min_width, kTrayPopupItemMinHeight)); |
| 101 constexpr int kTrayPopupItemMaxHeight = 144; |
| 102 tri_view->SetMaxSize( |
| 100 container, | 103 container, |
| 101 gfx::Size(min_width, GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT))); | 104 gfx::Size(SizeRangeLayout::kAbsoluteMaxSize, kTrayPopupItemMaxHeight)); |
| 102 tri_view->SetMaxSize(container, | |
| 103 gfx::Size(SizeRangeLayout::kAbsoluteMaxSize, | |
| 104 GetTrayConstant(TRAY_POPUP_ITEM_MAX_HEIGHT))); | |
| 105 } | 105 } |
| 106 | 106 |
| 107 class BorderlessLabelButton : public views::LabelButton { | 107 class BorderlessLabelButton : public views::LabelButton { |
| 108 public: | 108 public: |
| 109 BorderlessLabelButton(views::ButtonListener* listener, | 109 BorderlessLabelButton(views::ButtonListener* listener, |
| 110 const base::string16& text) | 110 const base::string16& text) |
| 111 : LabelButton(listener, text) { | 111 : LabelButton(listener, text) { |
| 112 const int kHorizontalPadding = 20; | 112 const int kHorizontalPadding = 20; |
| 113 SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kHorizontalPadding))); | 113 SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kHorizontalPadding))); |
| 114 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::BUTTON); | 114 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::BUTTON); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 tri_view->SetContainerVisible(TriView::Container::START, false); | 176 tri_view->SetContainerVisible(TriView::Container::START, false); |
| 177 tri_view->SetContainerLayout( | 177 tri_view->SetContainerLayout( |
| 178 TriView::Container::END, | 178 TriView::Container::END, |
| 179 CreateDefaultLayoutManager(TriView::Container::END)); | 179 CreateDefaultLayoutManager(TriView::Container::END)); |
| 180 return tri_view; | 180 return tri_view; |
| 181 } | 181 } |
| 182 | 182 |
| 183 TriView* TrayPopupUtils::CreateMultiTargetRowView() { | 183 TriView* TrayPopupUtils::CreateMultiTargetRowView() { |
| 184 TriView* tri_view = new TriView(0 /* padding_between_items */); | 184 TriView* tri_view = new TriView(0 /* padding_between_items */); |
| 185 | 185 |
| 186 tri_view->SetInsets( | 186 tri_view->SetInsets(gfx::Insets(0, kMenuExtraMarginFromLeftEdge, 0, 0)); |
| 187 gfx::Insets(0, GetTrayConstant(TRAY_POPUP_ITEM_LEFT_INSET), 0, 0)); | |
| 188 | 187 |
| 189 ConfigureDefaultSizeAndFlex(tri_view, TriView::Container::START); | 188 ConfigureDefaultSizeAndFlex(tri_view, TriView::Container::START); |
| 190 ConfigureDefaultSizeAndFlex(tri_view, TriView::Container::CENTER); | 189 ConfigureDefaultSizeAndFlex(tri_view, TriView::Container::CENTER); |
| 191 ConfigureDefaultSizeAndFlex(tri_view, TriView::Container::END); | 190 ConfigureDefaultSizeAndFlex(tri_view, TriView::Container::END); |
| 192 | 191 |
| 193 tri_view->SetContainerLayout(TriView::Container::START, | 192 tri_view->SetContainerLayout(TriView::Container::START, |
| 194 base::MakeUnique<views::FillLayout>()); | 193 base::MakeUnique<views::FillLayout>()); |
| 195 tri_view->SetContainerLayout(TriView::Container::CENTER, | 194 tri_view->SetContainerLayout(TriView::Container::CENTER, |
| 196 base::MakeUnique<views::FillLayout>()); | 195 base::MakeUnique<views::FillLayout>()); |
| 197 tri_view->SetContainerLayout(TriView::Container::END, | 196 tri_view->SetContainerLayout(TriView::Container::END, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 208 // Frequently the label will paint to a layer that's non-opaque, so subpixel | 207 // Frequently the label will paint to a layer that's non-opaque, so subpixel |
| 209 // rendering won't work unless we explicitly set a background. See | 208 // rendering won't work unless we explicitly set a background. See |
| 210 // crbug.com/686363 | 209 // crbug.com/686363 |
| 211 label->set_background( | 210 label->set_background( |
| 212 views::Background::CreateSolidBackground(kBackgroundColor)); | 211 views::Background::CreateSolidBackground(kBackgroundColor)); |
| 213 label->SetBackgroundColor(kBackgroundColor); | 212 label->SetBackgroundColor(kBackgroundColor); |
| 214 return label; | 213 return label; |
| 215 } | 214 } |
| 216 | 215 |
| 217 views::ImageView* TrayPopupUtils::CreateMainImageView() { | 216 views::ImageView* TrayPopupUtils::CreateMainImageView() { |
| 218 return new FixedSizedImageView( | 217 return new FixedSizedImageView(kTrayPopupItemMinStartWidth, |
| 219 GetTrayConstant(TRAY_POPUP_ITEM_MAIN_IMAGE_CONTAINER_WIDTH), | 218 kTrayPopupItemMinHeight); |
| 220 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); | |
| 221 } | 219 } |
| 222 | 220 |
| 223 views::ImageView* TrayPopupUtils::CreateMoreImageView() { | 221 views::ImageView* TrayPopupUtils::CreateMoreImageView() { |
| 224 views::ImageView* image = | 222 views::ImageView* image = |
| 225 new FixedSizedImageView(GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE), | 223 new FixedSizedImageView(kMenuIconSize, kMenuIconSize); |
| 226 GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE)); | |
| 227 image->EnableCanvasFlippingForRTLUI(true); | 224 image->EnableCanvasFlippingForRTLUI(true); |
| 228 return image; | 225 return image; |
| 229 } | 226 } |
| 230 | 227 |
| 231 views::Slider* TrayPopupUtils::CreateSlider(views::SliderListener* listener) { | 228 views::Slider* TrayPopupUtils::CreateSlider(views::SliderListener* listener) { |
| 232 views::Slider* slider = new views::Slider(listener); | 229 views::Slider* slider = new views::Slider(listener); |
| 233 slider->SetBorder(views::CreateEmptyBorder(gfx::Insets(0, 16))); | 230 slider->SetBorder(views::CreateEmptyBorder(gfx::Insets(0, 16))); |
| 234 return slider; | 231 return slider; |
| 235 } | 232 } |
| 236 | 233 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { | 424 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { |
| 428 // TODO(tdanderson): Consider moving this into WmShell, or introduce a | 425 // TODO(tdanderson): Consider moving this into WmShell, or introduce a |
| 429 // CanShowSettings() method in each delegate type that has a | 426 // CanShowSettings() method in each delegate type that has a |
| 430 // ShowSettings() method. | 427 // ShowSettings() method. |
| 431 return status != LoginStatus::NOT_LOGGED_IN && | 428 return status != LoginStatus::NOT_LOGGED_IN && |
| 432 status != LoginStatus::LOCKED && | 429 status != LoginStatus::LOCKED && |
| 433 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 430 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 434 } | 431 } |
| 435 | 432 |
| 436 } // namespace ash | 433 } // namespace ash |
| OLD | NEW |