//Add by liteng for MoveAtlas At 2014/1/4 Start
    private void VisitByListView(EditorControl c)
    {
        ListViewCtrl list = c as ListViewCtrl;

        if (list == null)
        {
            return;
        }


        EditorGUI.BeginDisabledGroup(!list.Enable);

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.BeginVertical(c.GetStyle(), c.GetOptions());
        Vector2 newScrollPos = EditorGUILayout.BeginScrollView(list.ScrollPos, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, GUIStyle.none);

        if (!newScrollPos.Equals(list.ScrollPos))
        {
            c.frameTriggerInfo.isScroll  = true;
            c.frameTriggerInfo.scrollPos = newScrollPos;
        }
        list.ScrollPos = newScrollPos;

        int count = 0;

        foreach (var item in list.Items)
        {
            foreach (var index in list.SelectItems)
            {
                if (index == count)
                {
                    GUI.color = item.onSelectColor;
                    GUI.Box(list.Items[index].lastRect, GUIContent.none);
                    GUI.color = Color.white;
                    break;
                }
            }
            //Modify by liteng for MoveAtlas End
            GUIContent itemContent = new GUIContent();
            itemContent.text = item.name;
            if (item.image != null)
            {
                itemContent.image = item.image;
            }
            //add by liteng for atlas begin
            if (!string.IsNullOrEmpty(item.tooltip))
            {
                itemContent.tooltip = item.tooltip;
            }

            //add by liteng end
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField(itemContent, itemStyle, new GUILayoutOption[] { GUILayout.MaxWidth(list.LastRect.width - scrollBarWidth) });

            SpecialEffectEditorUtility.GetLastRect(ref item.lastRect);

            EditorGUILayout.EndHorizontal();

            //Modify by liteng for MoveAtlas At 2015/1/4
            HandleMouseAction(list, count);

            count++;
        }
        HandleDragAction(list);
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        //为了顶住右侧边框,使ScrollView显示完全
        //GUILayout.Space(10f);

        EditorGUILayout.EndHorizontal();

        EditorGUI.EndDisabledGroup();

        c.UpdateLastRect();

        CheckInputEvent(c);
    }
    private void VisitByTextureView(EditorControl c)
    {
        ListViewCtrl list      = c as ListViewCtrl;
        Rect         tempRect  = new Rect();
        int          listIndex = 0;

        if (list == null)
        {
            return;
        }

        if (0 == list.TextureSizeLevel)
        {
            list.TextureSizeLevel = 1;
        }

        EditorGUILayout.BeginVertical(c.GetStyle(), c.GetOptions());

        Vector2 newScrollPos = EditorGUILayout.BeginScrollView(list.ScrollPos, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUIStyle.none);

        if (!newScrollPos.Equals(list.ScrollPos))
        {
            c.frameTriggerInfo.isScroll  = true;
            c.frameTriggerInfo.scrollPos = newScrollPos;
        }
        list.ScrollPos = newScrollPos;

        int curColumn = 0;

        int columns = Mathf.FloorToInt((float)c.LastRect.width / (float)(list.TextureSizeLevel * m_Padding + 20f));

        if (columns < 1)
        {
            columns = 1;
        }

        while (listIndex < list.Items.Count)
        {
            EditorGUILayout.BeginHorizontal();

            for (; listIndex < list.Items.Count; listIndex++)
            {
                if (curColumn >= columns)
                {
                    curColumn = 0;
                    break;
                }

                foreach (var index in list.SelectItems)
                {
                    if (index == listIndex)
                    {
                        GUI.color = list.Items[index].onSelectTexColor;
                        GUI.Box(list.Items[index].lastRect, GUIContent.none);
                        break;
                    }
                }
                GUIContent itemContent = new GUIContent();
                if (!string.IsNullOrEmpty(list.Items[listIndex].tooltip))
                {
                    itemContent.tooltip = list.Items[listIndex].tooltip;
                }
                if (list.Items[listIndex].image != null)
                {
                    itemContent.image = list.Items[listIndex].image;
                }

                EditorGUILayout.BeginVertical();
                GUILayout.Box(itemContent, new GUILayoutOption[] { GUILayout.Width(list.TextureSizeLevel * m_Padding), GUILayout.Height(list.TextureSizeLevel * m_Padding) });
                SpecialEffectEditorUtility.GetLastRect(ref list.Items[listIndex].lastRect);

                EditorGUILayout.LabelField(list.Items[listIndex].name, itemStyle, GUILayout.MaxWidth(list.TextureSizeLevel * m_Padding));
                SpecialEffectEditorUtility.GetLastRect(ref tempRect);
                list.Items[listIndex].lastRect.height += tempRect.height;

                GUI.color = Color.white;
                EditorGUILayout.EndVertical();

                HandleMouseAction(list, listIndex);
                curColumn++;
            }
            EditorGUILayout.EndHorizontal();
        }

        HandleDragAction(list);

        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
        c.UpdateLastRect();
        CheckInputEvent(c);
    }
    public override void Visit(EditorControl c)
    {
        currCtrl = c as TabViewCtrl;

        if (
            (null == currCtrl) ||
            (!currCtrl.Visiable)
            )
        {
            return;
        }

        if (currCtrl.GetChildCount() <= 1)
        {
            currCtrl.selectTab = 0;
            return;
        }

        int newSelect = -1;
        int selectTab = currCtrl.selectTab;

        EditorGUILayout.BeginHorizontal();
        for (int i = 0; i < currCtrl.GetChildCount(); i++)
        {
            GUIStyle currBtnStyle = null;

            if (i == 0)
            {
                if (selectTab == i)
                {
                    currBtnStyle = tabLeftBtnPressedStyle;
                }
                else
                {
                    currBtnStyle = tabLeftBtnNormalStyle;
                }
            }
            else if (i == currCtrl.GetChildCount() - 1)
            {
                if (selectTab == i)
                {
                    currBtnStyle = tabRightBtnPressedStyle;
                }
                else
                {
                    currBtnStyle = tabRightBtnNormalStyle;
                }
            }
            else
            {
                if (selectTab == i)
                {
                    currBtnStyle = tabMidBtnPressedStyle;
                }
                else
                {
                    currBtnStyle = tabMidBtnNormalStyle;
                }
            }

            if (GUILayout.Button(currCtrl.GetAt(i).Caption, currBtnStyle, tabBtnOptions))
            {
                newSelect = i;
            }
        }

        EditorGUILayout.EndHorizontal();

        SpecialEffectEditorUtility.GetLastRect(ref tabTitleRect);

        if (newSelect != -1)
        {
            if (currCtrl.selectTab != newSelect)
            {
                currCtrl.frameTriggerInfo.lastSelectItem = newSelect;
                currCtrl.selectTab = newSelect;
                currCtrl.RequestRepaint();
            }
        }
    }
