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

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

Issue 2527513002: Update ash shelf/tray focus rects. (Closed)
Patch Set: fixes Created 4 years, 1 month 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 "ash/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/ash_view_ids.h" 8 #include "ash/common/ash_view_ids.h"
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 : LabelButton(listener, text) { 110 : LabelButton(listener, text) {
111 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 111 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
112 SetInkDropMode(views::InkDropHostView::InkDropMode::ON); 112 SetInkDropMode(views::InkDropHostView::InkDropMode::ON);
113 set_has_ink_drop_action_on_click(true); 113 set_has_ink_drop_action_on_click(true);
114 set_ink_drop_base_color(kTrayPopupInkDropBaseColor); 114 set_ink_drop_base_color(kTrayPopupInkDropBaseColor);
115 set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity); 115 set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity);
116 const int kHorizontalPadding = 8; 116 const int kHorizontalPadding = 8;
117 SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kHorizontalPadding))); 117 SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kHorizontalPadding)));
118 TrayPopupItemStyle style(nullptr, TrayPopupItemStyle::FontStyle::BUTTON); 118 TrayPopupItemStyle style(nullptr, TrayPopupItemStyle::FontStyle::BUTTON);
119 style.SetupLabel(label()); 119 style.SetupLabel(label());
120 // TODO(tdanderson): Update focus rect for material design. See
121 // crbug.com/615892
122 // Hack alert: CreateSolidFocusPainter should add 0.5f to all insets to
123 // make the lines align to pixel centers, but for now it doesn't. We can
124 // get around this by relying on Skia rounding up integer coordinates.
125 SetFocusPainter(views::Painter::CreateSolidFocusPainter( 120 SetFocusPainter(views::Painter::CreateSolidFocusPainter(
126 kFocusBorderColor, gfx::Insets(0, 0, 1, 1))); 121 kFocusBorderColor, kFocusBorderThickness, gfx::InsetsF()));
tdanderson 2016/11/23 02:19:07 optional: consider adding a GetFocusPainter() to T
Evan Stade 2016/11/28 19:05:53 Done.
127 } else { 122 } else {
128 SetBorder(std::unique_ptr<views::Border>(new TrayPopupLabelButtonBorder)); 123 SetBorder(std::unique_ptr<views::Border>(new TrayPopupLabelButtonBorder));
129 SetFocusPainter(views::Painter::CreateSolidFocusPainter( 124 SetFocusPainter(views::Painter::CreateSolidFocusPainter(
130 kFocusBorderColor, gfx::Insets(1, 1, 2, 2))); 125 kFocusBorderColor, gfx::Insets(1, 1, 2, 2)));
131 set_animate_on_state_change(false); 126 set_animate_on_state_change(false);
132 } 127 }
133 SetHorizontalAlignment(gfx::ALIGN_CENTER); 128 SetHorizontalAlignment(gfx::ALIGN_CENTER);
134 SetFocusForPlatform(); 129 SetFocusForPlatform();
135 } 130 }
136 131
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 views::ImageView* image = 231 views::ImageView* image =
237 new FixedSizedImageView(GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE), 232 new FixedSizedImageView(GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE),
238 GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE)); 233 GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE));
239 image->EnableCanvasFlippingForRTLUI(true); 234 image->EnableCanvasFlippingForRTLUI(true);
240 return image; 235 return image;
241 } 236 }
242 237
243 views::Slider* TrayPopupUtils::CreateSlider(views::SliderListener* listener) { 238 views::Slider* TrayPopupUtils::CreateSlider(views::SliderListener* listener) {
244 const bool is_material = MaterialDesignController::IsSystemTrayMenuMaterial(); 239 const bool is_material = MaterialDesignController::IsSystemTrayMenuMaterial();
245 views::Slider* slider = views::Slider::CreateSlider(is_material, listener); 240 views::Slider* slider = views::Slider::CreateSlider(is_material, listener);
246 slider->set_focus_border_color(kFocusBorderColor);
247 if (is_material) { 241 if (is_material) {
248 slider->SetBorder( 242 slider->SetBorder(
249 views::CreateEmptyBorder(gfx::Insets(0, kTrayPopupSliderPaddingMD))); 243 views::CreateEmptyBorder(gfx::Insets(0, kTrayPopupSliderPaddingMD)));
250 } else { 244 } else {
251 slider->SetBorder( 245 slider->SetBorder(
252 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems)); 246 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems));
253 } 247 }
254 return slider; 248 return slider;
255 } 249 }
256 250
257 views::ToggleButton* TrayPopupUtils::CreateToggleButton( 251 views::ToggleButton* TrayPopupUtils::CreateToggleButton(
258 views::ButtonListener* listener, 252 views::ButtonListener* listener,
259 int accessible_name_id) { 253 int accessible_name_id) {
260 views::ToggleButton* toggle = new views::ToggleButton(listener); 254 views::ToggleButton* toggle = new views::ToggleButton(listener);
261 const gfx::Size toggle_size(toggle->GetPreferredSize()); 255 const gfx::Size toggle_size(toggle->GetPreferredSize());
262 const int vertical_padding = (kMenuButtonSize - toggle_size.height()) / 2; 256 const int vertical_padding = (kMenuButtonSize - toggle_size.height()) / 2;
263 const int horizontal_padding = 257 const int horizontal_padding =
264 (kTrayToggleButtonWidth - toggle_size.width()) / 2; 258 (kTrayToggleButtonWidth - toggle_size.width()) / 2;
265 toggle->SetBorder(views::CreateEmptyBorder( 259 toggle->SetBorder(views::CreateEmptyBorder(
266 gfx::Insets(vertical_padding, horizontal_padding))); 260 gfx::Insets(vertical_padding, horizontal_padding)));
267 // TODO(tdanderson): Update the focus rect color, border thickness, and
268 // location for material design.
269 toggle->SetFocusPainter(views::Painter::CreateSolidFocusPainter( 261 toggle->SetFocusPainter(views::Painter::CreateSolidFocusPainter(
270 kFocusBorderColor, gfx::Insets(1))); 262 kFocusBorderColor, kFocusBorderThickness, gfx::InsetsF()));
271 toggle->SetAccessibleName(l10n_util::GetStringUTF16(accessible_name_id)); 263 toggle->SetAccessibleName(l10n_util::GetStringUTF16(accessible_name_id));
272 return toggle; 264 return toggle;
273 } 265 }
274 266
275 void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) { 267 void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) {
276 view->set_id(VIEW_ID_STICKY_HEADER); 268 view->set_id(VIEW_ID_STICKY_HEADER);
277 view->set_background( 269 view->set_background(
278 views::Background::CreateSolidBackground(kBackgroundColor)); 270 views::Background::CreateSolidBackground(kBackgroundColor));
279 view->SetBorder( 271 view->SetBorder(
280 views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0))); 272 views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0)));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { 422 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) {
431 // TODO(tdanderson): Consider moving this into WmShell, or introduce a 423 // TODO(tdanderson): Consider moving this into WmShell, or introduce a
432 // CanShowSettings() method in each delegate type that has a 424 // CanShowSettings() method in each delegate type that has a
433 // ShowSettings() method. 425 // ShowSettings() method.
434 return status != LoginStatus::NOT_LOGGED_IN && 426 return status != LoginStatus::NOT_LOGGED_IN &&
435 status != LoginStatus::LOCKED && 427 status != LoginStatus::LOCKED &&
436 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); 428 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen();
437 } 429 }
438 430
439 } // namespace ash 431 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698