Chromium Code Reviews| Index: ui/views/controls/tree/tree_view.cc |
| diff --git a/ui/views/controls/tree/tree_view.cc b/ui/views/controls/tree/tree_view.cc |
| index cb252dd9e97002779d228f3dd74c75ebf6a3e9d9..7e964f96c66ea799acd3547c60ee57475be07fbd 100644 |
| --- a/ui/views/controls/tree/tree_view.cc |
| +++ b/ui/views/controls/tree/tree_view.cc |
| @@ -16,9 +16,12 @@ |
| #include "ui/events/event.h" |
| #include "ui/events/keycodes/keyboard_codes.h" |
| #include "ui/gfx/canvas.h" |
| +#include "ui/gfx/color_utils.h" |
| #include "ui/gfx/geometry/rect.h" |
| #include "ui/gfx/geometry/rect_conversions.h" |
| #include "ui/gfx/image/image.h" |
| +#include "ui/gfx/image/image_skia_operations.h" |
| +#include "ui/gfx/paint_vector_icon.h" |
| #include "ui/gfx/skia_util.h" |
| #include "ui/native_theme/native_theme.h" |
| #include "ui/resources/grit/ui_resources.h" |
| @@ -29,6 +32,7 @@ |
| #include "ui/views/controls/tree/tree_view_controller.h" |
| #include "ui/views/resources/grit/views_resources.h" |
| #include "ui/views/style/platform_style.h" |
| +#include "ui/views/vector_icons.h" |
| using ui::TreeModel; |
| using ui::TreeModelNode; |
| @@ -823,31 +827,22 @@ void TreeView::PaintRow(gfx::Canvas* canvas, |
| void TreeView::PaintExpandControl(gfx::Canvas* canvas, |
| const gfx::Rect& node_bounds, |
| bool expanded) { |
| - int center_x; |
| - if (base::i18n::IsRTL()) { |
| - center_x = node_bounds.right() - kArrowRegionSize + |
| - (kArrowRegionSize - 4) / 2; |
| - } else { |
| - center_x = node_bounds.x() + (kArrowRegionSize - 4) / 2; |
| - } |
| - int center_y = node_bounds.y() + node_bounds.height() / 2; |
| - const SkColor arrow_color = GetNativeTheme()->GetSystemColor( |
| - ui::NativeTheme::kColorId_TreeArrow); |
| - // TODO: this should come from an image. |
| - if (!expanded) { |
| - int delta = base::i18n::IsRTL() ? 1 : -1; |
| - for (int i = 0; i < 4; ++i) { |
| - canvas->FillRect(gfx::Rect(center_x + delta * (2 - i), |
| - center_y - (3 - i), 1, (3 - i) * 2 + 1), |
| - arrow_color); |
| - } |
| - } else { |
| - center_y -= 2; |
| - for (int i = 0; i < 4; ++i) { |
| - canvas->FillRect(gfx::Rect(center_x - (3 - i), center_y + i, |
| - (3 - i) * 2 + 1, 1), arrow_color); |
| - } |
| + gfx::ImageSkia arrow = gfx::CreateVectorIcon( |
| + kSubmenuArrowIcon, |
| + color_utils::DeriveDefaultIconColor( |
| + GetNativeTheme()->GetSystemColor(text_color_id(false, false)))); |
|
Peter Kasting
2017/02/15 01:05:31
Any particular reason to move away from kColorId_T
Evan Stade
2017/02/15 01:28:58
Ah, forgot about that color. I think we should rem
Evan Stade
2017/02/15 16:07:37
done
|
| + if (expanded) { |
| + arrow = gfx::ImageSkiaOperations::CreateRotatedImage( |
| + arrow, base::i18n::IsRTL() ? SkBitmapOperations::ROTATION_270_CW |
| + : SkBitmapOperations::ROTATION_90_CW); |
| } |
| + gfx::Rect arrow_bounds = node_bounds; |
| + arrow_bounds.Inset(gfx::Insets((node_bounds.height() - arrow.height()) / 2, |
| + (kArrowRegionSize - arrow.width()) / 2)); |
| + canvas->DrawImageInt(arrow, base::i18n::IsRTL() |
| + ? arrow_bounds.right() - arrow.width() |
| + : arrow_bounds.x(), |
| + arrow_bounds.y()); |
|
Peter Kasting
2017/02/15 01:05:31
Nit: I think this is equivalent, and seems shorter
Evan Stade
2017/02/15 01:28:58
the arrow square isn't centered in the node bounds
Peter Kasting
2017/02/15 02:05:28
I know. The code I wrote won't center it in the n
|
| } |
| TreeView::InternalNode* TreeView::GetInternalNodeForModelNode( |