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/separator.h"
7 #include "ui/accessibility/ax_view_state.h"
8 #include "ui/gfx/canvas.h"
13 const char Separator::kViewClassName
[] = "Separator";
15 // The separator size in pixels.
16 const int kSeparatorSize
= 1;
18 // Default color of the separator.
19 const SkColor kDefaultColor
= SkColorSetARGB(255, 233, 233, 233);
21 Separator::Separator(Orientation orientation
)
22 : orientation_(orientation
),
23 color_(kDefaultColor
),
24 size_(kSeparatorSize
) {
28 Separator::~Separator() {
31 void Separator::SetColor(SkColor color
) {
36 void Separator::SetPreferredSize(int size
) {
39 PreferredSizeChanged();
43 ////////////////////////////////////////////////////////////////////////////////
44 // Separator, View overrides:
46 gfx::Size
Separator::GetPreferredSize() const {
48 orientation_
== HORIZONTAL
? gfx::Size(1, size_
) : gfx::Size(size_
, 1);
49 gfx::Insets insets
= GetInsets();
50 size
.Enlarge(insets
.width(), insets
.height());
54 void Separator::GetAccessibleState(ui::AXViewState
* state
) {
55 state
->role
= ui::AX_ROLE_SPLITTER
;
58 void Separator::OnPaint(gfx::Canvas
* canvas
) {
59 canvas
->FillRect(GetContentsBounds(), color_
);
62 const char* Separator::GetClassName() const {
63 return kViewClassName
;