在 NBTTreeView 上启用平滑滚动 (#5364)
This commit is contained in:
@@ -20,13 +20,14 @@ package org.jackhuang.hmcl.ui.nbt;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import com.jfoenix.controls.JFXTreeView;
|
|
||||||
import javafx.scene.control.TreeCell;
|
import javafx.scene.control.TreeCell;
|
||||||
import javafx.scene.control.TreeItem;
|
import javafx.scene.control.TreeItem;
|
||||||
import javafx.scene.control.TreeView;
|
import javafx.scene.control.TreeView;
|
||||||
|
import javafx.scene.control.skin.TreeViewSkin;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
@@ -36,13 +37,22 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
|||||||
/**
|
/**
|
||||||
* @author Glavo
|
* @author Glavo
|
||||||
*/
|
*/
|
||||||
public final class NBTTreeView extends JFXTreeView<Tag> {
|
public final class NBTTreeView extends TreeView<Tag> {
|
||||||
|
|
||||||
public NBTTreeView(NBTTreeView.Item tree) {
|
public NBTTreeView(NBTTreeView.Item tree) {
|
||||||
this.setRoot(tree);
|
this.setRoot(tree);
|
||||||
this.setCellFactory(cellFactory());
|
this.setCellFactory(cellFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected javafx.scene.control.Skin<?> createDefaultSkin() {
|
||||||
|
return new TreeViewSkin<Tag>(this) {
|
||||||
|
{
|
||||||
|
FXUtils.smoothScrolling(getVirtualFlow());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private static Callback<TreeView<Tag>, TreeCell<Tag>> cellFactory() {
|
private static Callback<TreeView<Tag>, TreeCell<Tag>> cellFactory() {
|
||||||
EnumMap<NBTTagType, Image> icons = new EnumMap<>(NBTTagType.class);
|
EnumMap<NBTTagType, Image> icons = new EnumMap<>(NBTTagType.class);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user