/// <summary> /// Creates a new curve editor GUI elements. /// </summary> /// <param name="window">Parent window of the GUI element.</param> /// <param name="gui">GUI layout into which to place the GUI element.</param> /// <param name="width">Width in pixels.</param> /// <param name="height">Height in pixels.</param> public GUICurveEditor(AnimationWindow window, GUILayout gui, int width, int height) { this.window = window; this.gui = gui; this.width = width; this.height = height; blankContextMenu = new ContextMenu(); blankContextMenu.AddItem("Add keyframe", AddKeyframeAtPosition); blankEventContextMenu = new ContextMenu(); blankEventContextMenu.AddItem("Add event", AddEventAtPosition); keyframeContextMenu = new ContextMenu(); keyframeContextMenu.AddItem("Delete", DeleteSelectedKeyframes); keyframeContextMenu.AddItem("Edit", EditSelectedKeyframe); keyframeContextMenu.AddItem("Tangents/Auto", () => { ChangeSelectionTangentMode(TangentMode.Auto); }); keyframeContextMenu.AddItem("Tangents/Free", () => { ChangeSelectionTangentMode(TangentMode.Free); }); keyframeContextMenu.AddItem("Tangents/In/Auto", () => { ChangeSelectionTangentMode(TangentMode.InAuto); }); keyframeContextMenu.AddItem("Tangents/In/Free", () => { ChangeSelectionTangentMode(TangentMode.InFree); }); keyframeContextMenu.AddItem("Tangents/In/Linear", () => { ChangeSelectionTangentMode(TangentMode.InLinear); }); keyframeContextMenu.AddItem("Tangents/In/Step", () => { ChangeSelectionTangentMode(TangentMode.InStep); }); keyframeContextMenu.AddItem("Tangents/Out/Auto", () => { ChangeSelectionTangentMode(TangentMode.OutAuto); }); keyframeContextMenu.AddItem("Tangents/Out/Free", () => { ChangeSelectionTangentMode(TangentMode.OutFree); }); keyframeContextMenu.AddItem("Tangents/Out/Linear", () => { ChangeSelectionTangentMode(TangentMode.OutLinear); }); keyframeContextMenu.AddItem("Tangents/Out/Step", () => { ChangeSelectionTangentMode(TangentMode.OutStep); }); eventContextMenu = new ContextMenu(); eventContextMenu.AddItem("Delete", DeleteSelectedEvents); eventContextMenu.AddItem("Edit", EditSelectedEvent); GUIPanel timelinePanel = gui.AddPanel(); guiTimeline = new GUIGraphTime(timelinePanel, width, TIMELINE_HEIGHT); GUIPanel timelineBgPanel = gui.AddPanel(1); GUITexture timelineBackground = new GUITexture(null, EditorStyles.Header); timelineBackground.Bounds = new Rect2I(0, 0, width, TIMELINE_HEIGHT + VERT_PADDING); timelineBgPanel.AddElement(timelineBackground); eventsPanel = gui.AddPanel(); eventsPanel.SetPosition(0, TIMELINE_HEIGHT + VERT_PADDING); guiEvents = new GUIAnimEvents(eventsPanel, width, EVENTS_HEIGHT); GUIPanel eventsBgPanel = eventsPanel.AddPanel(1); GUITexture eventsBackground = new GUITexture(null, EditorStyles.Header); eventsBackground.Bounds = new Rect2I(0, 0, width, EVENTS_HEIGHT + VERT_PADDING); eventsBgPanel.AddElement(eventsBackground); drawingPanel = gui.AddPanel(); drawingPanel.SetPosition(0, TIMELINE_HEIGHT + EVENTS_HEIGHT + VERT_PADDING); guiCurveDrawing = new GUICurveDrawing(drawingPanel, width, height - TIMELINE_HEIGHT - EVENTS_HEIGHT - VERT_PADDING * 2, curveInfos); guiCurveDrawing.SetRange(60.0f, 20.0f); GUIPanel sidebarPanel = gui.AddPanel(-10); sidebarPanel.SetPosition(0, TIMELINE_HEIGHT + EVENTS_HEIGHT + VERT_PADDING); guiSidebar = new GUIGraphValues(sidebarPanel, SIDEBAR_WIDTH, height - TIMELINE_HEIGHT - EVENTS_HEIGHT - VERT_PADDING * 2); guiSidebar.SetRange(-10.0f, 10.0f); }
/// <summary> /// Creates a new curve editor GUI elements. /// </summary> /// <param name="window">Parent window of the GUI element.</param> /// <param name="gui">GUI layout into which to place the GUI element.</param> /// <param name="width">Width in pixels.</param> /// <param name="height">Height in pixels.</param> public GUICurveEditor(AnimationWindow window, GUILayout gui, int width, int height) { this.window = window; this.gui = gui; this.width = width; this.height = height; blankContextMenu = new ContextMenu(); blankContextMenu.AddItem("Add keyframe", AddKeyframeAtPosition); blankEventContextMenu = new ContextMenu(); blankEventContextMenu.AddItem("Add event", AddEventAtPosition); keyframeContextMenu = new ContextMenu(); keyframeContextMenu.AddItem("Delete", DeleteSelectedKeyframes); keyframeContextMenu.AddItem("Edit", EditSelectedKeyframe); keyframeContextMenu.AddItem("Tangents/Auto", () => { ChangeSelectionTangentMode(TangentMode.Auto); }); keyframeContextMenu.AddItem("Tangents/Free", () => { ChangeSelectionTangentMode(TangentMode.Free); }); keyframeContextMenu.AddItem("Tangents/In/Auto", () => { ChangeSelectionTangentMode(TangentMode.InAuto); }); keyframeContextMenu.AddItem("Tangents/In/Free", () => { ChangeSelectionTangentMode(TangentMode.InFree); }); keyframeContextMenu.AddItem("Tangents/In/Linear", () => { ChangeSelectionTangentMode(TangentMode.InLinear); }); keyframeContextMenu.AddItem("Tangents/In/Step", () => { ChangeSelectionTangentMode(TangentMode.InStep); }); keyframeContextMenu.AddItem("Tangents/Out/Auto", () => { ChangeSelectionTangentMode(TangentMode.OutAuto); }); keyframeContextMenu.AddItem("Tangents/Out/Free", () => { ChangeSelectionTangentMode(TangentMode.OutFree); }); keyframeContextMenu.AddItem("Tangents/Out/Linear", () => { ChangeSelectionTangentMode(TangentMode.OutLinear); }); keyframeContextMenu.AddItem("Tangents/Out/Step", () => { ChangeSelectionTangentMode(TangentMode.OutStep); }); eventContextMenu = new ContextMenu(); eventContextMenu.AddItem("Delete", DeleteSelectedEvents); eventContextMenu.AddItem("Edit", EditSelectedEvent); GUIPanel timelinePanel = gui.AddPanel(); guiTimeline = new GUIGraphTime(timelinePanel, width, TIMELINE_HEIGHT); GUIPanel timelineBgPanel = gui.AddPanel(1); GUITexture timelineBackground = new GUITexture(null, EditorStyles.Header); timelineBackground.Bounds = new Rect2I(0, 0, width, TIMELINE_HEIGHT + VERT_PADDING); timelineBgPanel.AddElement(timelineBackground); eventsPanel = gui.AddPanel(); eventsPanel.SetPosition(0, TIMELINE_HEIGHT + VERT_PADDING); guiEvents = new GUIAnimEvents(eventsPanel, width, EVENTS_HEIGHT); GUIPanel eventsBgPanel = eventsPanel.AddPanel(1); GUITexture eventsBackground = new GUITexture(null, EditorStyles.Header); eventsBackground.Bounds = new Rect2I(0, 0, width, EVENTS_HEIGHT + VERT_PADDING); eventsBgPanel.AddElement(eventsBackground); drawingPanel = gui.AddPanel(); drawingPanel.SetPosition(0, TIMELINE_HEIGHT + EVENTS_HEIGHT + VERT_PADDING); guiCurveDrawing = new GUICurveDrawing(drawingPanel, width, height - TIMELINE_HEIGHT - EVENTS_HEIGHT - VERT_PADDING * 2, curveInfos); guiCurveDrawing.SetRange(60.0f, 20.0f); GUIPanel sidebarPanel = gui.AddPanel(-10); sidebarPanel.SetPosition(0, TIMELINE_HEIGHT + EVENTS_HEIGHT + VERT_PADDING); guiSidebar = new GUIGraphValues(sidebarPanel, SIDEBAR_WIDTH, height - TIMELINE_HEIGHT - EVENTS_HEIGHT - VERT_PADDING * 2); guiSidebar.SetRange(-10.0f, 10.0f); }