public override void Visit(EditorControl c)
    {
        currCtrl = c as ButtonCtrl;
        if (currCtrl == null)
        {
            return;
        }

        Color oldColor = GUI.color;

        GUI.color = currCtrl.BtnColor;

        EditorGUI.BeginDisabledGroup(!currCtrl.Enable);

        //Moidfy by liteng for 追加共同控件 at 2015/2/26 Start
        if (currCtrl.IsRepeat)
        {
            c.frameTriggerInfo.isClick = GUILayout.RepeatButton(c.Caption, c.GetOptions());
            //currCtrl.RequestRepaint();
        }
        else
        {
            c.frameTriggerInfo.isClick = GUILayout.Button(c.Caption, c.GetOptions());
        }
        //Modify by liteng for 追加共同控件 End

        EditorGUI.EndDisabledGroup();

        c.UpdateLastRect();

        CheckInputEvent(c);

        GUI.color = oldColor;
    }
    public override void Visit(EditorControl c)
    {
        TextureBoxCtrl textureBox = c as TextureBoxCtrl;

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

        EditorGUI.BeginDisabledGroup(!textureBox.Enable);

        //Texture2D backgroundTex = AssetDatabase.LoadAssetAtPath("Assets/H3DTech/Editor/UniversalEditor/UIAtlasEditor/Data/Resources/background.png", typeof(Texture)) as Texture2D;
        EditorGUILayout.BeginVertical(c.GetStyle(), c.GetOptions());
        if (textureBox.Image != null)
        {
            //GUI.DrawTexture(tempRect, backgroundTex, ScaleMode.StretchToFill, true);
            //NGUIEditorTools.DrawTiledTexture(textureBox.LastRect, NGUIEditorTools.backdropTexture);
            EditorGUI.DrawTextureTransparent(textureBox.LastRect, textureBox.Image, ScaleMode.ScaleToFit);
            //EditorGUI.DrawPreviewTexture(textureBox.LastRect, textureBox.Image);
            // GUI.DrawTexture(textureBox.LastRect, textureBox.Image, ScaleMode.ScaleToFit, true);
        }
        EditorGUILayout.EndVertical();

        EditorGUI.EndDisabledGroup();

        c.UpdateLastRect();

        CheckInputEvent(c);
    }
    public override void Visit(EditorControl c)
    {
        LabelCtrl label = c as LabelCtrl;

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

        EditorGUI.BeginDisabledGroup(!label.Enable);

        Color oldColor = labelStyle.normal.textColor;

        labelStyle.normal.textColor = label.textColor;
        //Add by liteng for MoveAtlas At 2014/1/4
        labelStyle.fontSize = label.fontSize;
        labelStyle.margin   = label.margin;

        GUILayout.Label(c.Caption, labelStyle, c.GetOptions());

        labelStyle.normal.textColor = oldColor;

        EditorGUI.EndDisabledGroup();

        c.UpdateLastRect();

        HandleMouseInput(c);
    }
Example #4
0
    public override void Visit(EditorControl c)
    {
        HSpliterCtrl spliter = c as HSpliterCtrl;

        GUILayout.Box("", c.GetStyle(), c.GetOptions());

        c.UpdateLastRect();

        if (spliter.Dragable && spliter.IsCurrentCtrlEnable())
        {
            if (
                FrameInputInfo.GetInstance().leftBtnPress&&
                c.LastRect.Contains(FrameInputInfo.GetInstance().currPos)
                )
            {
                spliter.IsDragging = true;
            }
            else
            {
                if (FrameInputInfo.GetInstance().leftButtonDown == false)
                {
                    spliter.IsDragging = false;
                }

                if (spliter.IsDragging)
                {
                    if (null != c.layoutConstraint)
                    {
                        Vector2 mouseDelta = FrameInputInfo.GetInstance().posOffset;


                        if (Mathf.Abs(mouseDelta.y) > Mathf.Epsilon)
                        {
                            if (c.layoutConstraint.spliterOffsetInv)
                            {
                                c.layoutConstraint.spliterOffset -= mouseDelta.y;
                            }
                            else
                            {
                                c.layoutConstraint.spliterOffset += mouseDelta.y;
                            }

                            if (c.layoutConstraint.spliterOffset < spliter.MinOffset)
                            {
                                c.layoutConstraint.spliterOffset = spliter.MinOffset;
                            }
                            if (c.layoutConstraint.spliterOffset > spliter.MaxOffset)
                            {
                                c.layoutConstraint.spliterOffset = spliter.MaxOffset;
                            }

                            c.RequestRepaint();
                        }
                    }
                }
            }
            EditorGUIUtility.AddCursorRect(c.LastRect, MouseCursor.ResizeVertical);
        }
    }
    //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);
    }
