| 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 enum Orientation { |
| 22 // The separator is a horizontal line that distinguishes vertically stacked |
| 23 // elements. |
| 21 HORIZONTAL, | 24 HORIZONTAL, |
| 22 VERTICAL | 25 // The separator is a vertical line that distinguishes a row of elements. |
| 26 VERTICAL, |
| 23 }; | 27 }; |
| 24 | 28 |
| 25 // The separator's class name. | 29 // The separator's class name. |
| 26 static const char kViewClassName[]; | 30 static const char kViewClassName[]; |
| 27 | 31 |
| 32 // The separator's thickness in dip. |
| 33 static const int kThickness; |
| 34 |
| 28 explicit Separator(Orientation orientation); | 35 explicit Separator(Orientation orientation); |
| 29 ~Separator() override; | 36 ~Separator() override; |
| 30 | 37 |
| 31 SkColor color() const { return color_; } | |
| 32 void SetColor(SkColor color); | 38 void SetColor(SkColor color); |
| 33 | 39 |
| 34 int size() const { return size_; } | 40 // Preferred length: width for horizontal separator and height for vertical |
| 35 // Preferred size of one axis: height for horizontal separator | 41 // separator. |
| 36 // and width for vertical separator | 42 void SetPreferredLength(int length); |
| 37 void SetPreferredSize(int size); | |
| 38 | 43 |
| 39 // Overridden from View: | 44 // Overridden from View: |
| 40 gfx::Size GetPreferredSize() const override; | 45 gfx::Size GetPreferredSize() const override; |
| 41 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 46 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 42 void OnPaint(gfx::Canvas* canvas) override; | 47 void OnPaint(gfx::Canvas* canvas) override; |
| 43 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | |
| 44 const char* GetClassName() const override; | 48 const char* GetClassName() const override; |
| 45 | 49 |
| 46 private: | 50 private: |
| 47 void SetColorFromNativeTheme(); | |
| 48 | |
| 49 const Orientation orientation_; | 51 const Orientation orientation_; |
| 50 SkColor color_; | 52 base::Optional<SkColor> overridden_color_; |
| 51 bool color_overridden_; | 53 // The length to request in GetPreferredSize(). |
| 52 int size_; | 54 int length_ = 1; |
| 53 | 55 |
| 54 DISALLOW_COPY_AND_ASSIGN(Separator); | 56 DISALLOW_COPY_AND_ASSIGN(Separator); |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 } // namespace views | 59 } // namespace views |
| 58 | 60 |
| 59 #endif // UI_VIEWS_CONTROLS_SEPARATOR_H_ | 61 #endif // UI_VIEWS_CONTROLS_SEPARATOR_H_ |
| OLD | NEW |