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

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

Issue 2527513002: Update ash shelf/tray focus rects. (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « ash/common/system/tray/tray_popup_utils.h ('k') | ash/common/system/user/button_from_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 = 20; 116 const int kHorizontalPadding = 20;
117 SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kHorizontalPadding))); 117 SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kHorizontalPadding)));
118 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::BUTTON); 118 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::BUTTON);
119 style.SetupLabel(label()); 119 style.SetupLabel(label());
120 // TODO(tdanderson): Update focus rect for material design. See 120 SetFocusPainter(TrayPopupUtils::CreateFocusPainter());
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(
126 kFocusBorderColor, gfx::Insets(0, 0, 1, 1)));
127 } else { 121 } else {
128 SetBorder(std::unique_ptr<views::Border>(new TrayPopupLabelButtonBorder)); 122 SetBorder(std::unique_ptr<views::Border>(new TrayPopupLabelButtonBorder));
129 SetFocusPainter(views::Painter::CreateSolidFocusPainter( 123 SetFocusPainter(views::Painter::CreateSolidFocusPainter(
130 kFocusBorderColor, gfx::Insets(1, 1, 2, 2))); 124 kFocusBorderColor, gfx::Insets(1, 1, 2, 2)));
131 set_animate_on_state_change(false); 125 set_animate_on_state_change(false);
132 } 126 }
133 SetHorizontalAlignment(gfx::ALIGN_CENTER); 127 SetHorizontalAlignment(gfx::ALIGN_CENTER);
134 SetFocusForPlatform(); 128 SetFocusForPlatform();
135 } 129 }
136 130
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 views::ImageView* image = 242 views::ImageView* image =
249 new FixedSizedImageView(GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE), 243 new FixedSizedImageView(GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE),
250 GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE)); 244 GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE));
251 image->EnableCanvasFlippingForRTLUI(true); 245 image->EnableCanvasFlippingForRTLUI(true);
252 return image; 246 return image;
253 } 247 }
254 248
255 views::Slider* TrayPopupUtils::CreateSlider(views::SliderListener* listener) { 249 views::Slider* TrayPopupUtils::CreateSlider(views::SliderListener* listener) {
256 const bool is_material = MaterialDesignController::IsSystemTrayMenuMaterial(); 250 const bool is_material = MaterialDesignController::IsSystemTrayMenuMaterial();
257 views::Slider* slider = views::Slider::CreateSlider(is_material, listener); 251 views::Slider* slider = views::Slider::CreateSlider(is_material, listener);
258 slider->set_focus_border_color(kFocusBorderColor);
259 if (is_material) { 252 if (is_material) {
260 slider->SetBorder( 253 slider->SetBorder(
261 views::CreateEmptyBorder(gfx::Insets(0, kTrayPopupSliderPaddingMD))); 254 views::CreateEmptyBorder(gfx::Insets(0, kTrayPopupSliderPaddingMD)));
262 } else { 255 } else {
263 slider->SetBorder( 256 slider->SetBorder(
264 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems)); 257 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems));
265 } 258 }
266 return slider; 259 return slider;
267 } 260 }
268 261
269 views::ToggleButton* TrayPopupUtils::CreateToggleButton( 262 views::ToggleButton* TrayPopupUtils::CreateToggleButton(
270 views::ButtonListener* listener, 263 views::ButtonListener* listener,
271 int accessible_name_id) { 264 int accessible_name_id) {
272 views::ToggleButton* toggle = new views::ToggleButton(listener); 265 views::ToggleButton* toggle = new views::ToggleButton(listener);
273 const gfx::Size toggle_size(toggle->GetPreferredSize()); 266 const gfx::Size toggle_size(toggle->GetPreferredSize());
274 const int vertical_padding = (kMenuButtonSize - toggle_size.height()) / 2; 267 const int vertical_padding = (kMenuButtonSize - toggle_size.height()) / 2;
275 const int horizontal_padding = 268 const int horizontal_padding =
276 (kTrayToggleButtonWidth - toggle_size.width()) / 2; 269 (kTrayToggleButtonWidth - toggle_size.width()) / 2;
277 toggle->SetBorder(views::CreateEmptyBorder( 270 toggle->SetBorder(views::CreateEmptyBorder(
278 gfx::Insets(vertical_padding, horizontal_padding))); 271 gfx::Insets(vertical_padding, horizontal_padding)));
279 // TODO(tdanderson): Update the focus rect color, border thickness, and 272 // TODO(varkha): remove this and implement toggle-button specific focus. See
280 // location for material design. 273 // crbug.com/669124
281 toggle->SetFocusPainter(views::Painter::CreateSolidFocusPainter( 274 toggle->SetFocusPainter(CreateFocusPainter());
282 kFocusBorderColor, gfx::Insets(1)));
283 toggle->SetAccessibleName(l10n_util::GetStringUTF16(accessible_name_id)); 275 toggle->SetAccessibleName(l10n_util::GetStringUTF16(accessible_name_id));
284 return toggle; 276 return toggle;
285 } 277 }
286 278
279 std::unique_ptr<views::Painter> TrayPopupUtils::CreateFocusPainter() {
280 return views::Painter::CreateSolidFocusPainter(
281 kFocusBorderColor, kFocusBorderThickness, gfx::InsetsF());
282 }
283
287 void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) { 284 void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) {
288 view->set_id(VIEW_ID_STICKY_HEADER); 285 view->set_id(VIEW_ID_STICKY_HEADER);
289 view->set_background( 286 view->set_background(
290 views::Background::CreateSolidBackground(kBackgroundColor)); 287 views::Background::CreateSolidBackground(kBackgroundColor));
291 view->SetBorder( 288 view->SetBorder(
292 views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0))); 289 views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0)));
293 } 290 }
294 291
295 void TrayPopupUtils::ConfigureContainer(TriView::Container container, 292 void TrayPopupUtils::ConfigureContainer(TriView::Container container,
296 views::View* container_view) { 293 views::View* container_view) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { 453 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) {
457 // TODO(tdanderson): Consider moving this into WmShell, or introduce a 454 // TODO(tdanderson): Consider moving this into WmShell, or introduce a
458 // CanShowSettings() method in each delegate type that has a 455 // CanShowSettings() method in each delegate type that has a
459 // ShowSettings() method. 456 // ShowSettings() method.
460 return status != LoginStatus::NOT_LOGGED_IN && 457 return status != LoginStatus::NOT_LOGGED_IN &&
461 status != LoginStatus::LOCKED && 458 status != LoginStatus::LOCKED &&
462 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); 459 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen();
463 } 460 }
464 461
465 } // namespace ash 462 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_popup_utils.h ('k') | ash/common/system/user/button_from_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698