Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: ui/gfx/canvas.cc

Issue 2527513002: Update ash shelf/tray focus rects. (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/canvas.h ('k') | ui/views/controls/slider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/canvas.cc
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index 01c30cd939211e75cd965c26741039d0ba8c5872..5dd577419e9fa90eb1da9236db7af01300eb2cd2 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -14,6 +14,7 @@
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "ui/gfx/font_list.h"
+#include "ui/gfx/geometry/insets_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
@@ -342,24 +343,16 @@ void Canvas::DrawFocusRect(const RectF& rect) {
DrawDashedRect(rect, SK_ColorGRAY);
}
-void Canvas::DrawSolidFocusRect(const Rect& rect, SkColor color) {
- DrawSolidFocusRect(RectF(rect), color);
-}
-
-void Canvas::DrawSolidFocusRect(const RectF& rect, SkColor color) {
+void Canvas::DrawSolidFocusRect(const RectF& rect,
+ SkColor color,
+ float thickness) {
SkPaint paint;
paint.setColor(color);
- paint.setStrokeWidth(SK_Scalar1);
- // Note: We cannot use DrawRect since it would create a path and fill it which
- // would cause problems near the edge of the canvas.
- float x1 = std::min(rect.x(), rect.right());
- float x2 = std::max(rect.x(), rect.right());
- float y1 = std::min(rect.y(), rect.bottom());
- float y2 = std::max(rect.y(), rect.bottom());
- DrawLine(PointF(x1, y1), PointF(x2, y1), paint);
- DrawLine(PointF(x1, y2), PointF(x2, y2), paint);
- DrawLine(PointF(x1, y1), PointF(x1, y2), paint);
- DrawLine(PointF(x2, y1), PointF(x2, y2 + 1.f), paint);
+ paint.setStrokeWidth(SkFloatToScalar(thickness));
+ paint.setStyle(SkPaint::kStroke_Style);
+ gfx::RectF draw_rect = rect;
+ draw_rect.Inset(gfx::InsetsF(thickness / 2));
+ DrawRect(draw_rect, paint);
}
void Canvas::DrawImageInt(const ImageSkia& image, int x, int y) {
« no previous file with comments | « ui/gfx/canvas.h ('k') | ui/views/controls/slider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698