<commit_before>// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package mixins

import (
	"github.com/google/gxui"
	"github.com/google/gxui/math"
)

// Interface used to visualize tree nodes in as a list.
type TreeControlCreator interface {
	// Create returns a Control that contains control (returned by the backing
	// TreeNode) and visualizes the expanded state of node.
	Create(theme gxui.Theme, control gxui.Control, node *TreeToListNode) gxui.Control

	// Size returns the size that each of the controls returned by Create will
	// be displayed at for the given theme.
	// treeControlSize is the size returned the backing TreeNode.
	Size(theme gxui.Theme, treeControlSize math.Size) math.Size
}

// TreeToListAdapter converts a TreeAdapter to a ListAdapter so that the
// tree can be visualized with a List.
type TreeToListAdapter struct {
	TreeToListNode
	gxui.AdapterBase
	adapter gxui.TreeAdapter
	creator TreeControlCreator
}

// CreateTreeToListAdapter wraps the provided TreeAdapter with an adapter
// conforming to the ListAdapter interface.
func CreateTreeToListAdapter(treeAdapter gxui.TreeAdapter, creator TreeControlCreator) *TreeToListAdapter {
	listAdapter := &TreeToListAdapter{}
	listAdapter.adapter = treeAdapter
	listAdapter.container = treeAdapter
	listAdapter.creator = creator
	treeAdapter.OnDataReplaced(func() {
		listAdapter.reset()
		listAdapter.DataReplaced()
	})
	treeAdapter.OnDataChanged(func() {
		listAdapter.update()
		listAdapter.DataChanged()
	})
	listAdapter.reset()
	return listAdapter
}

func (a *TreeToListAdapter) adjustDescendants(delta int) {<commit_msg>Fix tree nodes being indented 1 more than they should<commit_after>// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package mixins

import (
	"github.com/google/gxui"
	"github.com/google/gxui/math"
)

// Interface used to visualize tree nodes in as a list.
type TreeControlCreator interface {
	// Create returns a Control that contains control (returned by the backing
	// TreeNode) and visualizes the expanded state of node.
	Create(theme gxui.Theme, control gxui.Control, node *TreeToListNode) gxui.Control

	// Size returns the size that each of the controls returned by Create will
	// be displayed at for the given theme.
	// treeControlSize is the size returned the backing TreeNode.
	Size(theme gxui.Theme, treeControlSize math.Size) math.Size
}

// TreeToListAdapter converts a TreeAdapter to a ListAdapter so that the
// tree can be visualized with a List.
type TreeToListAdapter struct {
	TreeToListNode
	gxui.AdapterBase
	adapter gxui.TreeAdapter
	creator TreeControlCreator
}

// CreateTreeToListAdapter wraps the provided TreeAdapter with an adapter
// conforming to the ListAdapter interface.
func CreateTreeToListAdapter(treeAdapter gxui.TreeAdapter, creator TreeControlCreator) *TreeToListAdapter {
	listAdapter := &TreeToListAdapter{}
	listAdapter.depth = -1 // The adapter is not a node, just a container.
	listAdapter.adapter = treeAdapter
	listAdapter.container = treeAdapter
	listAdapter.creator = creator
	treeAdapter.OnDataReplaced(func() {
		listAdapter.reset()
		listAdapter.DataReplaced()
	})
	treeAdapter.OnDataChanged(func() {
		listAdapter.update()
		listAdapter.DataChanged()
	})
	listAdapter.reset()
	return listAdapter
}

func (a *TreeToListAdapter) adjustDescendants(delta int) {
{'fraction_non_alphanumeric': 0.07385398981324279, 'fraction_numerical': 0.0028296547821165816, 'mean_word_length': 4.620031796502385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6790553', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1009, 'n_words': 364}