| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/views/controls/tree/tree_view_views.h" | 5 #include "ui/views/controls/tree/tree_view_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 auto_expand_children_(false), | 53 auto_expand_children_(false), |
| 54 editable_(true), | 54 editable_(true), |
| 55 controller_(NULL), | 55 controller_(NULL), |
| 56 root_shown_(true), | 56 root_shown_(true), |
| 57 has_custom_icons_(false), | 57 has_custom_icons_(false), |
| 58 row_height_(font_.GetHeight() + kTextVerticalPadding * 2) { | 58 row_height_(font_.GetHeight() + kTextVerticalPadding * 2) { |
| 59 set_focusable(true); | 59 set_focusable(true); |
| 60 set_background(Background::CreateSolidBackground(SK_ColorWHITE)); | 60 set_background(Background::CreateSolidBackground(SK_ColorWHITE)); |
| 61 closed_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 61 closed_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 62 (base::i18n::IsRTL() ? IDR_FOLDER_CLOSED_RTL | 62 (base::i18n::IsRTL() ? IDR_FOLDER_CLOSED_RTL |
| 63 : IDR_FOLDER_CLOSED)).ToSkBitmap(); | 63 : IDR_FOLDER_CLOSED)).ToImageSkia(); |
| 64 open_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 64 open_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 65 (base::i18n::IsRTL() ? IDR_FOLDER_OPEN_RTL | 65 (base::i18n::IsRTL() ? IDR_FOLDER_OPEN_RTL |
| 66 : IDR_FOLDER_OPEN)).ToSkBitmap(); | 66 : IDR_FOLDER_OPEN)).ToImageSkia(); |
| 67 text_offset_ = closed_icon_.width() + kImagePadding + kImagePadding + | 67 text_offset_ = closed_icon_.width() + kImagePadding + kImagePadding + |
| 68 kArrowRegionSize; | 68 kArrowRegionSize; |
| 69 } | 69 } |
| 70 | 70 |
| 71 TreeView::~TreeView() { | 71 TreeView::~TreeView() { |
| 72 if (model_) | 72 if (model_) |
| 73 model_->RemoveObserver(this); | 73 model_->RemoveObserver(this); |
| 74 if (focus_manager_) { | 74 if (focus_manager_) { |
| 75 focus_manager_->RemoveFocusChangeListener(this); | 75 focus_manager_->RemoveFocusChangeListener(this); |
| 76 focus_manager_ = NULL; | 76 focus_manager_ = NULL; |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 void TreeView::PaintRow(gfx::Canvas* canvas, | 632 void TreeView::PaintRow(gfx::Canvas* canvas, |
| 633 InternalNode* node, | 633 InternalNode* node, |
| 634 int row, | 634 int row, |
| 635 int depth) { | 635 int depth) { |
| 636 gfx::Rect bounds(GetBoundsForNodeImpl(node, row, depth)); | 636 gfx::Rect bounds(GetBoundsForNodeImpl(node, row, depth)); |
| 637 | 637 |
| 638 if (model_->GetChildCount(node->model_node())) | 638 if (model_->GetChildCount(node->model_node())) |
| 639 PaintExpandControl(canvas, bounds, node->is_expanded()); | 639 PaintExpandControl(canvas, bounds, node->is_expanded()); |
| 640 | 640 |
| 641 // Paint the icon. | 641 // Paint the icon. |
| 642 SkBitmap icon; | 642 gfx::ImageSkia icon; |
| 643 int icon_index = model_->GetIconIndex(node->model_node()); | 643 int icon_index = model_->GetIconIndex(node->model_node()); |
| 644 if (icon_index != -1) | 644 if (icon_index != -1) |
| 645 icon = icons_[icon_index]; | 645 icon = icons_[icon_index]; |
| 646 else if (node == selected_node_) | 646 else if (node == selected_node_) |
| 647 icon = open_icon_; | 647 icon = open_icon_; |
| 648 else | 648 else |
| 649 icon = closed_icon_; | 649 icon = closed_icon_; |
| 650 int icon_x = kArrowRegionSize + kImagePadding + | 650 int icon_x = kArrowRegionSize + kImagePadding + |
| 651 (open_icon_.width() - icon.width()) / 2; | 651 (open_icon_.width() - icon.width()) / 2; |
| 652 if (base::i18n::IsRTL()) | 652 if (base::i18n::IsRTL()) |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 if (!is_expanded_) | 901 if (!is_expanded_) |
| 902 return max_width; | 902 return max_width; |
| 903 for (int i = 0; i < child_count(); ++i) { | 903 for (int i = 0; i < child_count(); ++i) { |
| 904 max_width = std::max(max_width, | 904 max_width = std::max(max_width, |
| 905 GetChild(i)->GetMaxWidth(indent, depth + 1)); | 905 GetChild(i)->GetMaxWidth(indent, depth + 1)); |
| 906 } | 906 } |
| 907 return max_width; | 907 return max_width; |
| 908 } | 908 } |
| 909 | 909 |
| 910 } // namespace views | 910 } // namespace views |
| OLD | NEW |