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

Unified Diff: ui/views/painter.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/views/painter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/painter.cc
diff --git a/ui/views/painter.cc b/ui/views/painter.cc
index 8d4fc45aa28fc232919e09836fc5a3b92b81fc78..e2ac629c3f116eb891f4a3dcd30a1c874e0c851e 100644
--- a/ui/views/painter.cc
+++ b/ui/views/painter.cc
@@ -14,6 +14,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
+#include "ui/gfx/geometry/insets_f.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
@@ -119,7 +120,9 @@ void DashedFocusPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
class SolidFocusPainter : public Painter {
public:
- SolidFocusPainter(SkColor color, const gfx::Insets& insets);
+ SolidFocusPainter(SkColor color,
+ SkScalar thickness,
+ const gfx::InsetsF& insets);
~SolidFocusPainter() override;
// Painter:
@@ -128,16 +131,16 @@ class SolidFocusPainter : public Painter {
private:
const SkColor color_;
- const gfx::Insets insets_;
+ const SkScalar thickness_;
+ const gfx::InsetsF insets_;
DISALLOW_COPY_AND_ASSIGN(SolidFocusPainter);
};
SolidFocusPainter::SolidFocusPainter(SkColor color,
- const gfx::Insets& insets)
- : color_(color),
- insets_(insets) {
-}
+ SkScalar thickness,
+ const gfx::InsetsF& insets)
+ : color_(color), thickness_(thickness), insets_(insets) {}
SolidFocusPainter::~SolidFocusPainter() {
}
@@ -147,9 +150,9 @@ gfx::Size SolidFocusPainter::GetMinimumSize() const {
}
void SolidFocusPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
- gfx::Rect rect(size);
+ gfx::RectF rect((gfx::Rect(size)));
rect.Inset(insets_);
- canvas->DrawSolidFocusRect(rect, color_);
+ canvas->DrawSolidFocusRect(rect, color_, thickness_);
}
// GradientPainter ------------------------------------------------------------
@@ -356,7 +359,22 @@ std::unique_ptr<Painter> Painter::CreateDashedFocusPainterWithInsets(
std::unique_ptr<Painter> Painter::CreateSolidFocusPainter(
SkColor color,
const gfx::Insets& insets) {
- return base::MakeUnique<SolidFocusPainter>(color, insets);
+ // Before Canvas::DrawSolidFocusRect correctly inset the rect's bounds based
+ // on the thickness, callers had to add 1 to the bottom and right insets.
+ // Subtract that here so it works the same way with the new
+ // Canvas::DrawSolidFocusRect.
+ const gfx::Insets corrected_insets = insets - gfx::Insets(0, 0, 1, 1);
+ return base::MakeUnique<SolidFocusPainter>(color, SkIntToScalar(1),
+ corrected_insets);
+}
+
+// static
+std::unique_ptr<Painter> Painter::CreateSolidFocusPainter(
+ SkColor color,
+ float thickness,
+ const gfx::InsetsF& insets) {
+ return base::MakeUnique<SolidFocusPainter>(color, SkFloatToScalar(thickness),
+ insets);
}
// HorizontalPainter ----------------------------------------------------------
« no previous file with comments | « ui/views/painter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698