static int ToggleExpand(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UI.SequenceHandle obj = (UI.SequenceHandle)ToLua.CheckObject(L, 1, typeof(UI.SequenceHandle)); float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); obj.ToggleExpand(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
//计算时间轴区域的点击事件 void TimeLineInput() { float wOneSce = RectTimeLine.width / (m_handle.m_duration * 1.04f); //1秒的长度 float minMarkUnit = minUnit * wOneSce; //最小单位对应的长度 //鼠标点击事件 if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { //跳至对应时间 if (RectTimeLine.Contains(Event.current.mousePosition)) { CanDragTimeLine = true; CurTime = (Event.current.mousePosition.x - RectTimeLine.x) / wOneSce; Event.current.Use(); } //处理组的展开和拖动 else if (RectHandles.Contains(Event.current.mousePosition)) { float t = (Event.current.mousePosition.x - RectHandles.x) / wOneSce; Handle h = m_subHandles.GetClosest(t, 0, 8 / wOneSce);//5像素内点击成功 if (CurSelectHandles != null) { if (t >= SelectLeft && t <= SelectRight) { CanDragSelect = true; } else { CurSelectHandles = null; } } else if (h != null) { CurDowmHandles = h; } else { CanSelect = true; SelectLeft = t; SelectRight = t; } Event.current.Use(); } //处理的显示和拖动 else if (RectSubHandle.Contains(Event.current.mousePosition)) { CurDowmSubHandle = m_subHandles.GetClosest( (Event.current.mousePosition.x - RectHandles.x) / wOneSce, (int)((Event.current.mousePosition.y - ScrollHandles.y - RectHandles.yMax - 5) / (hHandleRow + 2f)), 7 / wOneSce);//5像素内点击成功 Event.current.Use(); } } else if (Event.current.type == EventType.MouseDrag && Event.current.button == 0) { float t = Mathf.Clamp((Event.current.mousePosition.x - RectTimeLine.x) / wOneSce, 0, m_handle.m_duration); float tClosest = Mathf.Clamp(Util.ClosestOf((Event.current.mousePosition.x - RectTimeLine.x) / wOneSce, minUnit), 0, m_handle.m_duration); bool use = true; //跳至对应时间 if (CanDragTimeLine == true) { CurTime = t; } //处理组的拖动 else if (CurDowmHandles != null) { CurDragHandles = CurDowmHandles; CurDowmHandles = null; DragHandlesTime = tClosest; } else if (CurDragHandles != null) { DragHandlesTime = tClosest; } else if (CurDowmSubHandle != null) { CurDragSubHandle = CurDowmSubHandle; CurDowmSubHandle = null; DragSubHandleTime = tClosest; } else if (CurDragSubHandle != null) { DragSubHandleTime = tClosest; } else if (CanSelect) { SelectRight = t; } else if (CanDragSelect) { SelectOffsetTime = Mathf.Clamp( SelectOffsetTime + Event.current.delta.x / wOneSce, -SelectLeft, m_handle.m_duration - SelectRight); } else { use = false; } if (use) { Event.current.Use(); } } else if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { bool use = true; //处理组的拖动 if (CurDowmHandles != null) { m_subHandles.ToggleExpand(CurDowmHandles.m_delay); } else if (CurDragHandles != null) { m_subHandles.ChangeTime(m_comp, m_handle, CurDragHandles.m_delay, DragHandlesTime); } else if (CurDowmSubHandle != null) { CurDowmSubHandle.m_seqIsShow = !CurDowmSubHandle.m_seqIsShow; } else if (CurDragSubHandle != null) { m_subHandles.ChangeTime(m_comp, m_handle, CurDragSubHandle, DragSubHandleTime); } else if (CanDragSelect) { SelectOffsetTime = Util.ClosestOf(SelectOffsetTime, minUnit); m_subHandles.OffsetTime(m_comp, m_handle, CurSelectHandles, SelectOffsetTime); CurSelectHandles = null; } else if (CanSelect) { CurSelectHandles = m_subHandles.GetRange(SelectLeft, SelectRight); SelectOffsetTime = 0; if (CurSelectHandles.Count == 0) { CurSelectHandles = null; } else { SelectLeft = CurSelectHandles[0].m_delay; SelectRight = CurSelectHandles[CurSelectHandles.Count - 1].m_delay; } } else { use = false; } CanDragTimeLine = false; CurDowmHandles = null; CurDragHandles = null; CurDowmSubHandle = null; CurDragSubHandle = null; CanSelect = false; CanDragSelect = false; this.PreRemoveSubHandles = null; this.PreRemoveSubHandle = null; if (use) { Event.current.Use(); } } else if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { float tClosest = Mathf.Clamp(Util.ClosestOf((Event.current.mousePosition.x - RectTimeLine.x) / wOneSce, minUnit), 0, m_handle.m_duration); bool use = true; //跳至对应时间 if (RectHandles.Contains(Event.current.mousePosition)) { this.PreRemoveSubHandle = null; this.PreRemoveSubHandles = m_subHandles.GetClosest(tClosest, 0, 8 / wOneSce);//5像素内点击成功 } //处理的增加删除 else if (RectSubHandle.Contains(Event.current.mousePosition)) { this.PreRemoveSubHandle = m_subHandles.GetClosest(tClosest, (int)((Event.current.mousePosition.y - ScrollHandles.y - RectHandles.yMax - 5) / (hHandleRow + 2f)), 7 / wOneSce);//5像素内点击成功 this.PreRemoveSubHandles = null; } else { use = false; } if (use) { Event.current.Use(); } } else if (Event.current.type == EventType.MouseUp && Event.current.button == 1) { if (RectHandles.Contains(Event.current.mousePosition) || RectSubHandle.Contains(Event.current.mousePosition)) { float tClosest = Mathf.Clamp(Util.ClosestOf((Event.current.mousePosition.x - RectTimeLine.x) / wOneSce, minUnit), 0, m_handle.m_duration); GenericMenu contextMenu = new GenericMenu(); if (this.PreRemoveSubHandles != null) { contextMenu.AddItem(new GUIContent("删除"), false, () =>//不导出中文 { this.m_subHandles.RemoveSubHandle(this.m_comp, this.m_handle, this.PreRemoveSubHandles.m_delay); this.PreRemoveSubHandles = null; this.PreRemoveSubHandle = null; }); } else if (this.PreRemoveSubHandle != null) { contextMenu.AddItem(new GUIContent("删除"), false, () =>//不导出中文 { this.m_subHandles.RemoveSubHandle(this.m_comp, this.m_handle, this.PreRemoveSubHandle); this.PreRemoveSubHandles = null; this.PreRemoveSubHandle = null; }); } for (int i = 0; i < (int)Handle.Type.max; ++i) { int tem = i; contextMenu.AddItem(new GUIContent("添加/" + Handle.TypeName[tem]), false, () =>//不导出中文 { this.m_subHandles.AddSubHandle(this.m_comp, this.m_handle, (Handle.Type)tem, tClosest); }); } contextMenu.ShowAsContext(); Event.current.Use(); } } }