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

Side by Side Diff: views/border.cc

Issue 8771006: views: Move the remaining file from views/ to ui/views/. (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/border.h ('k') | views/native_theme_delegate.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/border.h"
6
7 #include "base/logging.h"
8 #include "ui/gfx/canvas.h"
9
10 namespace views {
11
12 namespace {
13
14 // A simple border with a fixed thickness and single color.
15 class SolidBorder : public Border {
16 public:
17 SolidBorder(int thickness, SkColor color);
18
19 virtual void Paint(const View& view, gfx::Canvas* canvas) const;
20 virtual void GetInsets(gfx::Insets* insets) const;
21
22 private:
23 int thickness_;
24 SkColor color_;
25 gfx::Insets insets_;
26
27 DISALLOW_COPY_AND_ASSIGN(SolidBorder);
28 };
29
30 SolidBorder::SolidBorder(int thickness, SkColor color)
31 : thickness_(thickness),
32 color_(color),
33 insets_(thickness, thickness, thickness, thickness) {
34 }
35
36 void SolidBorder::Paint(const View& view, gfx::Canvas* canvas) const {
37 // Top border.
38 canvas->FillRect(color_, gfx::Rect(0, 0, view.width(), insets_.top()));
39 // Left border.
40 canvas->FillRect(color_, gfx::Rect(0, 0, insets_.left(), view.height()));
41 // Bottom border.
42 canvas->FillRect(color_, gfx::Rect(0, view.height() - insets_.bottom(),
43 view.width(), insets_.bottom()));
44 // Right border.
45 canvas->FillRect(color_, gfx::Rect(view.width() - insets_.right(), 0,
46 insets_.right(), view.height()));
47 }
48
49 void SolidBorder::GetInsets(gfx::Insets* insets) const {
50 DCHECK(insets);
51 insets->Set(insets_.top(), insets_.left(), insets_.bottom(), insets_.right());
52 }
53
54 class EmptyBorder : public Border {
55 public:
56 EmptyBorder(int top, int left, int bottom, int right)
57 : top_(top), left_(left), bottom_(bottom), right_(right) {}
58
59 virtual void Paint(const View& view, gfx::Canvas* canvas) const {}
60
61 virtual void GetInsets(gfx::Insets* insets) const {
62 DCHECK(insets);
63 insets->Set(top_, left_, bottom_, right_);
64 }
65
66 private:
67 int top_;
68 int left_;
69 int bottom_;
70 int right_;
71
72 DISALLOW_COPY_AND_ASSIGN(EmptyBorder);
73 };
74 }
75
76 Border::Border() {
77 }
78
79 Border::~Border() {
80 }
81
82 // static
83 Border* Border::CreateSolidBorder(int thickness, SkColor color) {
84 return new SolidBorder(thickness, color);
85 }
86
87 // static
88 Border* Border::CreateEmptyBorder(int top, int left, int bottom, int right) {
89 return new EmptyBorder(top, left, bottom, right);
90 }
91
92 } // namespace views
OLDNEW
« no previous file with comments | « views/border.h ('k') | views/native_theme_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698