Chromium Code Reviews| Index: chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.cc |
| diff --git a/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.cc b/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.cc |
| index 01c3c6ee135a9c932991c37b1b4d8a124d851ade..523bee6aa7625df269fee82cd382ca668a759974 100644 |
| --- a/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.cc |
| +++ b/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.cc |
| @@ -31,7 +31,7 @@ constexpr int kFadeDurationInMs = 150; |
| constexpr int kPointMoveDurationInMs = 400; |
| constexpr int kPointMoveDurationLongInMs = 500; |
| -const SkColor kExitLabelColor = SkColorSetARGBInline(255, 96, 96, 96); |
| +const SkColor kExitLabelColor = SkColorSetARGBInline(255, 138, 138, 138); |
| constexpr int kExitLabelWidth = 300; |
| constexpr int kExitLabelHeight = 20; |
| @@ -39,6 +39,8 @@ const SkColor kTapHereLabelColor = SK_ColorWHITE; |
| constexpr int kHintBoxWidth = 298; |
| constexpr int kHintBoxHeight = 180; |
| +constexpr int kHintBoxArrowWidth = 8; |
| +constexpr int kHintBoxArrowHeight = 14; |
| constexpr int kHintBoxLabelTextSize = 5; |
| constexpr int kHintBoxSublabelTextSize = 3; |
| @@ -278,6 +280,9 @@ class HintBox : public views::View { |
| void SetSubLabel(const base::string16& text, const SkColor& color); |
| private: |
| + void UpdateWidth(int updated_width); |
| + void UpdateTriangle(); |
| + |
| base::string16 label_text_; |
| base::string16 sublabel_text_; |
| @@ -288,6 +293,8 @@ class HintBox : public views::View { |
| int horizontal_offset_; |
| + gfx::Rect rounded_rect_bounds_; |
| + |
| gfx::FontList label_font_list_; |
| gfx::FontList sublabel_font_list_; |
| @@ -296,18 +303,26 @@ class HintBox : public views::View { |
| SkPaint paint_; |
| + SkPath triangle_path_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(HintBox); |
| }; |
| HintBox::HintBox(const gfx::Rect& bounds, int border_radius) |
| - : border_radius_(border_radius) { |
| + : border_radius_(border_radius), |
| + rounded_rect_bounds_( |
| + gfx::Rect(base::i18n::IsRTL() ? 0 : kHintBoxArrowWidth, |
| + 0, |
| + bounds.width() - kHintBoxArrowWidth, |
| + bounds.height())) { |
|
oshima
2017/01/25 22:08:54
can you use GetMirroredxxx api on views?
malaykeshav
2017/01/25 23:54:22
Done
|
| SetBoundsRect(bounds); |
| paint_.setColor(SK_ColorWHITE); |
| paint_.setStyle(SkPaint::kFill_Style); |
| paint_.setFlags(SkPaint::kAntiAlias_Flag); |
| - horizontal_offset_ = width() * 0.08f; |
| + horizontal_offset_ = |
| + kHintBoxArrowWidth + rounded_rect_bounds_.width() * 0.08f; |
| int top_offset = horizontal_offset_; |
| int line_gap = height() * 0.018f; |
| int label_height = height() * 0.11f; |
| @@ -318,10 +333,36 @@ HintBox::HintBox(const gfx::Rect& bounds, int border_radius) |
| sublabel_text_bounds_.SetRect(horizontal_offset_, top_offset, 0, |
| label_height); |
| + |
| + UpdateTriangle(); |
| } |
| HintBox::~HintBox() {} |
| +void HintBox::UpdateTriangle() { |
| + const int kHorizontalOffset = base::i18n::IsRTL() ? width() : 0; |
| + const int kMultiplier = base::i18n::IsRTL() ? 1 : -1; |
|
oshima
2017/01/25 22:08:54
ditto
malaykeshav
2017/01/25 23:54:22
Done
|
| + |
| + triangle_path_.reset(); |
| + triangle_path_.moveTo(kHorizontalOffset, SkIntToScalar(height() / 2)); |
| + triangle_path_.lineTo( |
| + SkIntToScalar((kHorizontalOffset - kHintBoxArrowWidth) * kMultiplier), |
| + SkIntToScalar((height() - kHintBoxArrowHeight) / 2)); |
| + |
| + triangle_path_.lineTo( |
| + SkIntToScalar((kHorizontalOffset - kHintBoxArrowWidth) * kMultiplier), |
| + SkIntToScalar((height() + kHintBoxArrowHeight) / 2)); |
| + triangle_path_.close(); |
| +} |
| + |
| +void HintBox::UpdateWidth(int updated_width) { |
| + rounded_rect_bounds_.set_size(gfx::Size(updated_width, height())); |
| + SetSize( |
| + gfx::Size(rounded_rect_bounds_.width() + kHintBoxArrowWidth, height())); |
| + |
| + UpdateTriangle(); |
| +} |
| + |
| void HintBox::SetLabel(const base::string16& text, const SkColor& color) { |
| label_text_ = text; |
| label_color_ = color; |
| @@ -338,8 +379,8 @@ void HintBox::SetLabel(const base::string16& text, const SkColor& color) { |
| // Check if the width of hint box needs to be updated. |
| int minimum_expected_width = size.width() + 2 * horizontal_offset_; |
| - if (minimum_expected_width > width()) |
| - SetSize(gfx::Size(minimum_expected_width, height())); |
| + if (minimum_expected_width > rounded_rect_bounds_.width()) |
| + UpdateWidth(minimum_expected_width); |
| } |
| void HintBox::SetSubLabel(const base::string16& text, const SkColor& color) { |
| @@ -358,12 +399,13 @@ void HintBox::SetSubLabel(const base::string16& text, const SkColor& color) { |
| // Check if the width of hint box needs to be updated. |
| int minimum_expected_width = size.width() + 2 * horizontal_offset_; |
| - if (minimum_expected_width > width()) |
| - SetSize(gfx::Size(minimum_expected_width, height())); |
| + if (minimum_expected_width > rounded_rect_bounds_.width()) |
| + UpdateWidth(minimum_expected_width); |
| } |
| void HintBox::OnPaint(gfx::Canvas* canvas) { |
| - canvas->DrawRoundRect(GetLocalBounds(), border_radius_, paint_); |
| + canvas->DrawPath(triangle_path_, paint_); |
| + canvas->DrawRoundRect(rounded_rect_bounds_, border_radius_, paint_); |
| canvas->DrawStringRectWithFlags(label_text_, label_font_list_, label_color_, |
| label_text_bounds_, gfx::Canvas::NO_ELLIPSIS); |
| canvas->DrawStringRectWithFlags(sublabel_text_, sublabel_font_list_, |
| @@ -534,11 +576,12 @@ void TouchCalibratorView::InitViewContents() { |
| int tpv_width = touch_point_view_->width(); |
| - gfx::Size size(kHintBoxWidth, kHintBoxHeight); |
| + gfx::Size size(kHintBoxWidth + kHintBoxArrowWidth, kHintBoxHeight); |
| - gfx::Point position( |
| - touch_point_view_->x() + tpv_width * 1.2f, |
| - touch_point_view_->y() + (tpv_width / 2.f) - (size.height() / 2.f)); |
| + gfx::Point position(touch_point_view_->x() + tpv_width * 1.2f, |
| + touch_point_view_->y() + |
| + (kThrobberCircleViewWidth / 2.f) - |
| + (size.height() / 2.f)); |
| HintBox* hint_box = |
| new HintBox(gfx::Rect(position, size), kHintRectBorderRadius); |
| @@ -551,7 +594,7 @@ void TouchCalibratorView::InitViewContents() { |
| // Initialize the animated hint box throbber view. |
| TouchTargetThrobberView* target_view = new TouchTargetThrobberView( |
| - gfx::Rect((size.width() - kTouchTargetWidth) / 2, |
| + gfx::Rect((kHintBoxArrowWidth + size.width() - kTouchTargetWidth) / 2, |
| size.height() * kTouchTargetVerticalOffsetFactor, |
| kTouchTargetWidth, kTouchTargetHeight), |
| kTouchTargetInnerCircleColor, kTouchTargetOuterCircleColor, |