Chromium Code Reviews| Index: ui/views/controls/separator.cc |
| diff --git a/ui/views/controls/separator.cc b/ui/views/controls/separator.cc |
| index 5ec611832bd1aa7758a4d86702fb74c4a781b7a9..4c28e5165c6cfd052e4a5ffaa28edb60e0dd24bb 100644 |
| --- a/ui/views/controls/separator.cc |
| +++ b/ui/views/controls/separator.cc |
| @@ -13,43 +13,31 @@ namespace views { |
| // static |
| const char Separator::kViewClassName[] = "Separator"; |
| -// The separator size in pixels. |
| -const int kSeparatorSize = 1; |
| - |
| -Separator::Separator(Orientation orientation) |
| - : orientation_(orientation), |
| - color_overridden_(false), |
| - size_(kSeparatorSize) { |
| - SetColorFromNativeTheme(); |
| -} |
| +// static |
| +const int Separator::kThickness = 1; |
| -Separator::~Separator() { |
| -} |
| +Separator::Separator(Orientation orientation) : orientation_(orientation) {} |
| + |
| +Separator::~Separator() {} |
| void Separator::SetColor(SkColor color) { |
| - color_ = color; |
| - color_overridden_ = true; |
| + overridden_color_ = color; |
| SchedulePaint(); |
| } |
| -void Separator::SetPreferredSize(int size) { |
| - if (size != size_) { |
| - size_ = size; |
| +void Separator::SetPreferredLength(int length) { |
| + if (length != length_) { |
| + length_ = length; |
| PreferredSizeChanged(); |
| } |
| } |
| -void Separator::SetColorFromNativeTheme() { |
| - color_ = GetNativeTheme()->GetSystemColor( |
| - ui::NativeTheme::kColorId_SeparatorColor); |
| -} |
| - |
| //////////////////////////////////////////////////////////////////////////////// |
| // Separator, View overrides: |
| gfx::Size Separator::GetPreferredSize() const { |
| - gfx::Size size = |
| - orientation_ == HORIZONTAL ? gfx::Size(1, size_) : gfx::Size(size_, 1); |
| + gfx::Size size = orientation_ == HORIZONTAL ? gfx::Size(length_, kThickness) |
|
tdanderson
2017/02/06 21:19:06
You're switching the meaning of HORIZONTAL vs VERT
Evan Stade
2017/02/06 21:39:17
The meaning of horizontal and vertical are the sam
sky
2017/02/07 19:02:49
I see where you are going. I find the change to se
Evan Stade
2017/02/07 21:39:50
I looked into this but it's not convenient to actu
|
| + : gfx::Size(kThickness, length_); |
| gfx::Insets insets = GetInsets(); |
| size.Enlarge(insets.width(), insets.height()); |
| return size; |
| @@ -60,12 +48,15 @@ void Separator::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| } |
| void Separator::OnPaint(gfx::Canvas* canvas) { |
| - canvas->FillRect(GetContentsBounds(), color_); |
| -} |
| - |
| -void Separator::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| - if (!color_overridden_) |
| - SetColorFromNativeTheme(); |
| + SkColor color = overridden_color_ |
| + ? *overridden_color_ |
| + : GetNativeTheme()->GetSystemColor( |
| + ui::NativeTheme::kColorId_SeparatorColor); |
| + |
| + // The separator fills its bounds, but avoid filling partial pixels. |
|
sky
2017/02/03 23:49:45
Are you sure this is the right thing? As views don
Evan Stade
2017/02/06 16:31:26
yes. Before/after screenshot posted to bug. If the
sky
2017/02/06 17:59:21
Do we need to turn on aa?
Evan Stade
2017/02/06 19:03:29
We want an integral number of pixels. AA would giv
sky
2017/02/06 22:42:55
I think we're going in circles. We really need vie
Evan Stade
2017/02/07 16:57:54
Yea, but I thought that was a long way off from be
|
| + float dsf = canvas->UndoDeviceScaleFactor(); |
| + gfx::RectF contents = gfx::ScaleRect(gfx::RectF(GetContentsBounds()), dsf); |
| + canvas->FillRect(gfx::ToEnclosedRect(contents), color); |
| } |
| const char* Separator::GetClassName() const { |