Commit e945bb1f authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Rotate the tools menu button by 90 degrees

This CL rotates the tools menu button (3 dots) by 90 degrees. It also
rotates the animation when an item is added to the reading list.

Bug: 807285
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I8553993c8e4b9f38579159087480c1adf82d23e8
Reviewed-on: https://chromium-review.googlesource.com/893360
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarLouis Romero <lpromero@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533244}
parent a929c9e1
...@@ -9,19 +9,31 @@ ...@@ -9,19 +9,31 @@
#include "base/logging.h" #include "base/logging.h"
#include "ios/chrome/browser/ui/toolbar/clean/toolbar_button_tints.h" #include "ios/chrome/browser/ui/toolbar/clean/toolbar_button_tints.h"
#include "ios/chrome/browser/ui/ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
namespace { namespace {
// The number of dots drawn. // *** Constants for the non-adaptive toolbar, 3 vertical dots. ***
const int kNumberOfDots = 3;
// Position of the topmost dot. // Position of the topmost dot.
const CGFloat kDotOffsetX = 22; const CGFloat kDotOffsetXVertical = 22;
const CGFloat kDotOffsetY = 18; const CGFloat kDotOffsetYVertical = 18;
// Vertical space between dots. // Vertical space between dots.
const CGFloat kVerticalSpaceBetweenDots = 6; const CGFloat kVerticalSpaceBetweenDots = 6;
// *** Constants for the adaptive toolbar, 3 horizontal dots. ***
// Position of the left most dot.
const CGFloat kDotOffsetXHorizontal = 22;
const CGFloat kDotOffsetYHorizontal = 18;
// Horizontal space between dots.
const CGFloat kHorizontalSpaceBetweenDots = 6;
// The maximum width of the segment/dots.
const CGFloat kMaxWidthOfStroke = 7.4;
// The number of dots drawn.
const int kNumberOfDots = 3;
// The duration of the animation, in seconds. // The duration of the animation, in seconds.
const CFTimeInterval kAnimationDuration = 1; const CFTimeInterval kAnimationDuration = 1;
// The frame offset at which the animation to the intermediary value finishes. // The frame offset at which the animation to the intermediary value finishes.
...@@ -32,8 +44,6 @@ const int kIntermediaryValueEndFrame = 29; ...@@ -32,8 +44,6 @@ const int kIntermediaryValueEndFrame = 29;
const int kFinalValueBeginFrame = 37; const int kFinalValueBeginFrame = 37;
// The number of frames between the start of each dot's animation. // The number of frames between the start of each dot's animation.
const double kFramesBetweenAnimationOfEachDot = 3; const double kFramesBetweenAnimationOfEachDot = 3;
// The maximum width of the segment/dots.
const CGFloat kMaxWidthOfSegment = 7.4;
// Constants for the properties of the stroke during the animations. // Constants for the properties of the stroke during the animations.
// The strokeEnd is slightly more than 0.5, because if the strokeEnd is // The strokeEnd is slightly more than 0.5, because if the strokeEnd is
// exactly equal to strokeStart, the line is not drawn. // exactly equal to strokeStart, the line is not drawn.
...@@ -158,12 +168,14 @@ const CGFloat kLineWidthAtApogee = 3; ...@@ -158,12 +168,14 @@ const CGFloat kLineWidthAtApogee = 3;
pathLayers_ = [[NSMutableArray alloc] initWithCapacity:kNumberOfDots]; pathLayers_ = [[NSMutableArray alloc] initWithCapacity:kNumberOfDots];
for (NSUInteger i = 0; i < kNumberOfDots; i++) { for (NSUInteger i = 0; i < kNumberOfDots; i++) {
const CGFloat x = kDotOffsetX; const CGFloat x = [self firstDotXOffset] + [self horizontalSpacing] * i;
const CGFloat y = kDotOffsetY + kVerticalSpaceBetweenDots * i; const CGFloat y = [self firstDotYOffset] + [self verticalSpacing] * i;
UIBezierPath* path = [UIBezierPath bezierPath]; UIBezierPath* path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(x - kMaxWidthOfSegment * 0.5, y)]; [path moveToPoint:CGPointMake(x - [self segmentWidth] * 0.5,
[path addLineToPoint:CGPointMake(x + kMaxWidthOfSegment * 0.5, y)]; y - [self segmentHeight] * 0.5)];
[path addLineToPoint:CGPointMake(x + [self segmentWidth] * 0.5,
y + [self segmentHeight] * 0.5)];
CAShapeLayer* pathLayer = [CAShapeLayer layer]; CAShapeLayer* pathLayer = [CAShapeLayer layer];
[pathLayer setFrame:self.bounds]; [pathLayer setFrame:self.bounds];
...@@ -339,4 +351,60 @@ const CGFloat kLineWidthAtApogee = 3; ...@@ -339,4 +351,60 @@ const CGFloat kLineWidthAtApogee = 3;
[self initializeShapeLayers]; [self initializeShapeLayers];
} }
#pragma mark - Private
// Returns the X offset of the first dot.
- (CGFloat)firstDotXOffset {
if (IsUIRefreshPhase1Enabled()) {
return kDotOffsetXHorizontal;
} else {
return kDotOffsetXVertical;
}
}
// Returns the Y offset of the first dot.
- (CGFloat)firstDotYOffset {
if (IsUIRefreshPhase1Enabled()) {
return kDotOffsetYHorizontal;
} else {
return kDotOffsetYVertical;
}
}
// Returns the vertical spacing between two dots.
- (CGFloat)verticalSpacing {
if (IsUIRefreshPhase1Enabled()) {
return 0;
} else {
return kVerticalSpaceBetweenDots;
}
}
// Returns the horizontal spacing between two dots.
- (CGFloat)horizontalSpacing {
if (IsUIRefreshPhase1Enabled()) {
return kHorizontalSpaceBetweenDots;
} else {
return 0;
}
}
// Returns the width of a segment used in animation.
- (CGFloat)segmentWidth {
if (IsUIRefreshPhase1Enabled()) {
return 0;
} else {
return kMaxWidthOfStroke;
}
}
// Returns the height of a segment used in animation.
- (CGFloat)segmentHeight {
if (IsUIRefreshPhase1Enabled()) {
return kMaxWidthOfStroke;
} else {
return 0;
}
}
@end @end
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