Hide expand and collapse buttons when there is no hierarchy in the model.
This commit is contained in:
parent
55c29b0d4b
commit
e4fbd29c16
@ -335,7 +335,7 @@ OV.NavigatorMeshesPanel = class extends OV.NavigatorPanel
|
|||||||
this.nodeIdToItem = new Map ();
|
this.nodeIdToItem = new Map ();
|
||||||
this.meshInstanceIdToItem = new Map ();
|
this.meshInstanceIdToItem = new Map ();
|
||||||
this.rootItem = null;
|
this.rootItem = null;
|
||||||
this.isHierarchical = false;
|
this.showTree = false;
|
||||||
this.buttins = null;
|
this.buttins = null;
|
||||||
|
|
||||||
this.treeView.AddClass ('tight');
|
this.treeView.AddClass ('tight');
|
||||||
@ -421,15 +421,24 @@ OV.NavigatorMeshesPanel = class extends OV.NavigatorPanel
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpdateButtonsStatus (buttons, isHierarchical)
|
function UpdateButtonsStatus (buttons, showTree, isHierarchical)
|
||||||
{
|
{
|
||||||
if (isHierarchical) {
|
if (showTree) {
|
||||||
buttons.flatList.iconDiv.removeClass ('selected');
|
buttons.flatList.iconDiv.removeClass ('selected');
|
||||||
buttons.treeView.iconDiv.addClass ('selected');
|
buttons.treeView.iconDiv.addClass ('selected');
|
||||||
} else {
|
} else {
|
||||||
buttons.flatList.iconDiv.addClass ('selected');
|
buttons.flatList.iconDiv.addClass ('selected');
|
||||||
buttons.treeView.iconDiv.removeClass ('selected');
|
buttons.treeView.iconDiv.removeClass ('selected');
|
||||||
}
|
}
|
||||||
|
if (showTree && isHierarchical) {
|
||||||
|
buttons.separator.show ();
|
||||||
|
buttons.expandAll.div.show ();
|
||||||
|
buttons.collapseAll.div.show ();
|
||||||
|
} else {
|
||||||
|
buttons.separator.hide ();
|
||||||
|
buttons.expandAll.div.hide ();
|
||||||
|
buttons.collapseAll.div.hide ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.buttons = {
|
this.buttons = {
|
||||||
@ -445,6 +454,7 @@ OV.NavigatorMeshesPanel = class extends OV.NavigatorPanel
|
|||||||
div : null,
|
div : null,
|
||||||
iconDiv : null
|
iconDiv : null
|
||||||
},
|
},
|
||||||
|
separator : null,
|
||||||
expandAll : {
|
expandAll : {
|
||||||
name : 'Expand all',
|
name : 'Expand all',
|
||||||
icon : 'expand',
|
icon : 'expand',
|
||||||
@ -471,29 +481,32 @@ OV.NavigatorMeshesPanel = class extends OV.NavigatorPanel
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const rootNode = importResult.model.GetRootNode ();
|
||||||
|
let isHierarchical = rootNode.ChildNodeCount () > 0;
|
||||||
|
|
||||||
CreateButton (this.buttonsDiv, this.buttons.flatList, null, () => {
|
CreateButton (this.buttonsDiv, this.buttons.flatList, null, () => {
|
||||||
if (!this.isHierarchical) {
|
if (!this.showTree) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.isHierarchical = false;
|
this.showTree = false;
|
||||||
this.ClearMeshTree ();
|
this.ClearMeshTree ();
|
||||||
this.FillMeshTree (importResult.model);
|
this.FillMeshTree (importResult.model);
|
||||||
UpdateButtonsStatus (this.buttons, this.isHierarchical);
|
UpdateButtonsStatus (this.buttons, this.showTree, isHierarchical);
|
||||||
this.callbacks.onSelectionRemoved ();
|
this.callbacks.onSelectionRemoved ();
|
||||||
});
|
});
|
||||||
|
|
||||||
CreateButton (this.buttonsDiv, this.buttons.treeView, null, () => {
|
CreateButton (this.buttonsDiv, this.buttons.treeView, null, () => {
|
||||||
if (this.isHierarchical) {
|
if (this.showTree) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.isHierarchical = true;
|
this.showTree = true;
|
||||||
this.ClearMeshTree ();
|
this.ClearMeshTree ();
|
||||||
this.FillMeshTree (importResult.model);
|
this.FillMeshTree (importResult.model);
|
||||||
UpdateButtonsStatus (this.buttons, this.isHierarchical);
|
UpdateButtonsStatus (this.buttons, this.showTree, isHierarchical);
|
||||||
this.callbacks.onSelectionRemoved ();
|
this.callbacks.onSelectionRemoved ();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('<div>').addClass ('ov_navigator_buttons_separator').appendTo (this.buttonsDiv);
|
this.buttons.separator = $('<div>').addClass ('ov_navigator_buttons_separator').appendTo (this.buttonsDiv);
|
||||||
|
|
||||||
CreateButton (this.buttonsDiv, this.buttons.expandAll, null, () => {
|
CreateButton (this.buttonsDiv, this.buttons.expandAll, null, () => {
|
||||||
this.rootItem.ExpandAll (true);
|
this.rootItem.ExpandAll (true);
|
||||||
@ -513,17 +526,17 @@ OV.NavigatorMeshesPanel = class extends OV.NavigatorPanel
|
|||||||
this.callbacks.onNodeFitToWindow (nodeId);
|
this.callbacks.onNodeFitToWindow (nodeId);
|
||||||
});
|
});
|
||||||
|
|
||||||
UpdateButtonsStatus (this.buttons, this.isHierarchical);
|
UpdateButtonsStatus (this.buttons, this.showTree, isHierarchical);
|
||||||
}
|
}
|
||||||
|
|
||||||
FillMeshTree (model)
|
FillMeshTree (model)
|
||||||
{
|
{
|
||||||
function AddMeshToNodeTree (panel, model, node, meshIndex, parentItem, isHierarchical)
|
function AddMeshToNodeTree (panel, model, node, meshIndex, parentItem, showTree)
|
||||||
{
|
{
|
||||||
let mesh = model.GetMesh (meshIndex);
|
let mesh = model.GetMesh (meshIndex);
|
||||||
let meshName = OV.GetMeshName (mesh.GetName ());
|
let meshName = OV.GetMeshName (mesh.GetName ());
|
||||||
let meshInstanceId = new OV.MeshInstanceId (node.GetId (), meshIndex);
|
let meshInstanceId = new OV.MeshInstanceId (node.GetId (), meshIndex);
|
||||||
let meshItemIcon = isHierarchical ? 'tree_mesh' : null;
|
let meshItemIcon = showTree ? 'tree_mesh' : null;
|
||||||
let meshItem = new OV.MeshItem (meshName, meshItemIcon, meshInstanceId, {
|
let meshItem = new OV.MeshItem (meshName, meshItemIcon, meshInstanceId, {
|
||||||
onShowHide : (selectedMeshId) => {
|
onShowHide : (selectedMeshId) => {
|
||||||
panel.callbacks.onMeshShowHide (selectedMeshId);
|
panel.callbacks.onMeshShowHide (selectedMeshId);
|
||||||
@ -574,26 +587,26 @@ OV.NavigatorMeshesPanel = class extends OV.NavigatorPanel
|
|||||||
return rootItem;
|
return rootItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddModelNodeToTree (panel, model, node, parentItem, isHierarchical)
|
function AddModelNodeToTree (panel, model, node, parentItem, showTree)
|
||||||
{
|
{
|
||||||
for (let childNode of node.GetChildNodes ()) {
|
for (let childNode of node.GetChildNodes ()) {
|
||||||
if (isHierarchical) {
|
if (showTree) {
|
||||||
let nodeItem = CreateNodeItem (panel, node.GetName (), childNode);
|
let nodeItem = CreateNodeItem (panel, node.GetName (), childNode);
|
||||||
parentItem.AddChild (nodeItem);
|
parentItem.AddChild (nodeItem);
|
||||||
AddModelNodeToTree (panel, model, childNode, nodeItem, isHierarchical);
|
AddModelNodeToTree (panel, model, childNode, nodeItem, showTree);
|
||||||
} else {
|
} else {
|
||||||
AddModelNodeToTree (panel, model, childNode, parentItem, isHierarchical);
|
AddModelNodeToTree (panel, model, childNode, parentItem, showTree);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let meshIndex of node.GetMeshIndices ()) {
|
for (let meshIndex of node.GetMeshIndices ()) {
|
||||||
AddMeshToNodeTree (panel, model, node, meshIndex, parentItem, isHierarchical);
|
AddMeshToNodeTree (panel, model, node, meshIndex, parentItem, showTree);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let rootNode = model.GetRootNode ();
|
let rootNode = model.GetRootNode ();
|
||||||
this.rootItem = CreateDummyRootItem (this, rootNode);
|
this.rootItem = CreateDummyRootItem (this, rootNode);
|
||||||
AddModelNodeToTree (this, model, rootNode, this.rootItem, this.isHierarchical);
|
AddModelNodeToTree (this, model, rootNode, this.rootItem, this.showTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateMaterialList (materialInfoArray)
|
UpdateMaterialList (materialInfoArray)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user