Beispiel #4
0
 public void UpdateContentRect()
 {
     SpecialEffectEditorUtility.GetLastRect(ref lastContentRect);
 }
Beispiel #5
0
    public bool DrawTreeNode(TreeViewNode n)
    {
        float spacePixelsPerLevel = 10f;
        float offset = 10f;

        nodeContent = new GUIContent();

        EditorGUILayout.BeginHorizontal();

        GUILayout.Space(offset);

        foreach (var p in n.state.userParams)
        {
            if (p.param.GetType() == typeof(bool))
            {
                EditorGUILayout.LabelField(p.desc, toggleLabelStyle, GUILayout.Width(toggleLabelStyle.CalcSize(new GUIContent(p.desc)).x));
                bool newState = EditorGUILayout.Toggle((bool)p.param, toggleStyle, new GUILayoutOption[] { GUILayout.MaxWidth(20f) });

                if (newState != (bool)p.param)
                {
                    currCtrl.frameTriggerInfo.isValueChanged     = true;
                    currCtrl.frameTriggerInfo.isCtrlBehaveChange = true;
                    currCtrl.lastValueChangeNodePath             = n.GetPathString();
                    currCtrl.CurrValue = n;
                }
                p.param = newState;
            }
        }

        GUILayout.Space(offset + spacePixelsPerLevel * (float)n.Level());
        if (n.IsLeaf())
        {
            n.state.IsExpand = false;
        }
        bool newExpandState = false;

        nodeContent.text = n.name;
        if (n.image != null)
        {
            nodeContent.image = n.image;
        }

        if (n.tooptip != "")
        {
            nodeContent.tooltip = n.tooptip;
        }

        if (n.IsLeaf())
        {//叶节点绘制直接使用标签
            GUILayout.Space(14f);
            EditorGUILayout.LabelField(nodeContent, labelStyle, GUILayout.Width(labelStyle.CalcSize(nodeContent).x));
        }
        else
        {
            newExpandState = EditorGUILayout.Foldout(n.state.IsExpand, nodeContent, foldOutStyle);
        }

        SpecialEffectEditorUtility.GetLastRect(ref n.lastLabelRect);

        //若节点展开状态有变化则重绘
        if (newExpandState != n.state.IsExpand)
        {
            currCtrl.frameTriggerInfo.isCtrlBehaveChange = true;
            RequestRepaint();
        }

        if (currCtrl.Enable)
        {
            n.state.IsExpand = newExpandState;
        }

        //被选中节点绘制选中方形
        if (n.Equals(currCtrl.currSelectNode))
        {
            GUI.Box(n.lastRect, GUIContent.none);
            if (n.lastRect.size == new Vector2(0, 0))
            {
                RequestRepaint();
            }
        }

        EditorGUILayout.EndHorizontal();

        SpecialEffectEditorUtility.GetLastRect(ref n.lastRect);

        HandleMouseInput(n);

        //若当前节点没有展开则略过此节点子树渲染
        if (!n.state.IsExpand)
        {
            return(false);
        }

        return(true);
    }
    public override void Visit(EditorControl c)
    {
        currCtrl = c as PlayCtrl;

        if (
            (null == currCtrl)
            )
        {
            return;
        }

        EditorGUI.BeginDisabledGroup(!currCtrl.Enable);

        EditorGUILayout.BeginHorizontal();
        float newPlayTime = 0.0f;

        try
        {
            GUI.SetNextControlName(currCtrl.CtrlID);
            newPlayTime =
                EditorGUILayout.Slider(currCtrl.PlayTime, 0.0f, currCtrl.TotalTime,
                                       new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(20f), GUILayout.MinWidth(300f) });
        }catch (Exception e)
        {
            e.GetType();
            //Debug.Log(e.Message);
        }

        EditorGUI.EndDisabledGroup();

        c.UpdateLastRect();

        CheckInputEvent(c);

        //若鼠标在播放条发生点按事件,暂停播放
        if (c.LastRect.Contains(CalcLocalPos(c, FrameInputInfo.GetInstance().currPos)))
        {
            if (
                FrameInputInfo.GetInstance().leftButtonDown&&
                FrameInputInfo.GetInstance().leftBtnPress&&
                c.IsCurrentCtrlEnable()
                )
            {
                currCtrl.Pause();
            }
        }

        if (!currCtrl.IsPlaying)
        {
            if (Mathf.Abs(currCtrl.PlayTime - newPlayTime) > Mathf.Epsilon)
            {
                currCtrl.frameTriggerInfo.isValueChanged = true;
            }
            currCtrl.PlayTime      = newPlayTime;
            currCtrl.IsForceUpdate = false;
        }

        EditorGUI.BeginDisabledGroup(!currCtrl.Enable);

        GUILayoutOption[] btnOptions = new GUILayoutOption[] {
            GUILayout.Width(40), GUILayout.Height(20)
        };

        if (!currCtrl.IsPlaying)
        {
            if (GUILayout.Button("播放", btnOptions))
            {
                currCtrl.Play();
                currCtrl.frameTriggerInfo.isValueChanged = true;
                currCtrl.frameTriggerInfo.isPlay         = true;
            }
        }
        else
        {
            if (GUILayout.Button("暂停", btnOptions))
            {
                currCtrl.Pause();
                currCtrl.frameTriggerInfo.isValueChanged = true;
                currCtrl.frameTriggerInfo.isPause        = true;
            }
        }
        //if( GUILayout.Button("播放", btnOptions) )
        //{
        //    currCtrl.Play();
        //    currCtrl.frameTriggerInfo.isValueChanged = true;
        //    currCtrl.frameTriggerInfo.isPlay = true;
        //}
        //if( GUILayout.Button("暂停", btnOptions) )
        //{
        //    currCtrl.Pause();
        //    currCtrl.frameTriggerInfo.isValueChanged = true;
        //    currCtrl.frameTriggerInfo.isPause = true;
        //}
        if (GUILayout.Button("停止", btnOptions))
        {
            currCtrl.Stop();
            currCtrl.frameTriggerInfo.isValueChanged = true;
            currCtrl.frameTriggerInfo.isStop         = true;
        }

        EditorGUILayout.LabelField("Loop", GUILayout.Width(30f));
        currCtrl.IsLoop = EditorGUILayout.Toggle(currCtrl.IsLoop, GUILayout.Width(20f));

        EditorGUI.EndDisabledGroup();


        EditorGUILayout.EndHorizontal();

        SpecialEffectEditorUtility.GetLastRect(ref totalRect);

        CheckInputEvent(c, totalRect);
    }