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 |
18 class VIEWS_EXPORT Separator : public View { | 19 class VIEWS_EXPORT Separator : public View { |
19 public: | 20 public: |
20 enum Orientation { | |
21 HORIZONTAL, | |
22 VERTICAL | |
23 }; | |
24 | |
25 // The separator's class name. | 21 // The separator's class name. |
26 static const char kViewClassName[]; | 22 static const char kViewClassName[]; |
27 | 23 |
28 explicit Separator(Orientation orientation); | 24 // The separator's thickness in dip. |
sky
2017/02/09 03:16:09
optional: Generally values are assumed to be dip u
Evan Stade
2017/02/09 15:46:11
Yea, you're right, my desire for extra clarity her
| |
25 static const int kThickness; | |
26 | |
27 // Constructs a separator that is ambivalent to orientation. To be used in the | |
28 // common case where sizing will be controlled by the layout manager. | |
sky
2017/02/09 03:16:09
Please document the preferred size is kThickness i
Evan Stade
2017/02/09 15:46:11
will do
| |
29 Separator(); | |
29 ~Separator() override; | 30 ~Separator() override; |
30 | 31 |
31 SkColor color() const { return color_; } | |
32 void SetColor(SkColor color); | 32 void SetColor(SkColor color); |
33 | 33 |
34 int size() const { return size_; } | 34 void SetPreferredHeight(int height); |
35 // Preferred size of one axis: height for horizontal separator | 35 |
36 // and width for vertical separator | 36 void SetPreferredWidth(int width); |
37 void SetPreferredSize(int size); | |
38 | 37 |
39 // Overridden from View: | 38 // Overridden from View: |
40 gfx::Size GetPreferredSize() const override; | 39 gfx::Size GetPreferredSize() const override; |
41 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 40 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
42 void OnPaint(gfx::Canvas* canvas) override; | 41 void OnPaint(gfx::Canvas* canvas) override; |
43 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | |
44 const char* GetClassName() const override; | 42 const char* GetClassName() const override; |
45 | 43 |
46 private: | 44 private: |
47 void SetColorFromNativeTheme(); | 45 gfx::Size preferred_size_; |
48 | 46 base::Optional<SkColor> overridden_color_; |
49 const Orientation orientation_; | |
50 SkColor color_; | |
51 bool color_overridden_; | |
52 int size_; | |
53 | 47 |
54 DISALLOW_COPY_AND_ASSIGN(Separator); | 48 DISALLOW_COPY_AND_ASSIGN(Separator); |
55 }; | 49 }; |
56 | 50 |
57 } // namespace views | 51 } // namespace views |
58 | 52 |
59 #endif // UI_VIEWS_CONTROLS_SEPARATOR_H_ | 53 #endif // UI_VIEWS_CONTROLS_SEPARATOR_H_ |
OLD | NEW |