Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(759)

Side by Side Diff: ui/views/controls/separator.h

Issue 2675983003: views::Separator cleanup. (Closed)
Patch Set: update docs Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
sky 2017/02/03 23:49:45 constexpr?
Evan Stade 2017/02/06 16:31:27 I don't understand this completely but this is the
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);
sky 2017/02/03 23:49:45 Is there a reason you prefer length here? I like s
Evan Stade 2017/02/06 16:31:27 That's exactly why I don't like size. Which dimens
sky 2017/02/06 17:59:21 I don't think there is a right answer here. I pref
Evan Stade 2017/02/06 19:03:29 size is used to describe a multi-dimensional value
sky 2017/02/06 22:42:55 'size' is used not inheritantly a multi-dimensiona
Evan Stade 2017/02/07 16:57:54 ok, but before this cl, this "size" actually meant
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698