Add resize callback to panel set.

This commit is contained in:
kovacsv 2021-11-06 08:46:22 +01:00
parent 316c722390
commit dede2eaae7
2 changed files with 43 additions and 1 deletions

View File

@ -57,16 +57,24 @@ OV.Navigator = class
{
this.callbacks = callbacks;
this.panelSet.Init ({
onResize : () => {
this.callbacks.onResize ();
}
});
this.filesPanel.Init ({
onFileBrowseButtonClicked : () => {
this.callbacks.openFileBrowserDialog ();
}
});
this.materialsPanel.Init ({
onMaterialSelected : (materialIndex) => {
this.SetSelection (new OV.Selection (OV.SelectionType.Material, materialIndex));
}
});
this.meshesPanel.Init ({
onMeshSelected : (meshId) => {
this.SetSelection (new OV.Selection (OV.SelectionType.Mesh, meshId));

View File

@ -24,6 +24,10 @@ OV.Panel = class
Show (show)
{
if (this.visible === show) {
return;
}
this.visible = show;
if (this.visible) {
this.panelDiv.show ();
@ -51,6 +55,13 @@ OV.PanelSet = class
this.menuDiv = $('<div>').addClass ('ov_panel_set_menu').appendTo (parentDiv);
this.contentDiv = $('<div>').addClass ('ov_panel_set_content').appendTo (parentDiv);
this.panels = [];
this.panelsVisible = true;
this.callbacks = null;
}
Init (callbacks)
{
this.callbacks = callbacks;
}
GetContentDiv ()
@ -63,10 +74,30 @@ OV.PanelSet = class
this.panels.push (panel);
let button = OV.AddSvgIcon (this.menuDiv, panel.GetIcon (), 'ov_panel_set_menu_button');
button.click (() => {
this.ShowPanel (panel);
if (panel === this.GetVisiblePanel ()) {
//this.ShowPanels (false);
} else {
//this.ShowPanels (true);
this.ShowPanel (panel);
}
});
}
ShowPanels (show)
{
if (this.panelsVisible === show) {
return;
}
this.panelsVisible = show;
if (this.panelsVisible) {
this.contentDiv.show ();
} else {
this.contentDiv.hide ();
this.callbacks.onResize ();
}
}
ShowPanel (panel)
{
if (panel === this.GetVisiblePanel ()) {
@ -81,6 +112,9 @@ OV.PanelSet = class
GetVisiblePanel ()
{
if (!this.panelsVisible) {
return null;
}
for (let panel of this.panels) {
if (panel.IsVisible ()) {
return panel;