Commit 657689fc authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Change the spotlight put on toolbar buttons

This CL changes the way the toolbar button associated with a popup menu
is spotlighted. It reduces the alpha of the buttons.
This is used to reduce the alpha of the background of the omnibox button
to prevent confusion between the spotlighted button and the omnibox
button.
It also changes the color of the spotlight in incognito, making it white
instead of dark.

Bug: 817752, 832076
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Iee6797945df2e9ec65464ca0393789eb3b581e71
Reviewed-on: https://chromium-review.googlesource.com/1014124Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551272}
parent 5fe30715
......@@ -16,7 +16,7 @@
namespace {
const CGFloat kSpotlightSize = 38;
const CGFloat kSpotlightCornerRadius = 7;
const CGFloat kSpotlightAlpha = 0.07;
const CGFloat kDimmedAlpha = 0.5;
} // namespace
@interface ToolbarButton ()
......@@ -136,9 +136,17 @@ const CGFloat kSpotlightAlpha = 0.07;
return;
if (dimmed) {
self.tintColor = self.configuration.buttonsTintColorDimmed;
self.alpha = kDimmedAlpha;
if (_spotlightView) {
self.spotlightView.backgroundColor =
self.configuration.dimmedButtonsSpotlightColor;
}
} else {
self.tintColor = self.configuration.buttonsTintColor;
self.alpha = 1;
if (_spotlightView) {
self.spotlightView.backgroundColor =
self.configuration.buttonsSpotlightColor;
}
}
}
......@@ -156,6 +164,7 @@ const CGFloat kSpotlightAlpha = 0.07;
return;
self.tintColor = configuration.buttonsTintColor;
_spotlightView.backgroundColor = self.configuration.buttonsSpotlightColor;
}
- (UIView*)spotlightView {
......@@ -165,8 +174,7 @@ const CGFloat kSpotlightAlpha = 0.07;
_spotlightView.hidden = YES;
_spotlightView.userInteractionEnabled = NO;
_spotlightView.layer.cornerRadius = kSpotlightCornerRadius;
_spotlightView.backgroundColor =
[UIColor colorWithWhite:0 alpha:kSpotlightAlpha];
_spotlightView.backgroundColor = self.configuration.buttonsSpotlightColor;
[self addSubview:_spotlightView];
AddSameCenterConstraints(self, _spotlightView);
[_spotlightView.widthAnchor constraintEqualToConstant:kSpotlightSize]
......
......@@ -44,8 +44,11 @@
// if the button has a custom style.
@property(nonatomic, readonly) UIColor* buttonsTintColorHighlighted;
// Tint color of the buttons in the dimmed state.
@property(nonatomic, readonly) UIColor* buttonsTintColorDimmed;
// Color for the spotlight view's background.
@property(nonatomic, readonly) UIColor* buttonsSpotlightColor;
// Color for the spotlight view's background when the toolbar is dimmed.
@property(nonatomic, readonly) UIColor* dimmedButtonsSpotlightColor;
// Color of the title of the buttons for the normal state.
// TODO(crbug.com/800266): Remove this property.
......
......@@ -117,18 +117,26 @@
}
}
- (UIColor*)buttonsTintColorDimmed {
- (UIColor*)buttonsSpotlightColor {
DCHECK(IsUIRefreshPhase1Enabled());
switch (self.style) {
case NORMAL:
return [UIColor colorWithWhite:0
alpha:kToolbarButtonTintColorAlpha -
kToolbarButtonDimmedTintColorAlphaDelta];
return [UIColor colorWithWhite:0 alpha:kToolbarSpotlightAlpha];
break;
case INCOGNITO:
return [UIColor colorWithWhite:1 alpha:kToolbarSpotlightAlpha];
break;
}
}
- (UIColor*)dimmedButtonsSpotlightColor {
DCHECK(IsUIRefreshPhase1Enabled());
switch (self.style) {
case NORMAL:
return [UIColor colorWithWhite:0 alpha:kDimmedToolbarSpotlightAlpha];
break;
case INCOGNITO:
return
[UIColor colorWithWhite:1
alpha:1 - kToolbarButtonDimmedTintColorAlphaDelta];
return [UIColor colorWithWhite:1 alpha:kDimmedToolbarSpotlightAlpha];
break;
}
}
......
......@@ -70,8 +70,9 @@ extern const CGFloat kToolbarButtonTintColorAlpha;
// Alpha for the tint color of the buttons when in the highlighted state.
extern const CGFloat kToolbarButtonTintColorAlphaHighlighted;
extern const CGFloat kIncognitoToolbarButtonTintColorAlphaHighlighted;
// Delta of alpha for the tint color of the buttons in the dimmed state.
extern const CGFloat kToolbarButtonDimmedTintColorAlphaDelta;
// Alpha for the spotlight view's background, when the toolbar is dimmed or not.
extern const CGFloat kToolbarSpotlightAlpha;
extern const CGFloat kDimmedToolbarSpotlightAlpha;
// Maximum number of tabs displayed by the button containing the tab count.
extern const NSInteger kShowTabStripButtonMaxTabCount;
......
......@@ -53,7 +53,8 @@ const CGFloat kBlurBackgroundAlpha = 0.5;
const CGFloat kToolbarButtonTintColorAlpha = 0.5;
const CGFloat kToolbarButtonTintColorAlphaHighlighted = 0.10;
const CGFloat kIncognitoToolbarButtonTintColorAlphaHighlighted = 0.21;
const CGFloat kToolbarButtonDimmedTintColorAlphaDelta = 0.3;
const CGFloat kToolbarSpotlightAlpha = 0.07;
const CGFloat kDimmedToolbarSpotlightAlpha = 0.14;
const NSInteger kShowTabStripButtonMaxTabCount = 99;
......
......@@ -164,21 +164,17 @@ const CGFloat kStrokeEndAtApogee = 1;
- (void)updateTint {
UIColor* newTint = nil;
if (IsUIRefreshPhase1Enabled()) {
if (self.dimmed) {
newTint = self.configuration.buttonsTintColorDimmed;
} else {
switch (self.state) {
case UIControlStateNormal:
newTint = self.configuration.buttonsTintColor;
break;
case UIControlStateHighlighted:
newTint = self.configuration.buttonsTintColorHighlighted;
break;
default:
newTint = self.configuration.buttonsTintColor;
break;
switch (self.state) {
case UIControlStateNormal:
newTint = self.configuration.buttonsTintColor;
break;
case UIControlStateHighlighted:
newTint = self.configuration.buttonsTintColorHighlighted;
break;
default:
newTint = self.configuration.buttonsTintColor;
break;
}
}
} else {
switch (self.state) {
case UIControlStateNormal:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment