chromium/ui/views/controls/tree/tree_view.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/views/controls/tree/tree_view.h"

#include <algorithm>
#include <utility>

#include "base/containers/adapters.h"
#include "base/i18n/rtl.h"
#include "base/memory/ptr_util.h"
#include "build/build_config.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/models/image_model.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/skia_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/scoped_canvas.h"
#include "ui/native_theme/native_theme.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/views/accessibility/ax_virtual_view.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/border.h"
#include "ui/views/controls/focus_ring.h"
#include "ui/views/controls/prefix_selector.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/controls/tree/tree_view_controller.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/widget/widget.h"

TreeModel;
TreeModelNode;

namespace views {

// Insets around the view.
static constexpr int kHorizontalInset =;
// Padding before/after the image.
static constexpr int kImagePadding =;
// Size of the arrow region.
static constexpr int kArrowRegionSize =;
// Padding around the text (on each side).
static constexpr int kTextVerticalPadding =;
static constexpr int kTextHorizontalPadding =;
// Padding between the auxiliary text and the end of the line, handles RTL.
static constexpr int kAuxiliaryTextLineEndPadding =;
// How much children are indented from their parent.
static constexpr int kIndent =;

namespace {

void PaintRowIcon(gfx::Canvas* canvas,
                  const gfx::ImageSkia& icon,
                  int x,
                  const gfx::Rect& rect) {}

bool EventIsDoubleTapOrClick(const ui::LocatedEvent& event) {}

int GetSpaceThicknessForFocusRing() {}

}  // namespace

TreeView::TreeView()
    :{}

TreeView::~TreeView() {}

// static
std::unique_ptr<ScrollView> TreeView::CreateScrollViewWithTree(
    std::unique_ptr<TreeView> tree) {}

void TreeView::SetModel(TreeModel* model) {}

void TreeView::SetEditable(bool editable) {}

void TreeView::StartEditing(TreeModelNode* node) {}

void TreeView::CancelEdit() {}

void TreeView::CommitEdit() {}

TreeModelNode* TreeView::GetEditingNode() {}

void TreeView::SetSelectedNode(TreeModelNode* model_node) {}

const TreeModelNode* TreeView::GetSelectedNode() const {}

void TreeView::SetActiveNode(TreeModelNode* model_node) {}

const TreeModelNode* TreeView::GetActiveNode() const {}

void TreeView::Collapse(ui::TreeModelNode* model_node) {}

void TreeView::Expand(TreeModelNode* node) {}

void TreeView::ExpandAll(TreeModelNode* node) {}

bool TreeView::IsExpanded(TreeModelNode* model_node) {}

void TreeView::SetRootShown(bool root_shown) {}

ui::TreeModelNode* TreeView::GetNodeForRow(int row) {}

int TreeView::GetRowForNode(ui::TreeModelNode* node) {}

void TreeView::SetDrawingProvider(
    std::unique_ptr<TreeViewDrawingProvider> provider) {}

void TreeView::Layout(PassKey) {}

gfx::Size TreeView::CalculatePreferredSize(
    const SizeBounds& /*available_size*/) const {}

bool TreeView::AcceleratorPressed(const ui::Accelerator& accelerator) {}

bool TreeView::OnMousePressed(const ui::MouseEvent& event) {}

void TreeView::OnGestureEvent(ui::GestureEvent* event) {}

void TreeView::ShowContextMenu(const gfx::Point& p,
                               ui::MenuSourceType source_type) {}

void TreeView::GetAccessibleNodeData(ui::AXNodeData* node_data) {}

bool TreeView::HandleAccessibleAction(const ui::AXActionData& action_data) {}

void TreeView::TreeNodeAdded(TreeModel* model,
                             TreeModelNode* parent,
                             size_t index) {}

void TreeView::TreeNodeRemoved(TreeModel* model,
                               TreeModelNode* parent,
                               size_t index) {}

void TreeView::TreeNodeChanged(TreeModel* model, TreeModelNode* model_node) {}

void TreeView::ContentsChanged(Textfield* sender,
                               const std::u16string& new_contents) {}

bool TreeView::HandleKeyEvent(Textfield* sender,
                              const ui::KeyEvent& key_event) {}

void TreeView::OnWillChangeFocus(View* focused_before, View* focused_now) {}

void TreeView::OnDidChangeFocus(View* focused_before, View* focused_now) {}

size_t TreeView::GetRowCount() {}

std::optional<size_t> TreeView::GetSelectedRow() {}

void TreeView::SetSelectedRow(std::optional<size_t> row) {}

std::u16string TreeView::GetTextForRow(size_t row) {}

gfx::Point TreeView::GetKeyboardContextMenuLocation() {}

bool TreeView::OnKeyPressed(const ui::KeyEvent& event) {}

void TreeView::OnPaint(gfx::Canvas* canvas) {}

void TreeView::OnFocus() {}

void TreeView::OnBlur() {}

void TreeView::UpdateSelection(TreeModelNode* model_node,
                               SelectionType selection_type) {}

bool TreeView::OnClickOrTap(const ui::LocatedEvent& event) {}

void TreeView::LoadChildren(InternalNode* node) {}

void TreeView::UpdateAccessiblePositionalProperties(InternalNode* node) {}

void TreeView::UpdateAccessiblePositionalPropertiesForNodeAndChildren(
    InternalNode* node) {}

void TreeView::ConfigureInternalNode(TreeModelNode* model_node,
                                     InternalNode* node) {}

bool TreeView::IsRoot(const InternalNode* node) const {}

void TreeView::UpdateNodeTextWidth(InternalNode* node) {}

std::unique_ptr<AXVirtualView> TreeView::CreateAndSetAccessibilityView(
    InternalNode* node) {}

void TreeView::SetAccessibleSelectionForNode(InternalNode* node,
                                             bool selected) {}

void TreeView::DrawnNodesChanged() {}

void TreeView::UpdatePreferredSize() {}

void TreeView::LayoutEditor() {}

void TreeView::SchedulePaintForNode(InternalNode* node) {}

void TreeView::PaintRows(gfx::Canvas* canvas,
                         int min_row,
                         int max_row,
                         InternalNode* node,
                         int depth,
                         int* row) {}

void TreeView::PaintRow(gfx::Canvas* canvas,
                        InternalNode* node,
                        int row,
                        int depth) {}

void TreeView::PaintExpandControl(gfx::Canvas* canvas,
                                  const gfx::Rect& node_bounds,
                                  bool expanded) {}

void TreeView::PaintNodeIcon(gfx::Canvas* canvas,
                             InternalNode* node,
                             const gfx::Rect& bounds) {}

TreeView::InternalNode* TreeView::GetInternalNodeForModelNode(
    ui::TreeModelNode* model_node,
    CreateType create_type) {}

TreeView::InternalNode* TreeView::GetInternalNodeForVirtualView(
    AXVirtualView* ax_view) {}

gfx::Rect TreeView::GetBoundsForNode(InternalNode* node) {}

gfx::Rect TreeView::GetBackgroundBoundsForNode(InternalNode* node) {}

gfx::Rect TreeView::GetForegroundBoundsForNode(InternalNode* node) {}

gfx::Rect TreeView::GetTextBoundsForNode(InternalNode* node) {}

// The auxiliary text for a node can use all the parts of the row's bounds that
// are logical-after the row's text, and is aligned opposite to the row's text -
// that is, in LTR locales it is trailing aligned, and in RTL locales it is
// leading aligned.
gfx::Rect TreeView::GetAuxiliaryTextBoundsForNode(InternalNode* node) {}

gfx::Rect TreeView::GetForegroundBoundsForNodeImpl(InternalNode* node,
                                                   int row,
                                                   int depth) {}

int TreeView::GetRowForInternalNode(InternalNode* node, int* depth) {}

TreeView::InternalNode* TreeView::GetNodeAtPoint(const gfx::Point& point) {}

TreeView::InternalNode* TreeView::GetNodeByRow(int row, int* depth) {}

TreeView::InternalNode* TreeView::GetNodeByRowImpl(InternalNode* node,
                                                   int target_row,
                                                   int current_depth,
                                                   int* current_row,
                                                   int* node_depth) {}

void TreeView::IncrementSelection(IncrementType type) {}

void TreeView::CollapseOrSelectParent() {}

void TreeView::ExpandOrSelectChild() {}

bool TreeView::ExpandImpl(TreeModelNode* model_node) {}

PrefixSelector* TreeView::GetPrefixSelector() {}

bool TreeView::IsPointInExpandControl(InternalNode* node,
                                      const gfx::Point& point) {}

void TreeView::SetHasFocusIndicator(bool shows) {}

// InternalNode ----------------------------------------------------------------

TreeView::InternalNode::InternalNode() {}

TreeView::InternalNode::~InternalNode() = default;

void TreeView::InternalNode::Reset(ui::TreeModelNode* node) {}

void TreeView::InternalNode::set_is_expanded(bool expanded) {}

void TreeView::InternalNode::SetAccessibleIsExpanded(bool expanded) {}

size_t TreeView::InternalNode::NumExpandedNodes() const {}

void TreeView::InternalNode::UpdateAccessibleName() {}

int TreeView::InternalNode::GetMaxWidth(TreeView* tree, int indent, int depth) {}

BEGIN_METADATA()

}  // namespace views