// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: // global proc fillEmptyPanes() { // // Description: // This proc will fill any empty panes in the main window // paneLayout. It will first look for any unparented panels // and if there are none it will create new model panels. // global string $gMainPane; // // Check if we need to parent or create new panels // int $i; int $nVis = `paneLayout -q -nvp $gMainPane`; int $nChild = `paneLayout -q -nch $gMainPane`; int $nEmpty = 0; int $whichStub; int $isChildVis; int $nFixed; string $panel, $type, $child; string $panels[]; string $childs[]; string $stubs[4]; int $emptyPanes[4]; if ($nChild < $nVis) { // // put stubs in place of panels first // so that panels will be added unmanaged. This avoids // squished menubars and the like. // if ($nEmpty < $nVis && `paneLayout -q -p1 $gMainPane` == "") { $emptyPanes[$nEmpty++] = 1; } if ($nVis > 1 && $nEmpty < $nVis && `paneLayout -q -p2 $gMainPane` == "") { $emptyPanes[$nEmpty++] = 2; } if ($nVis > 2 && $nEmpty < $nVis && `paneLayout -q -p3 $gMainPane` == "") { $emptyPanes[$nEmpty++] = 3; } if ($nVis > 3 && $nEmpty < $nVis && `paneLayout -q -p4 $gMainPane` == "") { $emptyPanes[$nEmpty++] = 4; } for ($i = 0; $i < $nEmpty; $i++) { $stubs[$i] = `text -parent $gMainPane -l ""`; } $panels = `getPanel -all`; // // Parent as many unparented panels as required. // $whichStub = 0; for ($panel in $panels) { if ("" == `panel -q -control $panel`) { $type = `getPanel -to $panel`; if ("" != $type) { eval ($type +"-e -parent $gMainPane " + $panel); paneLayout -e -sp `panel -q -control $panel` $emptyPanes[$whichStub] $gMainPane; deleteUI -control $stubs[$whichStub++]; $nChild++; if ($nChild == $nVis) break; } } } // // If still required make new model panels. // int $useMenuBars = `optionVar -q allowMenusInPanels`; for ($i = $nChild; $i < $nVis; $i++) { $panel = `modelPanel -parent $gMainPane -mbv $useMenuBars`; modelPanel -e -label `interToUI $panel` $panel; paneLayout -e -sp `panel -q -control $panel` $emptyPanes[$whichStub] $gMainPane; deleteUI -control $stubs[$whichStub++]; } } else { // // Have enough children, just make sure that they are visible. // // if ($nEmpty < $nVis && `paneLayout -q -p1 $gMainPane` == "") { $emptyPanes[$nEmpty++] = 1; } if ($nEmpty < $nVis && `paneLayout -q -p2 $gMainPane` == "") { $emptyPanes[$nEmpty++] = 2; } if ($nEmpty < $nVis && `paneLayout -q -p3 $gMainPane` == "") { $emptyPanes[$nEmpty++] = 3; } if ($nEmpty < $nVis && `paneLayout -q -p4 $gMainPane` == "") { $emptyPanes[$nEmpty++] = 4; } $nFixed = 0; $childs = `paneLayout -q -ca $gMainPane`; for ($i = 0; $i < $nEmpty; $i++) { for ($j = 0; $j < $nChild; $j++) { $child = $childs[$j]; $isChildVis = false; if ($child == `paneLayout -q -p1 $gMainPane`) { $isChildVis = true; continue; } if ($nVis > 1 && $child == `paneLayout -q -p2 $gMainPane`) { $isChildVis = true; continue; } if ($nVis > 2 && $child == `paneLayout -q -p3 $gMainPane`) { $isChildVis = true; continue; } if ($nVis > 3 && $child == `paneLayout -q -p4 $gMainPane`) { $isChildVis = true; continue; } if (!$isChildVis) { paneLayout -e -sp $child $emptyPanes[$i] $gMainPane; $nFixed++; } } if ($nFixed == $nEmpty) break; } } }