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

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

Issue 2527513002: Update ash shelf/tray focus rects. (Closed)
Patch Set: don't fix palette 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
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 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 views::ImageView* image = 230 views::ImageView* image =
237 new FixedSizedImageView(GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE), 231 new FixedSizedImageView(GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE),
238 GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE)); 232 GetTrayConstant(TRAY_POPUP_ITEM_MORE_IMAGE_SIZE));
239 image->EnableCanvasFlippingForRTLUI(true); 233 image->EnableCanvasFlippingForRTLUI(true);
240 return image; 234 return image;
241 } 235 }
242 236
243 views::Slider* TrayPopupUtils::CreateSlider(views::SliderListener* listener) { 237 views::Slider* TrayPopupUtils::CreateSlider(views::SliderListener* listener) {
244 const bool is_material = MaterialDesignController::IsSystemTrayMenuMaterial(); 238 const bool is_material = MaterialDesignController::IsSystemTrayMenuMaterial();
245 views::Slider* slider = views::Slider::CreateSlider(is_material, listener); 239 views::Slider* slider = views::Slider::CreateSlider(is_material, listener);
246 slider->set_focus_border_color(kFocusBorderColor);
247 if (is_material) { 240 if (is_material) {
248 slider->SetBorder( 241 slider->SetBorder(
249 views::CreateEmptyBorder(gfx::Insets(0, kTrayPopupSliderPaddingMD))); 242 views::CreateEmptyBorder(gfx::Insets(0, kTrayPopupSliderPaddingMD)));
250 } else { 243 } else {
251 slider->SetBorder( 244 slider->SetBorder(
252 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems)); 245 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems));
253 } 246 }
254 return slider; 247 return slider;
255 } 248 }
256 249
257 views::ToggleButton* TrayPopupUtils::CreateToggleButton( 250 views::ToggleButton* TrayPopupUtils::CreateToggleButton(
258 views::ButtonListener* listener, 251 views::ButtonListener* listener,
259 int accessible_name_id) { 252 int accessible_name_id) {
260 views::ToggleButton* toggle = new views::ToggleButton(listener); 253 views::ToggleButton* toggle = new views::ToggleButton(listener);
261 const gfx::Size toggle_size(toggle->GetPreferredSize()); 254 const gfx::Size toggle_size(toggle->GetPreferredSize());
262 const int vertical_padding = (kMenuButtonSize - toggle_size.height()) / 2; 255 const int vertical_padding = (kMenuButtonSize - toggle_size.height()) / 2;
263 const int horizontal_padding = 256 const int horizontal_padding =
264 (kTrayToggleButtonWidth - toggle_size.width()) / 2; 257 (kTrayToggleButtonWidth - toggle_size.width()) / 2;
265 toggle->SetBorder(views::CreateEmptyBorder( 258 toggle->SetBorder(views::CreateEmptyBorder(
266 gfx::Insets(vertical_padding, horizontal_padding))); 259 gfx::Insets(vertical_padding, horizontal_padding)));
267 // TODO(tdanderson): Update the focus rect color, border thickness, and 260 // TODO(varkha): remove this and implement toggle-button specific focus. See
268 // location for material design. 261 // crbug.com/669124
269 toggle->SetFocusPainter(views::Painter::CreateSolidFocusPainter( 262 toggle->SetFocusPainter(CreateFocusPainter());
270 kFocusBorderColor, gfx::Insets(1)));
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
267 std::unique_ptr<views::Painter> TrayPopupUtils::CreateFocusPainter() {
268 return views::Painter::CreateSolidFocusPainter(
269 kFocusBorderColor, kFocusBorderThickness, gfx::InsetsF());
270 }
271
275 void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) { 272 void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) {
276 view->set_id(VIEW_ID_STICKY_HEADER); 273 view->set_id(VIEW_ID_STICKY_HEADER);
277 view->set_background( 274 view->set_background(
278 views::Background::CreateSolidBackground(kBackgroundColor)); 275 views::Background::CreateSolidBackground(kBackgroundColor));
279 view->SetBorder( 276 view->SetBorder(
280 views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0))); 277 views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0)));
281 } 278 }
282 279
283 void TrayPopupUtils::ConfigureContainer(TriView::Container container, 280 void TrayPopupUtils::ConfigureContainer(TriView::Container container,
284 views::View* container_view) { 281 views::View* container_view) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { 427 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) {
431 // TODO(tdanderson): Consider moving this into WmShell, or introduce a 428 // TODO(tdanderson): Consider moving this into WmShell, or introduce a
432 // CanShowSettings() method in each delegate type that has a 429 // CanShowSettings() method in each delegate type that has a
433 // ShowSettings() method. 430 // ShowSettings() method.
434 return status != LoginStatus::NOT_LOGGED_IN && 431 return status != LoginStatus::NOT_LOGGED_IN &&
435 status != LoginStatus::LOCKED && 432 status != LoginStatus::LOCKED &&
436 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); 433 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen();
437 } 434 }
438 435
439 } // namespace ash 436 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698