Implement show/hide for nodes.
This commit is contained in:
parent
6177c3c169
commit
f12285be84
@ -239,7 +239,7 @@ OV.Navigator = class
|
||||
const nodeId = childNode.GetId ();
|
||||
let nodeItem = new OV.NodeItem (nodeName, nodeId, {
|
||||
onShowHide : (selectedNodeId) => {
|
||||
console.log ('sh');
|
||||
navigator.ToggleNodeVisibility (selectedNodeId);
|
||||
},
|
||||
onFitToWindow : (selectedNodeId) => {
|
||||
navigator.FitNodeToWindow (selectedNodeId);
|
||||
@ -300,6 +300,13 @@ OV.Navigator = class
|
||||
this.callbacks.updateMeshesVisibility ();
|
||||
}
|
||||
|
||||
ToggleNodeVisibility (nodeId)
|
||||
{
|
||||
let nodeItem = this.navigatorItems.GetNodeItem (nodeId);
|
||||
nodeItem.SetVisible (!nodeItem.IsVisible ());
|
||||
this.callbacks.updateMeshesVisibility ();
|
||||
}
|
||||
|
||||
ToggleMeshVisibility (meshInstanceId)
|
||||
{
|
||||
let meshItem = this.navigatorItems.GetMeshItem (meshInstanceId);
|
||||
|
||||
@ -25,7 +25,7 @@ OV.MeshItem = class extends OV.TreeViewButtonItem
|
||||
this.AddButton (this.fitToWindowButton);
|
||||
|
||||
this.showHideButton = new OV.TreeViewButton ('visible');
|
||||
this.showHideButton.OnClick ((ev) => {
|
||||
this.showHideButton.OnClick (() => {
|
||||
callbacks.onShowHide (this.meshInstanceId);
|
||||
});
|
||||
this.AddButton (this.showHideButton);
|
||||
@ -53,6 +53,9 @@ OV.MeshItem = class extends OV.TreeViewButtonItem
|
||||
} else {
|
||||
this.showHideButton.SetImage ('hidden');
|
||||
}
|
||||
if (this.parent instanceof OV.NodeItem) {
|
||||
this.parent.UpdateVisibleStatus ();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -75,6 +78,27 @@ OV.NodeItem = class extends OV.TreeViewGroupButtonItem
|
||||
this.AddButton (this.showHideButton);
|
||||
}
|
||||
|
||||
IsVisible ()
|
||||
{
|
||||
let isVisible = false;
|
||||
this.EnumerateMeshItems ((meshItem) => {
|
||||
if (meshItem.IsVisible ()) {
|
||||
isVisible = true;
|
||||
}
|
||||
});
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
SetVisible (visible)
|
||||
{
|
||||
this.UpdateVisibleIcon (visible);
|
||||
for (let child of this.children) {
|
||||
if (child instanceof OV.NodeItem || child instanceof OV.MeshItem) {
|
||||
child.SetVisible (visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnumerateMeshItems (processor)
|
||||
{
|
||||
for (let child of this.children) {
|
||||
@ -85,6 +109,24 @@ OV.NodeItem = class extends OV.TreeViewGroupButtonItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdateVisibleStatus ()
|
||||
{
|
||||
let visible = this.IsVisible ();
|
||||
this.UpdateVisibleIcon (visible);
|
||||
if (this.parent instanceof OV.NodeItem) {
|
||||
this.parent.UpdateVisibleStatus ();
|
||||
}
|
||||
}
|
||||
|
||||
UpdateVisibleIcon (visible)
|
||||
{
|
||||
if (visible) {
|
||||
this.showHideButton.SetImage ('visible');
|
||||
} else {
|
||||
this.showHideButton.SetImage ('hidden');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OV.NavigatorItems = class
|
||||
|
||||
Loading…
Reference in New Issue
Block a user