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

Side by Side Diff: ui/views/controls/focusable_border.cc

Issue 2314983003: Harmony - manually draw combobox arrows. (Closed)
Patch Set: silence windows complaint Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/focusable_border.h" 5 #include "ui/views/controls/focusable_border.h"
6 6
7 #include "third_party/skia/include/core/SkPaint.h" 7 #include "third_party/skia/include/core/SkPaint.h"
8 #include "third_party/skia/include/core/SkPath.h" 8 #include "third_party/skia/include/core/SkPath.h"
9 #include "ui/base/material_design/material_design_controller.h" 9 #include "ui/base/material_design/material_design_controller.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) { 44 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) {
45 SkPaint paint; 45 SkPaint paint;
46 paint.setStyle(SkPaint::kStroke_Style); 46 paint.setStyle(SkPaint::kStroke_Style);
47 paint.setColor(GetCurrentColor(view)); 47 paint.setColor(GetCurrentColor(view));
48 48
49 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { 49 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
50 gfx::ScopedCanvas scoped(canvas); 50 gfx::ScopedCanvas scoped(canvas);
51 float dsf = canvas->UndoDeviceScaleFactor(); 51 float dsf = canvas->UndoDeviceScaleFactor();
52 gfx::RectF rect((gfx::Rect(view.GetLocalBounds()))); 52 // Scale the rect and snap to pixel boundaries.
53 rect = ScaleRect(rect, dsf, dsf); 53 gfx::RectF rect = gfx::RectF(gfx::ToEnclosedRect(
54 ScaleRect(gfx::RectF(view.GetLocalBounds()), dsf, dsf)));
54 rect.Inset(gfx::InsetsF(0.5f)); 55 rect.Inset(gfx::InsetsF(0.5f));
55 SkPath path; 56 SkPath path;
56 float corner_radius_px = kCornerRadiusDp * dsf; 57 float corner_radius_px = kCornerRadiusDp * dsf;
57 path.addRoundRect(gfx::RectFToSkRect(rect), corner_radius_px, 58 path.addRoundRect(gfx::RectFToSkRect(rect), corner_radius_px,
58 corner_radius_px); 59 corner_radius_px);
59 const int kStrokeWidthPx = 1; 60 const int kStrokeWidthPx = 1;
60 paint.setStrokeWidth(SkIntToScalar(kStrokeWidthPx)); 61 paint.setStrokeWidth(SkIntToScalar(kStrokeWidthPx));
61 paint.setAntiAlias(true); 62 paint.setAntiAlias(true);
62 canvas->DrawPath(path, paint); 63 canvas->DrawPath(path, paint);
63 } else { 64 } else {
(...skipping 19 matching lines...) Expand all
83 84
84 SkColor FocusableBorder::GetCurrentColor(const View& view) const { 85 SkColor FocusableBorder::GetCurrentColor(const View& view) const {
85 if (!use_default_color_) 86 if (!use_default_color_)
86 return override_color_; 87 return override_color_;
87 return view.GetNativeTheme()->GetSystemColor( 88 return view.GetNativeTheme()->GetSystemColor(
88 view.HasFocus() ? ui::NativeTheme::kColorId_FocusedBorderColor : 89 view.HasFocus() ? ui::NativeTheme::kColorId_FocusedBorderColor :
89 ui::NativeTheme::kColorId_UnfocusedBorderColor); 90 ui::NativeTheme::kColorId_UnfocusedBorderColor);
90 } 91 }
91 92
92 } // namespace views 93 } // namespace views
OLDNEW
« ui/views/controls/combobox/combobox.cc ('K') | « ui/views/controls/combobox/combobox.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698