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

Side by Side Diff: ash/common/system/tray/tray_popup_utils.cc

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

Powered by Google App Engine
This is Rietveld 408576698