// =========================================================================== // 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: June 26, 1996 // // Description: // This script a panel which has both an outliner and a graph editor // within it. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars () { // autoFit if (!`optionVar -exists dopeSheetAutoFit`) { optionVar -intValue dopeSheetAutoFit 0; } // bug#219843 - setting to tick on for default if (!`optionVar -exists dopeSheetShowTicks`) { optionVar -intValue dopeSheetShowTicks 1; } } global proc buildDopeSheetEdViewMenu (string $dopeSheetEd, string $parentMenu) // // Procedure Name: // buildDopeSheetEdViewMenu // // Description: // This creates submenu items for view // functionality in the Dope Sheet. // // Input Arguments: // None. // // Return Value: // None. // { setParent -menu $parentMenu; // Check to see if we have to build the menu items // if (`menu -query -numberOfItems $parentMenu` == 0) { menuItem -label (uiRes("m_dopeSheetPanel.kFrameAll")) -annotation (uiRes("m_dopeSheetPanel.kFrameAllAnnot")) -command ("FrameAll"); menuItem -label (uiRes("m_dopeSheetPanel.kFrameSelection")) -annotation (uiRes("m_dopeSheetPanel.kFrameSelectionAnnot")) -command ("FrameSelected"); menuItem -label (uiRes("m_dopeSheetPanel.kFramePlaybackRange")) -annotation (uiRes("m_dopeSheetPanel.kFramePlaybackRangeAnnot")) -command ( "animView " + "-startTime (`playbackOptions -query -minTime` - 1) " + "-endTime (`playbackOptions -query -maxTime` + 1) " + $dopeSheetEd ); menuItem -label (uiRes("m_dopeSheetPanel.kCenterCurrentTime")) -annotation (uiRes("m_dopeSheetPanel.kCenterCurrentTimeAnnot")) -command ("dopeSheetEditor -edit -lookAt currentTime " + $dopeSheetEd); menuItem -divider true; menuItem -label (uiRes("m_dopeSheetPanel.kAutoFrame")) -annotation (uiRes("m_dopeSheetPanel.kAutoFrameAnnot")) -checkBox 0 -command ( "dopeSheetEditor -edit -autoFit #1 " + $dopeSheetEd + ";" + "optionVar -intValue dopeSheetAutoFit #1;" ) displayAutoFitItem; menuItem -divider true; menuItem -label (uiRes("m_dopeSheetPanel.kDopesheetSummary")) -annotation (uiRes("m_dopeSheetPanel.kDopesheetSummaryAnnot")) -checkBox true -command ("dopeSheetEditor -edit -showSummary #1 " + $dopeSheetEd) showSummaryItem; menuItem -label (uiRes("m_dopeSheetPanel.kSceneSummary")) -annotation (uiRes("m_dopeSheetPanel.kSceneSummaryAnnot")) -checkBox false -command ("dopeSheetEditor -edit -showScene #1 " + $dopeSheetEd) showSceneItem; menuItem -label (uiRes("m_dopeSheetPanel.kShowTicks")) -annotation (uiRes("m_dopeSheetPanel.kShowTicksAnnot")) -checkBox true -command ("dopeSheetEditor -edit -showTicks #1 " + $dopeSheetEd + ";" + "optionVar -intValue dopeSheetShowTicks #1;") showTicksItem; } menuItem -edit -checkBox `dopeSheetEditor -query -autoFit $dopeSheetEd` displayAutoFitItem; menuItem -edit -checkBox `dopeSheetEditor -query -showSummary $dopeSheetEd` showSummaryItem; menuItem -edit -checkBox `dopeSheetEditor -query -showScene $dopeSheetEd` showSceneItem; menuItem -edit -checkBox `dopeSheetEditor -query -showTicks $dopeSheetEd` showTicksItem; } global proc doDopeMute(string $outlineEd, string $dopeSheetEd, string $flag) { // if we don't have a region selected. float $selection[] = `dopeSheetEditor -q -sel $dopeSheetEd`; if ( (size($selection) < 4 ) || ($selection[0] == $selection[1]) || $selection[2] == $selection[3]) { doMuteKey $flag; } else { string $selectionConnection = `editor -query -selectionConnection $outlineEd`; string $membersArray[] = expandSelectionConnectionAsArray($selectionConnection); for ($m in $membersArray) { doMuteRegion $m $flag $selection[0] $selection[1]; } } } global proc buildDopeSheetEdKeysMenu(string $outlineEd, string $dopeSheetEd, string $parentMenu ) { setParent -menu $parentMenu; if (`menu -query -numberOfItems $parentMenu` != 0) { return; } string $selectionConnection = `editor -query -selectionConnection $outlineEd`; menuItem -label (uiRes("m_dopeSheetPanel.kConvertToKey")) -annotation (uiRes("m_dopeSheetPanel.kConvertToKeyAnnot")) -command ("doKeyEdit \"-breakdown false\" " + $selectionConnection + " noOptions") makeKeysItem; menuItem -label (uiRes("m_dopeSheetPanel.kConvertToBreakdown")) -annotation (uiRes("m_dopeSheetPanel.kConvertToBreakdownAnnot")) -command ("doKeyEdit \"-breakdown true\" " + $selectionConnection + " noOptions") makeBreakdownsItem; menuItem -label (uiRes("m_dopeSheetPanel.kAddInbetween")) -annotation (uiRes("m_dopeSheetPanel.kAddInbetweenAnnot")) -command ("doKeyEdit \"\" " + $selectionConnection + " addInbetween") addInbetweenItem; menuItem -label (uiRes("m_dopeSheetPanel.kRemoveInbetween")) -annotation (uiRes("m_dopeSheetPanel.kRemoveInbetweenAnnot")) -command ("doKeyEdit \"\" " + $selectionConnection + " removeInbetween") removeInbetweenItem; menuItem -label (uiRes("m_dopeSheetPanel.kMuteKey")) -annotation (uiRes("m_dopeSheetPanel.kMuteKeyAnnot")) -command ("doDopeMute " + $outlineEd + " " + $dopeSheetEd + " -true") muteChannelItem; menuItem -label (uiRes("m_dopeSheetPanel.kUnmuteKey")) -annotation (uiRes("m_dopeSheetPanel.kUnmuteKeyAnnot")) -command ("doDopeMute " + $outlineEd + " " + $dopeSheetEd + " -false") unmuteChannelItem; } global proc setHierarchyBelow (int $below, string $dopeSheetEd) { dopeSheetEditor -edit -hierarchyBelow $below $dopeSheetEd; setParent `dopeSheetEditor -query -parent $dopeSheetEd`; if (`dopeSheetEditor -query -hierarchyBelow $dopeSheetEd`) { iconTextCheckBox -edit -i1 "hierOn.png" -value true hierButton; } else { iconTextCheckBox -edit -i1 "hierOff.png" -value false hierButton; } } global proc buildDopeSheetContextHelpItems(string $nameRoot, string $menuParent) // // Description: // Build context sensitive menu items // // Input Arguments: // $nameRoot - name to use as the root of all item names // $menuParent - the name of the parent of this menu // // Return Value: // None // { menuItem -label (uiRes("m_dopeSheetPanel.kHelpDope")) -annotation (uiRes("m_dopeSheetPanel.kHelpDopeAnnot")) -enableCommandRepeat false -command "showHelp DopeSheet"; } global proc createDopeSheetPanel (string $whichPanel) // // Description: // Define the editors that are used in this panel. No // controls (widgets) are created at this point. // { // create unique names for editors based on panel name // string $dopeSheetEd = ($whichPanel + "DopeSheetEd"); string $outlineEd = ($whichPanel + "OutlineEd"); string $outlineConn = ($whichPanel + "FromOutliner"); string $outlinerSelection = ($whichPanel + "OutlinerSelection"); loadAnimPanelLibrary; setOptionVars; selectionConnection $outlinerSelection; // WARNING: Changes here must also be made in buildNewSceneUI.mel // outlinerEditor -unParent -mainListConnection animationList -highlightConnection keyframeList -selectionConnection $outlinerSelection -showShapes true -showAttributes true -showConnected true -showAnimCurvesOnly true -showDagOnly false -autoExpand false -expandConnections true -showUnitlessCurves false -doNotSelectNewObjects true -showNumericAttrsOnly true -showSetMembers false -showContainedOnly false -showContainerContents false -showParentContainers true -showTimeEditor true -mapMotionTrails true $outlineEd; selectionConnection -editor $outlineEd -parent $outlineEd $outlineConn; selectionConnection -edit -parent $outlineEd $outlinerSelection; dopeSheetEditor -unParent -mainListConnection $outlineConn -highlightConnection $outlinerSelection -outliner $outlineEd -autoFit `optionVar -query dopeSheetAutoFit` -showTicks `optionVar -query dopeSheetShowTicks` $dopeSheetEd; registerEditor ($outlineEd, "animationList"); } global proc addDopeSheetPanel (string $whichPanel) // // Description: // Add the panel to a layout. // Parent the editors to that layout and create any other // controls (widgets) required. // { string $dopeSheetEd = ($whichPanel + "DopeSheetEd"); string $outlineEd = ($whichPanel + "OutlineEd"); string $outlineEdForm = ($whichPanel + "OutlineEdForm"); // Do not use the wait cursor, it causes a problem (crash) when used // in combination with the table widget (key frame stats). // // waitCursor -state on; // Make sure that there is no template active setUITemplate -pushTemplate NONE; // Define the standard animation editing panel // string $widgetList[] = `definePanelElements $whichPanel`; // // menuBarLayout is turned on for this editor - // create the top level menus // // Attach the menus to the menu form // setParent $widgetList[2]; string $menuItem = `menu -label (uiRes("m_dopeSheetPanel.kEditMenu")) -allowOptionBoxes true -tearOff true -postMenuCommandOnce true -familyImage "menuIconEdit.png"`; defineEditMenu $outlineEd $dopeSheetEd $menuItem "noOptions" ""; setParent -menu ..; string $viewMenu = `menu -label (uiRes("m_dopeSheetPanel.kViewMenu")) -tearOff true -familyImage "menuIconView.png"`; menu -edit -postMenuCommand ("buildDopeSheetEdViewMenu " + $dopeSheetEd + " " + $viewMenu) $viewMenu; setParent -menu ..; string $curvesMenu = `menu -label (uiRes("m_dopeSheetPanel.kCurvesMenu")) -allowOptionBoxes true -tearOff true -familyImage "menuIconAnimCurves.png"`; defineCurvesMenu $outlineEd $dopeSheetEd $curvesMenu "noOptions" ""; setParent -menu ..; string $keysMenu = `menu -label (uiRes("m_dopeSheetPanel.kKeysMenu")) -tearOff true -postMenuCommandOnce true -familyImage "menuIconKeys.png"`; menu -edit -postMenuCommand ("buildDopeSheetEdKeysMenu " + $outlineEd + " " + $dopeSheetEd + " " + $keysMenu) $keysMenu; setParent -menu ..; string $tangentsMenu = `menu -label (uiRes("m_dopeSheetPanel.kTangentsMenu")) -tearOff true -postMenuCommandOnce true -familyImage "menuIconTangents.png"`; defineTangentsMenu $outlineEd $dopeSheetEd $tangentsMenu "noOptions" ""; setParent -menu ..; $menuItem = `menu -label (uiRes("m_dopeSheetPanel.kListMenu")) -tearOff true -familyImage "menuIconOptions.png"`; defineListMenu "useHier" $outlineEd $dopeSheetEd $menuItem ""; setParent -menu ..; // Attach the filter menu to the menu bar. // filterUICreateMenu($outlineEd, `setParent -query`); // Add support for the Context Sensitive Help Menu. // addContextHelpProc $whichPanel "buildDopeSheetContextHelpItems"; // Attach tools to the tool form // setParent $widgetList[5]; // Here we need to make sure all the toolButton has a size of (24, 24), // it's calculated as icon size (20) + margin (2+2). This has to be // exact otherwise it will cause problem in Mac retina. See MAYA-49712. // Please do note that although we have variable named as "iconSize", but // it's actually meant for "buttonSize", button size = icon size + margin. int $iconSize = 24; toolButton -doubleClickCommand toolPropertyWindow -collection toolCluster -tool selectKeyframeSuperContext -style "iconOnly" -image1 "dopeSheetSelect.png" -width $iconSize -height $iconSize selectKeyTool; toolButton -doubleClickCommand toolPropertyWindow -collection toolCluster -tool directKeySuperContext -style "iconOnly" -image1 "directKeySmall.png" -width $iconSize -height $iconSize directKeyTool; toolButton -doubleClickCommand toolPropertyWindow -collection toolCluster -tool insertKeySuperContext -style "iconOnly" -image1 "setKeySmall.png" -width $iconSize -height $iconSize insertKeyTool; separator -height $iconSize -horizontal false -style single toolSeparator; // Keyframe stats window // keyframeStats -height $iconSize -width 170 -timeAnnotation (uiRes("m_dopeSheetPanel.kSelectedKeyTime")) -valueAnnotation (uiRes("m_dopeSheetPanel.kSelectedKeyValue")) keyframeStats; separator -height $iconSize -horizontal false -style single viewSeparator; // View buttons // iconTextButton -i1 "traxFrameAll.png" -width $iconSize -height $iconSize -annotation `uiRes( "m_dopeSheetPanel.kFrameAllAnnot" )` -command ("FrameAll") frameAllButton; iconTextButton -i1 "traxFrameRange.png" -width $iconSize -height $iconSize -annotation `uiRes( "m_dopeSheetPanel.kFramePlaybackRangeAnnot" )` -command ( "animView " + "-startTime (`playbackOptions -query -minTime` - 1) " + "-endTime (`playbackOptions -query -maxTime` + 1) " + $dopeSheetEd ) frameRangeButton; iconTextButton -i1 "centerCurrentTime.png" -width $iconSize -height $iconSize -annotation (uiRes("m_dopeSheetPanel.kCenterCurrentTimeIconAnnot")) -command ("dopeSheetEditor -edit -lookAt currentTime " + $dopeSheetEd) centerCurrentTimeButton; separator -height $iconSize -horizontal false -style single hierSeparator; iconTextCheckBox -width $iconSize -height $iconSize -onCommand ( "setHierarchyBelow 1 " + $dopeSheetEd ) -offCommand ( "setHierarchyBelow 0 " + $dopeSheetEd ) -annotation (uiRes("m_dopeSheetPanel.kHierarchyAboveBelowAnnot")) hierButton; // Set up the initial value if (`dopeSheetEditor -query -hierarchyBelow $dopeSheetEd`) { iconTextCheckBox -edit -i1 "hierOn.png" -value true hierButton; } else { iconTextCheckBox -edit -i1 "hierOff.png" -value false hierButton; } separator -height $iconSize -horizontal false -style single loadSeparator; // toggleAutoLoad needs to know the full path name of this button // however it is difficult to pass it in (because toggleAutoLoad // is called from several places, including c++ code), so instead // the name is carefully constructed to be unique // string $loadToggleButton = ($outlineEd + "loadToggleButton"); string $reloadButton = ($outlineEd + "reloadButton"); iconTextCheckBox -i1 "autoload.png" -width $iconSize -height $iconSize -onCommand ( "toggleAutoLoad " + $outlineEd + " 1" ) -offCommand ( "toggleAutoLoad " + $outlineEd + " 0" ) -annotation (uiRes("m_dopeSheetPanel.kAutoLoadAnnot")) -value `isAutoLoad $outlineEd` $loadToggleButton; iconTextButton -i1 "reload.png" -width $iconSize -height $iconSize -command ("doReload " + $outlineEd ) -annotation (uiRes("m_dopeSheetPanel.kLoadFromSelectionAnnot")) -enable (!`isAutoLoad $outlineEd`) $reloadButton; separator -height $iconSize -horizontal false -style single rightSeparator; setParent $widgetList[4]; // Get Graph Editor and Trax from Dope Sheet iconTextButton -i1 "getGraphEditor.png" -width $iconSize -height $iconSize -command ( "replaceEditor graphEditor1 GraphEditor" ) -annotation (uiRes("m_dopeSheetPanel.kGetGraphEditorIconAnnot")) -version "2017" getGraphEditorButton; iconTextButton -i1 "getTrax.png" -width $iconSize -height $iconSize -command ( "replaceEditor clipEditorPanel1 CharacterAnimationEditor" ) -annotation (uiRes("m_dopeSheetPanel.kGetTraxIconAnnot")) getTraxButton; int $margin = 1 ; formLayout -edit -attachForm $widgetList[5] "left" $margin -attachForm $widgetList[5] "top" $margin -attachForm $widgetList[5] "bottom" $margin -attachControl $widgetList[5] "right" 0 getGraphEditorButton -attachNone getGraphEditorButton "left" -attachForm getGraphEditorButton "top" $margin -attachForm getGraphEditorButton "bottom" $margin -attachControl getGraphEditorButton "right" 0 getTraxButton -attachNone getTraxButton "left" -attachForm getTraxButton "top" $margin -attachForm getTraxButton "bottom" $margin -attachForm getTraxButton "right" $margin $widgetList[4]; // Add two buttons to $widgetList[6] formLayout to // control the size of the formLayout that holds // the outliner and the graph editor widget // formLayout -p $widgetList[6] $outlineEdForm; outlinerEditor -edit -parent $outlineEdForm $outlineEd; setParent ..; // Attach the filter menu to the popup menu // This has to be done after the outliner has been parented // filterUICreateMenu($outlineEd, ($outlineEd + "Popup")); formLayout -e -af $outlineEd left 0 -af $outlineEd right 0 -af $outlineEd top 0 -af $outlineEd bottom 0 $outlineEdForm; // Parent the editors to the editor layout // dopeSheetEditor -edit -parent $widgetList[6] $dopeSheetEd; // Attach a procedure that will limit the kinds of filters displayed // in the Dope Sheet's filter menus. // filterUISetRelatedFiltersProcedure($outlineEd, "dopeSheetFilterCategories"); // Set the outliner pane to the last saved size. // evalDeferred("setDopeSheetOutlinerPaneSize " + $widgetList[6]); setParent -top; setUITemplate -popTemplate; // Do not use the wait cursor, it causes a problem (crash) when used // in combination with the table widget (key frame stats). // // waitCursor -state off; } global proc removeDopeSheetPanel (string $whichPanel) // // Description: // Remove the panel from a layout. // Delete controls. // { string $dopeSheetEd = ($whichPanel + "DopeSheetEd"); string $outlineEd = ($whichPanel + "OutlineEd"); string $outlineEdForm = ($whichPanel + "OutlineEdForm"); // Save the outliner width to restore on the next open. // if (`formLayout -exists $outlineEdForm`) { int $outlinerWidth = `formLayout -q -width $outlineEdForm`; optionVar -iv dopeSheetOutlinerWidth $outlinerWidth; } if (`outlinerEditor -exists $outlineEd`) { outlinerEditor -edit -unParent $outlineEd; } if (`dopeSheetEditor -exists $dopeSheetEd`) { dopeSheetEditor -edit -unParent $dopeSheetEd; } filterUIRemoveView($outlineEd); } global proc deleteDopeSheetPanel (string $whichPanel) // // Description: // This proc will delete the contents of the panel, but not // the panel itself. // // Note: // We only need to delete editors here. Other UI will be taken care of // by the remove proc. // { string $dopeSheetEd = ($whichPanel + "DopeSheetEd"); string $outlineEd = ($whichPanel + "OutlineEd"); string $outlineEdForm = ($whichPanel + "OutlineEdForm"); // Save the outliner width to restore on the next open. // if (`formLayout -exists $outlineEdForm`) { int $outlinerWidth = `formLayout -q -width $outlineEdForm`; optionVar -iv dopeSheetOutlinerWidth $outlinerWidth; } if (`outlinerEditor -exists $outlineEd`) { deleteUI -editor $outlineEd; } if (`dopeSheetEditor -exists $dopeSheetEd`) { deleteUI -editor $dopeSheetEd; } } global proc string saveStateDopeSheetPanel (string $whichPanel) // // Description: // This proc returns a string that when executed will restore the // current state of the panel elements. // { string $indent = "\n\t\t\t"; string $dopeSheetEd = ($whichPanel + "DopeSheetEd"); string $outlineEd = ($whichPanel + "OutlineEd"); return ( $indent + "$editorName = ($panelName+\"OutlineEd\");\n" + `outlinerEditor -query -stateString $outlineEd` + ";\n" + $indent + "$editorName = ($panelName+\"DopeSheetEd\");\n" + `dopeSheetEditor -query -stateString $dopeSheetEd` ); } global proc string [] dopeSheetFilterCategories() // // Description: // Return the types of filters that the Dope Sheet will display // in its "Show->Objects" filter menu. // { string $result[] = { "Modeling", "Camera", "Animating" }; return $result; } global proc setDopeSheetOutlinerPaneSize(string $dopeSheetPaneLayout) // // Description: // Set the outliner pane to the proper size (based on either // saved or default values). // { // Make sure the dopeSheetPaneLayout still exists as it may have been deleted. if(!`paneLayout -exists $dopeSheetPaneLayout`) { return; } int $paneLayoutWidth = `paneLayout -q -width $dopeSheetPaneLayout`; int $outlinerWidth = `optionVar -q dopeSheetOutlinerWidth`; int $outlinerProportion; if( !`optionVar -exists dopeSheetOutlinerWidth` || $outlinerWidth > $paneLayoutWidth) { if($paneLayoutWidth < 190) { // Set to the default proportion if the paneLayout // width is less than the default width. // $outlinerProportion = 30; $outlinerWidth = $outlinerProportion * $paneLayoutWidth / 100; } else { // Set to the default width if it is less than or // equal to the paneLayout width. // $outlinerWidth = 190; $outlinerProportion = $outlinerWidth * 100 / $paneLayoutWidth; } optionVar -iv dopeSheetOutlinerWidth $outlinerWidth; } else { // Set the proportion based on the saved width if it // is less than or equal to the paneLayout width. // $outlinerProportion = $outlinerWidth * 100 / $paneLayoutWidth; } // Set the pane proportion for the outliner pane. // paneLayout -e -paneSize 1 $outlinerProportion 100 $dopeSheetPaneLayout; }