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

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

Issue 2523523002: Add ink drop ripple to status tray (Closed)
Patch Set: 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
« no previous file with comments | « ash/common/system/tray/tray_popup_utils.h ('k') | ash/common/system/user/tray_user.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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 return highlight; 363 return highlight;
364 } 364 }
365 365
366 std::unique_ptr<views::InkDropMask> TrayPopupUtils::CreateInkDropMask( 366 std::unique_ptr<views::InkDropMask> TrayPopupUtils::CreateInkDropMask(
367 TrayPopupInkDropStyle ink_drop_style, 367 TrayPopupInkDropStyle ink_drop_style,
368 const views::View* host) { 368 const views::View* host) {
369 if (ink_drop_style == TrayPopupInkDropStyle::FILL_BOUNDS) 369 if (ink_drop_style == TrayPopupInkDropStyle::FILL_BOUNDS)
370 return nullptr; 370 return nullptr;
371 371
372 const gfx::Size layer_size = host->size(); 372 const gfx::Size layer_size = host->size();
373 const gfx::Rect mask_bounds = GetInkDropBounds(ink_drop_style, host);
374 switch (ink_drop_style) { 373 switch (ink_drop_style) {
375 case TrayPopupInkDropStyle::HOST_CENTERED: { 374 case TrayPopupInkDropStyle::HOST_CENTERED: {
375 const gfx::Rect mask_bounds =
376 GetInkDropBounds(TrayPopupInkDropStyle::HOST_CENTERED, host);
376 const int radius = 377 const int radius =
377 std::min(mask_bounds.width(), mask_bounds.height()) / 2; 378 std::min(mask_bounds.width(), mask_bounds.height()) / 2;
378 return base::MakeUnique<views::CircleInkDropMask>( 379 return base::MakeUnique<views::CircleInkDropMask>(
379 layer_size, mask_bounds.CenterPoint(), radius); 380 layer_size, mask_bounds.CenterPoint(), radius);
380 } 381 }
381 case TrayPopupInkDropStyle::INSET_BOUNDS: 382 case TrayPopupInkDropStyle::INSET_BOUNDS: {
383 const gfx::Insets mask_insets =
384 GetInkDropInsets(TrayPopupInkDropStyle::INSET_BOUNDS);
382 return base::MakeUnique<views::RoundRectInkDropMask>( 385 return base::MakeUnique<views::RoundRectInkDropMask>(
383 layer_size, mask_bounds, kTrayPopupInkDropCornerRadius); 386 layer_size, mask_insets, kTrayPopupInkDropCornerRadius);
387 }
384 case TrayPopupInkDropStyle::FILL_BOUNDS: 388 case TrayPopupInkDropStyle::FILL_BOUNDS:
385 // Handled by quick return above. 389 // Handled by quick return above.
386 break; 390 break;
387 } 391 }
388 // Required by some compilers. 392 // Required by some compilers.
389 NOTREACHED(); 393 NOTREACHED();
390 return nullptr; 394 return nullptr;
391 } 395 }
392 396
397 gfx::Insets TrayPopupUtils::GetInkDropInsets(
398 TrayPopupInkDropStyle ink_drop_style) {
399 gfx::Insets insets;
400 if (ink_drop_style == TrayPopupInkDropStyle::HOST_CENTERED ||
401 ink_drop_style == TrayPopupInkDropStyle::INSET_BOUNDS) {
402 insets.Set(kTrayPopupInkDropInset, kTrayPopupInkDropInset,
403 kTrayPopupInkDropInset, kTrayPopupInkDropInset);
404 }
405 return insets;
406 }
407
393 gfx::Rect TrayPopupUtils::GetInkDropBounds(TrayPopupInkDropStyle ink_drop_style, 408 gfx::Rect TrayPopupUtils::GetInkDropBounds(TrayPopupInkDropStyle ink_drop_style,
394 const views::View* host) { 409 const views::View* host) {
395 gfx::Rect bounds = host->GetLocalBounds(); 410 gfx::Rect bounds = host->GetLocalBounds();
396 if (ink_drop_style == TrayPopupInkDropStyle::HOST_CENTERED || 411 bounds.Inset(GetInkDropInsets(ink_drop_style));
397 ink_drop_style == TrayPopupInkDropStyle::INSET_BOUNDS) {
398 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset);
399 }
400 return bounds; 412 return bounds;
401 } 413 }
402 414
403 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { 415 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) {
404 // TODO(tdanderson): Consider moving this into WmShell, or introduce a 416 // TODO(tdanderson): Consider moving this into WmShell, or introduce a
405 // CanShowSettings() method in each delegate type that has a 417 // CanShowSettings() method in each delegate type that has a
406 // ShowSettings() method. 418 // ShowSettings() method.
407 return status != LoginStatus::NOT_LOGGED_IN && 419 return status != LoginStatus::NOT_LOGGED_IN &&
408 status != LoginStatus::LOCKED && 420 status != LoginStatus::LOCKED &&
409 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); 421 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen();
410 } 422 }
411 423
412 } // namespace ash 424 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_popup_utils.h ('k') | ash/common/system/user/tray_user.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698