Index: chrome/browser/android/vr_shell/textures/url_bar_texture.cc |
diff --git a/chrome/browser/android/vr_shell/textures/url_bar_texture.cc b/chrome/browser/android/vr_shell/textures/url_bar_texture.cc |
index 57ca3d2f6b89ef975e5d51d8dbf2b2e039e9f98f..856a90831cd32bc8dec2108c5503b4266f399393 100644 |
--- a/chrome/browser/android/vr_shell/textures/url_bar_texture.cc |
+++ b/chrome/browser/android/vr_shell/textures/url_bar_texture.cc |
@@ -10,7 +10,9 @@ |
#include "ui/gfx/canvas.h" |
#include "ui/gfx/font.h" |
#include "ui/gfx/font_list.h" |
+#include "ui/gfx/geometry/point_f.h" |
#include "ui/gfx/geometry/rect.h" |
+#include "ui/gfx/geometry/rect_f.h" |
#include "ui/gfx/paint_vector_icon.h" |
#include "ui/gfx/render_text.h" |
#include "ui/gfx/vector_icon_types.h" |
@@ -20,8 +22,9 @@ namespace vr_shell { |
namespace { |
-static constexpr SkColor kBackground = 0xCCAAAAAA; |
-static constexpr SkColor kBackgroundHover = 0xCCDDDDDD; |
+static constexpr SkColor kBackground = 0xCCD6D6D6; |
cjgrant
2017/05/16 14:07:23
Where is this one from?
mthiesse
2017/05/16 18:11:02
I pulled it out of my a-
There wasn't any in the
|
+static constexpr SkColor kBackgroundHover = 0xCCE1E1E1; |
cjgrant
2017/05/16 14:07:23
Should we drop the 0xCC?
mthiesse
2017/05/16 18:11:01
Spec maaaaybe suggests using 0x66. so I'll switch
|
+static constexpr SkColor kBackgroundDown = 0xCCECECEC; |
static constexpr SkColor kForeground = 0xCC444444; |
static constexpr SkColor kSeparatorColor = |
SkColorSetARGBMacro(256 * 0.2, 0, 0, 0); |
@@ -36,6 +39,7 @@ static constexpr float kSecurityFieldWidth = 0.06; |
static constexpr float kSecurityIconHeight = 0.03; |
static constexpr float kUrlRightMargin = 0.02; |
static constexpr float kSeparatorWidth = 0.002; |
+static constexpr float kBackHitTargetSize = 0.128; |
using security_state::SecurityLevel; |
@@ -77,6 +81,28 @@ float UrlBarTexture::ToPixels(float meters) const { |
return meters * size_.width() / kWidth; |
} |
+bool UrlBarTexture::HitsBackButton(const gfx::PointF& position) const { |
+ float margin = (kBackHitTargetSize - kBackButtonWidth) / 2; |
+ gfx::RectF rect(-margin, -margin, kBackHitTargetSize, kBackHitTargetSize); |
+ rect.Scale(1.0f / (kWidth - kBackButtonWidth), 1.0f / kBackButtonWidth); |
+ return rect.Contains(position); |
+} |
+ |
+bool UrlBarTexture::HitsURLBar(const gfx::PointF& position) const { |
+ gfx::RectF rect(0, 0, 1, 1); |
+ return rect.Contains(position) && !HitsRightTransparentRegion(position); |
+} |
+ |
+bool UrlBarTexture::HitsRightTransparentRegion( |
+ const gfx::PointF& position) const { |
+ float rounded_radius = kHeight / kWidth / 2; |
cjgrant
2017/05/16 14:07:23
This is fine if it works, but alternatively, would
mthiesse
2017/05/16 18:11:01
Yeah, looks clearer when you convert everything to
cjgrant
2017/05/16 18:22:21
Acknowledged.
|
+ if (position.x() < 1.0f - rounded_radius) |
+ return false; |
+ float x = (position.x() - (1.0f - rounded_radius)) / rounded_radius / 2 + 0.5; |
+ gfx::Vector2dF diff = gfx::PointF(x, position.y()) - gfx::PointF(0.5, 0.5); |
+ return diff.LengthSquared() > 0.25; |
+} |
+ |
void UrlBarTexture::Draw(SkCanvas* canvas, const gfx::Size& texture_size) { |
size_.set_height(texture_size.height()); |
size_.set_width(texture_size.width()); |
@@ -93,9 +119,11 @@ void UrlBarTexture::Draw(SkCanvas* canvas, const gfx::Size& texture_size) { |
SkVector rounded_corner = {kHeight / 2, kHeight / 2}; |
SkVector left_corners[4] = {rounded_corner, {0, 0}, {0, 0}, rounded_corner}; |
round_rect.setRectRadii({0, 0, kHeight, kHeight}, left_corners); |
+ SkColor color = |
+ (GetDrawFlags() & FLAG_BACK_HOVER) ? kBackgroundHover : kBackground; |
+ color = (GetDrawFlags() & FLAG_BACK_DOWN) ? kBackgroundDown : color; |
SkPaint paint; |
- paint.setColor((GetDrawFlags() & FLAG_HOVER) ? kBackgroundHover |
- : kBackground); |
+ paint.setColor(color); |
canvas->drawRRect(round_rect, paint); |
// URL area. |