void DrawOptions() { if (currentMode.headerState.options == TimelineModeGUIState.Hidden || state.editSequence.asset == null) { return; } using (new EditorGUI.DisabledScope(currentMode.headerState.options == TimelineModeGUIState.Disabled)) { var rect = new Rect(position.width - WindowConstants.cogButtonWidth, 0, WindowConstants.cogButtonWidth, WindowConstants.timeAreaYPosition); if (EditorGUI.DropdownButton(rect, DirectorStyles.optionsCogIcon, FocusType.Keyboard, EditorStyles.toolbarButton)) { GenericMenu menu = new GenericMenu(); menu.AddItem(L10n.TextContent("Preferences Page..."), false, () => SettingsWindow.Show(SettingsScope.User, "Preferences/Timeline")); menu.AddSeparator(""); menu.AddItem(MenuItemFrames, state.timeFormat == TimeFormat.Frames, () => state.timeFormat = TimeFormat.Frames); menu.AddItem(MenuItemTimecode, state.timeFormat == TimeFormat.Timecode, () => state.timeFormat = TimeFormat.Timecode); menu.AddItem(MenuItemSeconds, state.timeFormat == TimeFormat.Seconds, () => state.timeFormat = TimeFormat.Seconds); menu.AddSeparator(""); TimeAreaContextMenu.AddTimeAreaMenuItems(menu, state); menu.AddSeparator(""); bool isCustom = !FrameRateDisplayUtility.GetStandardFromFrameRate(state.editSequence.frameRate, out StandardFrameRates option); var frameRatesLabels = FrameRateDisplayUtility.GetDefaultFrameRatesLabels(option); if (isCustom) { frameRatesLabels[frameRatesLabels.Length - 1] = String.Format(k_CustomFpsLabel, frameRatesLabels.Last(), state.editSequence.frameRate); } for (var i = 0; i < frameRatesLabels.Length; i++) { var currentStandard = (StandardFrameRates)i; AddStandardFrameRateMenu(menu, currentStandard, frameRatesLabels[i], currentStandard == option); } if (Unsupported.IsDeveloperMode()) { menu.AddSeparator(""); menu.AddItem(L10n.TextContent("Show Snapping Debug"), SnapEngine.displayDebugLayout, () => SnapEngine.displayDebugLayout = !SnapEngine.displayDebugLayout); menu.AddItem(L10n.TextContent("Debug TimeArea"), false, () => Debug.LogFormat("translation: {0} scale: {1} rect: {2} shownRange: {3}", m_TimeArea.translation, m_TimeArea.scale, m_TimeArea.rect, m_TimeArea.shownArea)); menu.AddItem(L10n.TextContent("Edit Skin"), false, () => Selection.activeObject = DirectorStyles.Instance.customSkin); menu.AddItem(L10n.TextContent("Show QuadTree Debugger"), state.showQuadTree, () => state.showQuadTree = !state.showQuadTree); } menu.DropDown(rect); } } }
public static double FrameRateField(double frameRate, GUIContent label, Rect position, out bool isValid) { double frameRateDouble = FrameRateDisplayUtility.RoundFrameRate(frameRate); FrameRate frameRateObj = TimeUtility.GetClosestFrameRate(frameRateDouble); isValid = frameRateObj.IsValid(); TimeUtility.ToStandardFrameRate(frameRateObj, out StandardFrameRates option); position = EditorGUI.PrefixLabel(position, label); Rect posPopup = new Rect(position.x, position.y, position.width / 2, position.height); Rect posFloatField = new Rect(posPopup.xMax, position.y, position.width / 2, position.height); using (var checkOption = new EditorGUI.ChangeCheckScope()) { option = (StandardFrameRates)EditorGUI.Popup(posPopup, (int)option, FrameRateDisplayUtility.GetDefaultFrameRatesLabels(option)); if (checkOption.changed) { isValid = true; return(TimeUtility.ToFrameRate(option).rate); } } using (var checkFrame = new EditorGUI.ChangeCheckScope()) { frameRateDouble = Math.Abs(EditorGUI.DoubleField(posFloatField, frameRateDouble)); frameRateObj = TimeUtility.GetClosestFrameRate(frameRateDouble); if (checkFrame.changed) { isValid = frameRateObj.IsValid(); return(isValid ? frameRateObj.rate : frameRateDouble); } } return(frameRateDouble); }