blob: 8be91e790d273f6d53c43ca9e5efe678066706f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/controls/separator.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/gfx/canvas.h"
#include "ui/native_theme/native_theme.h"
namespace views {
// static
const char Separator::kViewClassName[] = "Separator";
// static
const int Separator::kThickness = 1;
Separator::Separator() {}
Separator::~Separator() {}
void Separator::SetColor(SkColor color) {
overridden_color_ = color;
SchedulePaint();
}
void Separator::SetPreferredHeight(int height) {
preferred_height_ = height;
PreferredSizeChanged();
}
////////////////////////////////////////////////////////////////////////////////
// Separator, View overrides:
gfx::Size Separator::CalculatePreferredSize() const {
gfx::Size size(kThickness, preferred_height_);
gfx::Insets insets = GetInsets();
size.Enlarge(insets.width(), insets.height());
return size;
}
void Separator::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ax::mojom::Role::kSplitter;
}
void Separator::OnPaint(gfx::Canvas* canvas) {
SkColor color = overridden_color_
? *overridden_color_
: GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_SeparatorColor);
// The separator fills its bounds, but avoid filling partial pixels.
float dsf = canvas->UndoDeviceScaleFactor();
gfx::RectF contents = gfx::ScaleRect(gfx::RectF(GetContentsBounds()), dsf);
canvas->FillRect(gfx::ToEnclosedRect(contents), color);
View::OnPaint(canvas);
}
const char* Separator::GetClassName() const {
return kViewClassName;
}
} // namespace views
|