Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / ui / views / controls / focusable_border.cc
blob74b487555e0d39a13ea00bea9a83d139d44d4008
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
3 // found in the LICENSE file.
5 #include "ui/views/controls/focusable_border.h"
7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/geometry/insets.h"
9 #include "ui/gfx/skia_util.h"
10 #include "ui/native_theme/native_theme.h"
12 namespace {
14 const int kInsetSize = 1;
16 } // namespace
18 namespace views {
20 FocusableBorder::FocusableBorder()
21 : insets_(kInsetSize, kInsetSize, kInsetSize, kInsetSize),
22 override_color_(SK_ColorWHITE),
23 use_default_color_(true) {
26 FocusableBorder::~FocusableBorder() {
29 void FocusableBorder::SetColor(SkColor color) {
30 override_color_ = color;
31 use_default_color_ = false;
34 void FocusableBorder::UseDefaultColor() {
35 use_default_color_ = true;
38 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) {
39 SkPath path;
40 path.addRect(gfx::RectToSkRect(view.GetLocalBounds()), SkPath::kCW_Direction);
41 SkPaint paint;
42 paint.setStyle(SkPaint::kStroke_Style);
43 SkColor color = override_color_;
44 if (use_default_color_) {
45 color = view.GetNativeTheme()->GetSystemColor(
46 view.HasFocus() ? ui::NativeTheme::kColorId_FocusedBorderColor :
47 ui::NativeTheme::kColorId_UnfocusedBorderColor);
50 paint.setColor(color);
51 paint.setStrokeWidth(SkIntToScalar(2));
53 canvas->DrawPath(path, paint);
56 gfx::Insets FocusableBorder::GetInsets() const {
57 return insets_;
60 gfx::Size FocusableBorder::GetMinimumSize() const {
61 return gfx::Size();
64 void FocusableBorder::SetInsets(int top, int left, int bottom, int right) {
65 insets_.Set(top, left, bottom, right);
68 } // namespace views