Example #7
0
    public override void Visit(EditorControl c)
    {
        currCtrl = c as TimeLineViewCtrl;
        if (
            (null == currCtrl)
            )
        {
            return;
        }


        //float itemWidth = c.LastRect.width;
        float itemHeight   = 19.0f;
        float itemInterval = 3.0f;

        float rulerTotalLength   = currCtrl.rulerTotalPixelLength;
        float smallScalesNum     = currCtrl.CalcSmallScaleCount(rulerTotalLength);
        float rulerOffset        = currCtrl.rulerHorizonPixelOffset;
        float rulerPixelLength   = rulerTotalLength + rulerOffset;
        float smallScalePixelLen = currCtrl.GetSmallScalePixelLength();
        //float bigScalePixelLen = currCtrl.GetBigScalePixelLength();
        float smallScaleHeight    = itemHeight * 0.3f;
        float bigScaleHeight      = itemHeight * 0.8f;
        float framesPerSmallScale = currCtrl.framesPerSmallScale;
        //float framesPerBigScale = framesPerSmallScale * 10f;


        //时间线款
        float itemTimeLineHeight = itemHeight * 0.4f;
        float itemOffsetHeight   = (itemHeight - itemTimeLineHeight) / 3.5f;


        //根据时间轴列表的滚动条位置,移动可视区域
        viewRect = c.LastRect;
        //viewRect.x += currCtrl.ScrollPos.x;
        viewRect.y    += currCtrl.ScrollPos.y;
        viewRect.width = rulerOffset + rulerTotalLength;


        Vector2 viewIndependentUpperLeft = new Vector2(c.LastRect.x, c.LastRect.y);
        Vector2 viewDependentUpperLeft   = new Vector2(viewRect.x, viewRect.y);

        //Vector2 localMousePos = c.CalcLocalPos(currCtrl.mousePos);

        EditorGUI.BeginDisabledGroup(!currCtrl.Enable);

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

        float scrollPosY = currCtrl.ScrollPos.y;

        currCtrl.ScrollPos =
            GUI.BeginScrollView(c.LastRect, currCtrl.ScrollPos, viewRect, GUI.skin.horizontalScrollbar, GUIStyle.none);

        currCtrl.ScrollPos = new Vector2(currCtrl.ScrollPos.x, scrollPosY);

        int   i = 0;
        float x = c.LastRect.x;
        float y = c.LastRect.y + itemHeight;

        foreach (var item in currCtrl.Items)
        {    //绘制子时间轴
            if (!item.visiable)
            {
                i++;
                continue;
            }
            y += itemInterval;
            y += itemOffsetHeight;

            float itemTimeLineWidth  = currCtrl.CalcPixelLengthByTime(item.length);
            float itemTimeLineStartX = currCtrl.CalcPixelLengthByTime(item.startTime);

            Color timeLineItemColor;
            if (i == currCtrl.LastSelectedItem || currCtrl.IsHighLightBox(i, TimeLineViewCtrl.SIDE_MID))
            {
                timeLineItemColor = item.onSelectedColor;
                GUI.color         = item.onSelectedColor;
            }
            else if (!item.enable)
            {
                timeLineItemColor = Color.gray;
                GUI.color         = Color.gray;
            }
            else
            {
                timeLineItemColor = item.color;
                GUI.color         = item.color;
            }

            item.lastRect = new Rect(x + itemTimeLineStartX + rulerOffset, y, itemTimeLineWidth, itemTimeLineHeight);
            Drawing.DrawColorBox(item.lastRect, timeLineItemColor);

            float boxHeight        = itemTimeLineHeight * 1.5f;
            float boxOffsetHeight  = itemTimeLineHeight * 0.25f;
            Rect  leftDragBoxRect  = new Rect(item.lastRect.x, item.lastRect.y - boxOffsetHeight, boxHeight, boxHeight);
            Rect  rightDragBoxRect = new Rect(item.lastRect.x + itemTimeLineWidth - boxHeight, item.lastRect.y - boxOffsetHeight, boxHeight, boxHeight);

            //用于碰撞检测
            item.leftDragLastRect  = leftDragBoxRect;
            item.rightDragLastRect = rightDragBoxRect;

            Color leftDragBoxColor  = item.dragBoxColor;
            Color rightDragBoxColor = item.dragBoxColor;

            if (currCtrl.IsHighLightBox(i, TimeLineViewCtrl.SIDE_LEFT))
            {
                leftDragBoxColor = item.dragBoxSelectedColor;
            }

            if (currCtrl.IsHighLightBox(i, TimeLineViewCtrl.SIDE_RIGHT))
            {
                rightDragBoxColor = item.dragBoxSelectedColor;
            }

            Drawing.DrawColorBox(leftDragBoxRect, leftDragBoxColor);
            Drawing.DrawColorBox(rightDragBoxRect, rightDragBoxColor);


            //若当前时间轴属于拖动状态绘制标线
            if (
                currCtrl.IsHighLightBox(i, TimeLineViewCtrl.SIDE_MID) ||
                currCtrl.IsHighLightBox(i, TimeLineViewCtrl.SIDE_LEFT) ||
                currCtrl.IsHighLightBox(i, TimeLineViewCtrl.SIDE_RIGHT)
                )
            {
                //绘制时间线前后两个基准线
                DrawFullViewVLine(item.lastRect.x, Color.white, 1);
                DrawFullViewVLine(item.lastRect.x + itemTimeLineWidth, Color.white, 1);

                //绘制基准线时间标
                GUI.Box(
                    new Rect(item.lastRect.x + 4, y - 18, 60, 18),
                    currCtrl.Trans2RealTime(item.lastRect.x - currCtrl.LastRect.x).ToString("f2") + "s",
                    SpecialEffectEditorStyle.TimeLineMouseTag);

                GUI.Box(
                    new Rect(item.lastRect.x + itemTimeLineWidth + 4, y - 18, 60, 18),
                    currCtrl.Trans2RealTime(item.lastRect.x + itemTimeLineWidth - currCtrl.LastRect.x).ToString("f2") + "s",
                    SpecialEffectEditorStyle.TimeLineMouseTag);
            }

            y += itemTimeLineHeight;
            y += itemOffsetHeight;
            i++;
        }    //绘制子时间轴

        GUI.color = Color.white;


        {    //绘制标尺
            //标尺主体
            GUI.Box(new Rect(c.LastRect.x, viewRect.y, rulerPixelLength, itemHeight), GUIContent.none);

            //绘制标记
            foreach (var tag in currCtrl.Tags)
            {
                float tagSize   = itemHeight;
                float tagOffset = currCtrl.CalcPixelLengthByTime(tag.time);

                float tagCenterX = viewIndependentUpperLeft.x + rulerOffset + tagOffset;
                float tagX       = tagCenterX - tagSize * 0.5f;

                tag.lastRect.Set(tagX, viewDependentUpperLeft.y, tagSize, tagSize);

                Color tagColor = tag.color;
                if (tag.isDragging)
                {
                    tagColor = tag.onDragColor;
                }
                Drawing.DrawColorBox(tag.lastRect, tagColor);

                DrawFullViewVLine(tagCenterX, tagColor, 1);
            }

            //绘制起始线
            DrawFullViewVLine(rulerOffset + c.LastRect.x, Color.red, 1);

            //float mouseLineX = localMousePos.x + viewRect.x + currCtrl.ScrollPos.x;

            //美术认为目前不需要鼠标时间线

            /*
             * if (false)
             * {
             *  //绘制鼠标线
             *  DrawFullViewVLine(mouseLineX, Color.yellow, 1);
             *
             *
             *  //绘制鼠标辅助线所指时间
             *  if (currCtrl.showMouseTag)
             *  {
             *      GUI.Box(
             *          new Rect(mouseLineX + 4,
             *              (localMousePos.y - 18) + viewRect.y, 60, 18),
             *          currCtrl.Trans2RealTime(localMousePos.x + currCtrl.ScrollPos.x).ToString("f2") + "s",
             *          SpecialEffectEditorStyle.TimeLineMouseTag);
             *  }
             * }*/

            //绘制当前帧标线
            DrawFullViewVLine(c.LastRect.x + rulerOffset + currCtrl.CalcPixelLengthByTime(currCtrl.CurrPlayTime), Color.gray, 1);

            //绘制当前帧标线
            Vector2 p0 = new Vector2(), p1 = new Vector2();

            //绘制小刻度
            for (int j = 0; j < smallScalesNum; j++)
            {
                float xStart = rulerOffset + c.LastRect.x + j * smallScalePixelLen;
                float yStart = viewRect.y + (itemHeight - smallScaleHeight);
                p0 = new Vector2(xStart, yStart);
                p1 = new Vector2(xStart, yStart + smallScaleHeight);
                Drawing.DrawLine(p0, p1, Color.black, 1f);

                //绘制大刻度
                if (0 == j % (int)currCtrl.smallScalesPerBigScale)
                {
                    yStart = viewRect.y + (itemHeight - bigScaleHeight);
                    p0     = new Vector2(xStart, yStart);
                    p1     = new Vector2(xStart, yStart + bigScaleHeight);
                    Drawing.DrawLine(p0, p1, Color.black, 1f);

                    //标尺刻度值
                    GUI.Box(new Rect(p0.x + 4, viewRect.y, 100, 18), (framesPerSmallScale * j).ToString(), SpecialEffectEditorStyle.RulerNum);
                }
            }


            //绘制总时间线
            Vector2 startTimePos = new Vector2(rulerOffset + c.LastRect.x, viewRect.y + itemHeight);
            Vector2 endTimePos   = new Vector2(rulerOffset + c.LastRect.x + currCtrl.CalcPixelLengthByTime(currCtrl.TotalTime), startTimePos.y);
            Drawing.DrawLine(startTimePos - new Vector2(0, bigScaleHeight), startTimePos, Color.red, 2);
            Drawing.DrawLine(endTimePos - new Vector2(0, bigScaleHeight), endTimePos, Color.red, 2);
            Drawing.DrawLine(startTimePos, endTimePos, Color.red, 2);
        }    //绘制标尺

        {    //绘制多选范围
            if (currCtrl.mutiSelectState == TimeLineViewCtrl.MutiSelectState.STATE_DRAGGING_MUTI_SEL_RECT)
            {
                GUI.Box(currCtrl.lastMutiSelectRect, GUIContent.none);
            }
        }    //绘制多选范围

        GUI.EndScrollView();

        EditorGUILayout.EndVertical();

        EditorGUI.EndDisabledGroup();

        //处理所有输入交互
        HandleInput();

        c.UpdateLastRect();
    }
    public override void Visit(EditorControl c)
    {
        bool isHandle = false;

        currCtrl = c as MainViewCtrl;
        if (
            (null == currCtrl)
            )
        {
            return;
        }

        currCtrl.Init();

        //_RenderScene();

        if (currCtrl.IsShowAxis)
        {
            isHandle = InitAxis();
        }

        Rect mainViewRect      = new Rect(c.LastRect);
        Rect assistantViewRect = new Rect(c.LastRect.x + c.LastRect.width - assTextureSize, c.LastRect.y, assTextureSize, assTextureSize);

        if ((c.LastRect.x + c.LastRect.width) < assTextureSize)
        {
            assistantViewRect.x     = c.LastRect.x;
            assistantViewRect.width = c.LastRect.width;
        }

        if ((c.LastRect.height) < assTextureSize)
        {
            assistantViewRect.height = c.LastRect.height;
        }

        EditorGUILayout.BeginHorizontal(c.GetStyle(), c.GetOptions());
        //GUI.DrawTexture(mainViewRect, currCtrl.mainViewTexture, ScaleMode.StretchToFill, false);
        GUI.DrawTextureWithTexCoords(mainViewRect, currCtrl.mainViewTexture, currCtrl.mainViewUVRect, false);
        if (currCtrl.IsShowAxis)
        {
            //GUI.DrawTexture(assistantViewRect, currCtrl.assistantViewTexture, ScaleMode.StretchToFill, true);
            GUI.DrawTextureWithTexCoords(assistantViewRect, currCtrl.assistantViewTexture, currCtrl.assistantViewUVRect, true);
        }
        EditorGUILayout.EndHorizontal();
        c.UpdateLastRect();

        if (!isHandle)
        {
            _HandleInput();
        }

        //主视图大小有变
        if (
            c.LastRect.width != mainViewRect.width ||
            c.LastRect.height != mainViewRect.height
            )
        {
            currCtrl.Resize(c.LastRect);
            c.RequestRepaint();
        }
    }
Example #9
0
 public override bool PreVisit(EditorControl c)
 {
     EditorGUILayout.BeginVertical(c.GetStyle(), c.GetOptions());
     return(true);
 }
Example #10
0
    public override void Visit(EditorControl c)
    {
        currCtrl = c as SelectionGridCtrl;
        if (
            (null == currCtrl) ||
            (null == currCtrl.CurrValue)
            )
        {
            return;
        }

        EditorGUI.BeginDisabledGroup(!currCtrl.Enable);

        lastSelectIndex = (int)currCtrl.CurrValue;

        currCtrl.CurrValue = GUILayout.SelectionGrid((int)currCtrl.CurrValue, currCtrl.DispStr, currCtrl.XCount, c.GetOptions());

        if (lastSelectIndex != (int)currCtrl.CurrValue)
        {
            c.frameTriggerInfo.isValueChanged = true;
        }

        EditorGUI.EndDisabledGroup();

        c.UpdateLastRect();

        CheckInputEvent(c);
    }