OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_VIEWS_CONTROLS_SEPARATOR_H_ | 5 #ifndef UI_VIEWS_CONTROLS_SEPARATOR_H_ |
6 #define UI_VIEWS_CONTROLS_SEPARATOR_H_ | 6 #define UI_VIEWS_CONTROLS_SEPARATOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/optional.h" |
11 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
12 | 13 |
13 namespace views { | 14 namespace views { |
14 | 15 |
15 // The Separator class is a view that shows a line used to visually separate | 16 // The Separator class is a view that shows a line used to visually separate |
16 // other views. | 17 // other views. |
17 | |
18 class VIEWS_EXPORT Separator : public View { | 18 class VIEWS_EXPORT Separator : public View { |
19 public: | 19 public: |
20 enum Orientation { | |
21 HORIZONTAL, | |
22 VERTICAL | |
23 }; | |
24 | |
25 // The separator's class name. | 20 // The separator's class name. |
26 static const char kViewClassName[]; | 21 static const char kViewClassName[]; |
27 | 22 |
28 explicit Separator(Orientation orientation); | 23 // The separator's thickness in dip. |
| 24 static const int kThickness; |
| 25 |
| 26 Separator(); |
29 ~Separator() override; | 27 ~Separator() override; |
30 | 28 |
31 SkColor color() const { return color_; } | |
32 void SetColor(SkColor color); | 29 void SetColor(SkColor color); |
33 | 30 |
34 int size() const { return size_; } | 31 void SetPreferredHeight(int height); |
35 // Preferred size of one axis: height for horizontal separator | |
36 // and width for vertical separator | |
37 void SetPreferredSize(int size); | |
38 | 32 |
39 // Overridden from View: | 33 // Overridden from View: |
40 gfx::Size GetPreferredSize() const override; | 34 gfx::Size GetPreferredSize() const override; |
41 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 35 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
42 void OnPaint(gfx::Canvas* canvas) override; | 36 void OnPaint(gfx::Canvas* canvas) override; |
43 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | |
44 const char* GetClassName() const override; | 37 const char* GetClassName() const override; |
45 | 38 |
46 private: | 39 private: |
47 void SetColorFromNativeTheme(); | 40 int preferred_height_ = kThickness; |
48 | 41 base::Optional<SkColor> overridden_color_; |
49 const Orientation orientation_; | |
50 SkColor color_; | |
51 bool color_overridden_; | |
52 int size_; | |
53 | 42 |
54 DISALLOW_COPY_AND_ASSIGN(Separator); | 43 DISALLOW_COPY_AND_ASSIGN(Separator); |
55 }; | 44 }; |
56 | 45 |
57 } // namespace views | 46 } // namespace views |
58 | 47 |
59 #endif // UI_VIEWS_CONTROLS_SEPARATOR_H_ | 48 #endif // UI_VIEWS_CONTROLS_SEPARATOR_H_ |
OLD | NEW |