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

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

Issue 8687031: views: Move the remaining files to ui/views/controls/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « views/controls/focusable_border.h ('k') | views/controls/image_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "views/controls/focusable_border.h"
6
7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/canvas_skia.h"
9 #include "ui/gfx/insets.h"
10
11 namespace {
12
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;
18
19 // Color settings for border.
20 // These are tentative, and should be derived from theme, system
21 // settings and current settings.
22 const SkColor kFocusedBorderColor = SK_ColorCYAN;
23 const SkColor kDefaultBorderColor = SK_ColorGRAY;
24
25 } // namespace
26
27 namespace views {
28
29 FocusableBorder::FocusableBorder()
30 : has_focus_(false),
31 insets_(kTopInsetSize, kLeftInsetSize,
32 kBottomInsetSize, kRightInsetSize) {
33 }
34
35 void FocusableBorder::Paint(const View& view, gfx::Canvas* canvas) const {
36 SkRect rect;
37 rect.set(SkIntToScalar(0), SkIntToScalar(0),
38 SkIntToScalar(view.width()), SkIntToScalar(view.height()));
39 SkScalar corners[8] = {
40 // top-left
41 SkIntToScalar(insets_.left()),
42 SkIntToScalar(insets_.top()),
43 // top-right
44 SkIntToScalar(insets_.right()),
45 SkIntToScalar(insets_.top()),
46 // bottom-right
47 SkIntToScalar(insets_.right()),
48 SkIntToScalar(insets_.bottom()),
49 // bottom-left
50 SkIntToScalar(insets_.left()),
51 SkIntToScalar(insets_.bottom()),
52 };
53 SkPath path;
54 path.addRoundRect(rect, corners);
55 SkPaint paint;
56 paint.setStyle(SkPaint::kStroke_Style);
57 paint.setFlags(SkPaint::kAntiAlias_Flag);
58 // TODO(oshima): Copy what WebKit does for focused border.
59 paint.setColor(has_focus_ ? kFocusedBorderColor : kDefaultBorderColor);
60 paint.setStrokeWidth(SkIntToScalar(has_focus_ ? 2 : 1));
61
62 canvas->GetSkCanvas()->drawPath(path, paint);
63 }
64
65 void FocusableBorder::GetInsets(gfx::Insets* insets) const {
66 *insets = insets_;
67 }
68
69 void FocusableBorder::SetInsets(int top, int left, int bottom, int right) {
70 insets_.Set(top, left, bottom, right);
71 }
72
73 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/focusable_border.h ('k') | views/controls/image_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698