Add UMA reports for Linux nacl_helper startup status
[chromium-blink-merge.git] / views / controls / focusable_border.cc
bloba1aa667145807961a14b2bf92c1292aec60ec3c2
1 // Copyright (c) 2011 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 "views/controls/focusable_border.h"
7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/canvas_skia.h"
9 #include "ui/gfx/insets.h"
11 namespace {
13 // Define the size of the insets
14 const int kTopInsetSize = 4;
15 const int kLeftInsetSize = 4;
16 const int kBottomInsetSize = 4;
17 const int kRightInsetSize = 4;
19 // Color settings for border.
20 // These are tentative, and should be derived from theme, system
21 // settings and current settings.
22 // TODO(saintlou): understand why this is not factored/shared somewhere
23 const SkColor kFocusedBorderColor = SK_ColorCYAN;
24 const SkColor kDefaultBorderColor = SK_ColorGRAY;
26 } // namespace
28 namespace views {
30 FocusableBorder::FocusableBorder()
31 : has_focus_(false),
32 insets_(kTopInsetSize, kLeftInsetSize,
33 kBottomInsetSize, kRightInsetSize) {
36 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) const {
37 SkRect rect;
38 rect.set(SkIntToScalar(0), SkIntToScalar(0),
39 SkIntToScalar(view.width()), SkIntToScalar(view.height()));
40 SkScalar corners[8] = {
41 // top-left
42 SkIntToScalar(insets_.left()),
43 SkIntToScalar(insets_.top()),
44 // top-right
45 SkIntToScalar(insets_.right()),
46 SkIntToScalar(insets_.top()),
47 // bottom-right
48 SkIntToScalar(insets_.right()),
49 SkIntToScalar(insets_.bottom()),
50 // bottom-left
51 SkIntToScalar(insets_.left()),
52 SkIntToScalar(insets_.bottom()),
54 SkPath path;
55 path.addRoundRect(rect, corners);
56 SkPaint paint;
57 paint.setStyle(SkPaint::kStroke_Style);
58 paint.setFlags(SkPaint::kAntiAlias_Flag);
59 // TODO(oshima): Copy what WebKit does for focused border.
60 paint.setColor(has_focus_ ? kFocusedBorderColor : kDefaultBorderColor);
61 paint.setStrokeWidth(SkIntToScalar(has_focus_ ? 2 : 1));
63 canvas->GetSkCanvas()->drawPath(path, paint);
66 void FocusableBorder::GetInsets(gfx::Insets* insets) const {
67 *insets = insets_;
70 void FocusableBorder::SetInsets(int top, int left, int bottom, int right) {
71 insets_.Set(top, left, bottom, right);
74 } // namespace views