Skip to content

Commit

Permalink
dark_mode: Add 2px gap for kIconlessProminent PillButton
Browse files Browse the repository at this point in the history
For kIconlessProminent PillButton, since its background color is the
same with the focus ring color, to make the focus ring visible to the
user, add 2px gap between the focus ring and the content for
kIconlessProminent type of PillButton.

Fixed: 1322853
Test: Manual
Change-Id: I6596767f40b7caf00f9adb559a3913c4ad69b8c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3787017
Reviewed-by: Min Chen <minch@chromium.org>
Commit-Queue: Connie Xu <conniekxu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1028805}
  • Loading branch information
conniekxu authored and Chromium LUCI CQ committed Jul 27, 2022
1 parent d2af3cc commit 73eb24a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ash/style/pill_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "ui/compositor/layer.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/background.h"
#include "ui/views/controls/focus_ring.h"
#include "ui/views/controls/highlight_path_generator.h"

namespace ash {
Expand All @@ -23,6 +24,11 @@ constexpr int kIconSize = 20;
constexpr int kIconPillButtonImageLabelSpacingDp = 8;
constexpr int kPaddingReductionForIcon = 4;

// Including the thickness and inset of the focus ring in order to keep 2px
// padding between the focus ring and content of the button.
constexpr int kFocusRingPadding = 2 + views::FocusRing::kDefaultHaloThickness +
views::FocusRing::kDefaultHaloInset;

// Returns true it is a floating type of PillButton, which is a type of
// PillButton without a background.
bool IsFloatingPillButton(PillButton::Type type) {
Expand Down Expand Up @@ -218,9 +224,16 @@ void PillButton::UpdateButtonHeight(int height) {
vertical_spacing, left_padding, vertical_spacing, horizontal_spacing_)));

if (rounded_highlight_path_) {
views::InstallRoundRectHighlightPathGenerator(this, gfx::Insets(),
height_ / 2.f);
if (type_ == Type::kIconlessProminent) {
views::InstallRoundRectHighlightPathGenerator(
this, gfx::Insets(-kFocusRingPadding),
height_ / 2.f + kFocusRingPadding);
} else {
views::InstallRoundRectHighlightPathGenerator(this, gfx::Insets(),
height_ / 2.f);
}
}

if (!IsFloatingPillButton(type_)) {
SetBackground(views::CreateRoundedRectBackground(
GetDefaultBackgroundColor(type_), height_ / 2.f));
Expand Down

0 comments on commit 73eb24a

Please sign in to comment.