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

Unified Diff: ui/views/controls/focusable_border.cc

Issue 2228593002: Implement Harmony textfield border (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tapted to the resuce Created 4 years, 4 months 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/controls/focusable_border.h ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/focusable_border.cc
diff --git a/ui/views/controls/focusable_border.cc b/ui/views/controls/focusable_border.cc
index a4e76ff1ba2c88e4bd63a56b4f41f9f2cbc9ad3f..2274b3cdcd4d22ae40bd419cef4ad0869ebc9217 100644
--- a/ui/views/controls/focusable_border.cc
+++ b/ui/views/controls/focusable_border.cc
@@ -10,6 +10,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/insets.h"
+#include "ui/gfx/scoped_canvas.h"
#include "ui/gfx/skia_util.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/controls/textfield/textfield.h"
@@ -45,18 +46,27 @@ void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) {
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(GetCurrentColor(view));
- SkPath path;
if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
- path.moveTo(Textfield::kTextPadding, view.height() - 1);
- path.rLineTo(view.width() - Textfield::kTextPadding * 2, 0);
- path.offset(0.5f, 0.5f);
- paint.setStrokeWidth(SkIntToScalar(1));
+ gfx::ScopedCanvas scoped(canvas);
+ float dsf = canvas->UndoDeviceScaleFactor();
+ gfx::RectF rect((gfx::Rect(view.GetLocalBounds())));
+ rect = ScaleRect(rect, dsf, dsf);
+ rect.Inset(gfx::InsetsF(0.5f));
+ SkPath path;
+ float corner_radius_px = kCornerRadiusDp * dsf;
+ path.addRoundRect(gfx::RectFToSkRect(rect), corner_radius_px,
+ corner_radius_px);
+ const int kStrokeWidthPx = 1;
+ paint.setStrokeWidth(SkIntToScalar(kStrokeWidthPx));
+ paint.setAntiAlias(true);
+ canvas->DrawPath(path, paint);
} else {
+ SkPath path;
path.addRect(gfx::RectToSkRect(view.GetLocalBounds()),
SkPath::kCW_Direction);
paint.setStrokeWidth(SkIntToScalar(2));
+ canvas->DrawPath(path, paint);
}
- canvas->DrawPath(path, paint);
}
gfx::Insets FocusableBorder::GetInsets() const {
« no previous file with comments | « ui/views/controls/focusable_border.h ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698