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 {
47 if (orientation_
== HORIZONTAL
)
48 return gfx::Size(width(), size_
);
49 return gfx::Size(size_
, height());
52 void Separator::GetAccessibleState(ui::AXViewState
* state
) {
53 state
->role
= ui::AX_ROLE_SPLITTER
;
56 void Separator::OnPaint(gfx::Canvas
* canvas
) {
57 canvas
->FillRect(GetContentsBounds(), color_
);
60 const char* Separator::GetClassName() const {
61 return kViewClassName
;