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

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

Issue 1931013002: MD-ify textfields and combobox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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
« no previous file with comments | « ui/native_theme/common_theme.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/color_palette.h"
10 #include "ui/gfx/geometry/insets.h" 12 #include "ui/gfx/geometry/insets.h"
11 #include "ui/gfx/skia_util.h" 13 #include "ui/gfx/skia_util.h"
12 #include "ui/native_theme/native_theme.h" 14 #include "ui/native_theme/native_theme.h"
15 #include "ui/views/controls/textfield/textfield.h"
13 16
14 namespace { 17 namespace {
15 18
16 const int kInsetSize = 1; 19 const int kInsetSize = 1;
17 20
18 } // namespace 21 } // namespace
19 22
20 namespace views { 23 namespace views {
21 24
22 FocusableBorder::FocusableBorder() 25 FocusableBorder::FocusableBorder()
23 : insets_(kInsetSize, kInsetSize, kInsetSize, kInsetSize), 26 : insets_(kInsetSize, kInsetSize, kInsetSize, kInsetSize),
24 override_color_(SK_ColorWHITE), 27 override_color_(gfx::kPlaceholderColor),
25 use_default_color_(true) { 28 use_default_color_(true) {
26 } 29 }
27 30
28 FocusableBorder::~FocusableBorder() { 31 FocusableBorder::~FocusableBorder() {
29 } 32 }
30 33
31 void FocusableBorder::SetColor(SkColor color) { 34 void FocusableBorder::SetColor(SkColor color) {
32 override_color_ = color; 35 override_color_ = color;
33 use_default_color_ = false; 36 use_default_color_ = false;
34 } 37 }
35 38
36 void FocusableBorder::UseDefaultColor() { 39 void FocusableBorder::UseDefaultColor() {
37 use_default_color_ = true; 40 use_default_color_ = true;
38 } 41 }
39 42
40 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) { 43 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) {
41 SkPath path;
42 path.addRect(gfx::RectToSkRect(view.GetLocalBounds()), SkPath::kCW_Direction);
43 SkPaint paint; 44 SkPaint paint;
44 paint.setStyle(SkPaint::kStroke_Style); 45 paint.setStyle(SkPaint::kStroke_Style);
46 paint.setColor(GetCurrentColor(view));
45 47
46 paint.setColor(GetCurrentColor(view)); 48 SkPath path;
47 paint.setStrokeWidth(SkIntToScalar(2)); 49 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
48 50 path.moveTo(Textfield::kTextPadding, view.height() - 1);
51 path.rLineTo(view.width() - Textfield::kTextPadding * 2, 0);
52 path.offset(0.5f, 0.5f);
53 paint.setStrokeWidth(SkIntToScalar(1));
54 } else {
55 path.addRect(gfx::RectToSkRect(view.GetLocalBounds()),
56 SkPath::kCW_Direction);
57 paint.setStrokeWidth(SkIntToScalar(2));
58 }
49 canvas->DrawPath(path, paint); 59 canvas->DrawPath(path, paint);
50 } 60 }
51 61
52 gfx::Insets FocusableBorder::GetInsets() const { 62 gfx::Insets FocusableBorder::GetInsets() const {
53 return insets_; 63 return insets_;
54 } 64 }
55 65
56 gfx::Size FocusableBorder::GetMinimumSize() const { 66 gfx::Size FocusableBorder::GetMinimumSize() const {
57 return gfx::Size(); 67 return gfx::Size();
58 } 68 }
59 69
60 void FocusableBorder::SetInsets(int top, int left, int bottom, int right) { 70 void FocusableBorder::SetInsets(int top, int left, int bottom, int right) {
61 insets_.Set(top, left, bottom, right); 71 insets_.Set(top, left, bottom, right);
62 } 72 }
63 73
64 SkColor FocusableBorder::GetCurrentColor(const View& view) const { 74 SkColor FocusableBorder::GetCurrentColor(const View& view) const {
65 if (!use_default_color_) 75 if (!use_default_color_)
66 return override_color_; 76 return override_color_;
67 return view.GetNativeTheme()->GetSystemColor( 77 return view.GetNativeTheme()->GetSystemColor(
68 view.HasFocus() ? ui::NativeTheme::kColorId_FocusedBorderColor : 78 view.HasFocus() ? ui::NativeTheme::kColorId_FocusedBorderColor :
69 ui::NativeTheme::kColorId_UnfocusedBorderColor); 79 ui::NativeTheme::kColorId_UnfocusedBorderColor);
70 } 80 }
71 81
72 } // namespace views 82 } // namespace views
OLDNEW
« no previous file with comments | « ui/native_theme/common_theme.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698