예제 #1
0
    private void DrawElementPreview(ControlElement element, int selectionId, bool align)
    {
        if (element == null)
        {
            return;
        }

        if (element.depth != -1)
        {
            bool selected     = element.id == selectionId;
            bool selectresult = selected;
            selectresult = XWinGUI.Control(element, selectresult, align, new GUIContent("Button"), GUI.skin.FindStyle("Button"));

            if (selected != selectresult)
            {
                SetSelection(new List <int>()
                {
                    element.id
                });
            }
        }

        if (element.hasChildren)
        {
            for (int i = 0; i < element.children.Count; i++)
            {
                DrawElementPreview(((ControlElement)element.children[i]), selectionId, align);
            }
        }
    }
예제 #2
0
    public virtual Rect DoGUI(Rect rect, GUIContent title)
    {
        rect = XWinGUI.Panel(rect, resizeLeft, resizeRight, resizeTop, resizeBottom,
                             title, XWinEditorWindow.styles.dragtabdropwindow);

        return(rect);
    }
예제 #3
0
    public override Rect DoGUI(Rect rect, GUIContent title)
    {
        rect = base.DoGUI(rect, title);

        Rect areaRect = new Rect(rect.x + 1, rect.y + 20, rect.width - 2, rect.height - 20);

        var types = System.Enum.GetValues(typeof(ControlType));

        Rect workPanelRect = new Rect(m_WorkPanelRect.x - areaRect.x, m_WorkPanelRect.y - areaRect.y,
                                      m_WorkPanelRect.width, m_WorkPanelRect.height);

        m_ControlsScroller = GUI.BeginScrollView(new Rect(areaRect), m_ControlsScroller,
                                                 new Rect(0, 0, areaRect.width, types.Length * 18));

        for (int i = 0; i < types.Length; i++)
        {
            if (XWinGUI.ControlPreview(new Rect(0, i * 18, areaRect.width, 18), workPanelRect,
                                       new GUIContent(types.GetValue(i).ToString()), XWinEditorWindow.styles.toolbarButton))
            {
                m_Window.AddControl((ControlType)types.GetValue(i),
                                    new Vector2(Event.current.mousePosition.x + areaRect.x - m_WorkPanelRect.x,
                                                Event.current.mousePosition.y + areaRect.y - m_WorkPanelRect.y - 36));
            }
        }

        GUI.EndScrollView();


        //GUILayout.BeginArea(areaRect);

        //m_ControlsScroller = GUILayout.BeginScrollView(m_ControlsScroller);
        //foreach (ControlType type in System.Enum.GetValues(typeof(ControlType)))
        //{
        //    GUILayout.Button("xx", XWinEditorWindow.styles.tagMenuItem);
        //    //if (XWinGUILayout.ControlPreview(workPanelRect,
        //    //    new GUIContent(type.ToString()), XWinEditorWindow.styles.tagMenuItem))
        //    //{
        //    //    m_Window.AddControl(type, Event.current.mousePosition);
        //    //}
        //}
        //GUILayout.EndScrollView();

        //GUILayout.EndArea();

        return(rect);
    }
예제 #4
0
    public static bool ControlPreview(Rect panelRect, GUIContent content, GUIStyle style, params GUILayoutOption[] opts)
    {
        Rect position = GUILayoutUtility.GetRect(GUIContent.none, style, opts);

        return(XWinGUI.ControlPreview(position, panelRect, content, style));
    }