Beispiel #1
0
        private void OnGUI()
        {
            DrawToolbar();
            if (dragLineDrawer == null)
            {
                dragLineDrawer = new DragLineDrawer(this, DragLineDirection.Vertical);
            }
            Rect cRect = EditorGUILayout.GetControlRect(GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));

            if (cRect != contentRect && cRect.width > 10 && cRect.height > 10)
            {
                contentRect             = cRect;
                dragLineDrawer.Position = new Rect(contentRect.x + 300, contentRect.y, 6, contentRect.height);
            }
            dragLineDrawer.LowLimitXY   = 200;
            dragLineDrawer.UpperLimitXY = contentRect.width * 0.8f;
            dragLineDrawer.OnGUILayout();

            Rect listViewRect = new Rect(contentRect.x, contentRect.y, dragLineDrawer.MinX - contentRect.x, contentRect.height);

            // EGUI.DrawAreaLine(listViewRect, Color.blue);
            GUILayout.BeginArea(listViewRect);
            {
                configListView.OnGUILayout();
            }
            GUILayout.EndArea();

            Rect objectRect = new Rect(dragLineDrawer.MaxX, contentRect.y, contentRect.width - dragLineDrawer.MaxX, contentRect.height);

            //  EGUI.DrawAreaLine(objectRect, Color.yellow);
            GUILayout.BeginArea(objectRect);
            {
                EGUILayout.DrawBoxHeader("Checker", EGUIStyles.BoxedHeaderCenterStyle, GUILayout.ExpandWidth(true));
                checkerDrawer?.OnGUILayout();
            }
            GUILayout.EndArea();
        }
        private void OnGUI()
        {
            if (toolbarDrawer == null)
            {
                BaseData[] datas = new BaseData[]
                {
                    new BaseData(),
                    new BaseData(),
                };
                string[] contents2 = new string[]
                {
                    "BaseData 1",
                    "BaseData 2"
                };

                toolbarDrawer = new ToolbarDrawer()
                {
                    LeftDrawable = new HorizontalLayoutDrawer(new ToolbarButtonDrawer()
                    {
                        Text      = "Open",
                        Tooltip   = "open a new file",
                        OnClicked = () =>
                        {
                            Debug.Log("ToolbarButton->Clicked");
                        }
                    },
                                                              new PopupDrawer <BaseData>()
                    {
                        Values   = datas,
                        Value    = datas[0],
                        Contents = contents2,
                    }),
                    RightDrawable = new HorizontalLayoutDrawer(
                        new ToolbarToggleDrawer()
                    {
                        Text           = "Auto Save",
                        OnValueChanged = (isSelected) =>
                        {
                            Debug.Log("ToolbarToggleDrawer->isSelected = " + isSelected);
                        }
                    },
                        new SearchFieldDrawer()
                    {
                        OnValueChanged = (searchText) =>
                        {
                            Debug.Log("SearchFieldDrawer->searchText = " + searchText);
                        }
                    }),
                };
            }
            toolbarDrawer.OnGUILayout();

            if (listViewDrawer == null)
            {
                listViewDrawer = new EasyListViewDrawer()
                {
                    Text           = "List View",
                    DisplayNames   = (from file in Directory.GetFiles(@"D:\", "*.*", SearchOption.TopDirectoryOnly) select Path.GetFileNameWithoutExtension(file)).ToArray(),
                    Values         = (from file in Directory.GetFiles(@"D:\", "*.*", SearchOption.TopDirectoryOnly) select file).ToArray(),
                    OnValueChanged = (file) =>
                    {
                        selectedFilePath = (string)file;
                    }
                };
            }
            if (dragLineDrawer == null)
            {
                dragLineDrawer = new DragLineDrawer(this, DragLineDirection.Vertical);
            }
            Rect cRect = EditorGUILayout.GetControlRect(GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));

            if (cRect != contentRect && cRect.width > 10 && cRect.height > 10)
            {
                contentRect             = cRect;
                dragLineDrawer.Position = new Rect(contentRect.x + 300, contentRect.y, 6, contentRect.height);
            }
            dragLineDrawer.LowLimitXY   = 200;
            dragLineDrawer.UpperLimitXY = contentRect.width * 0.8f;
            dragLineDrawer.OnGUILayout();

            Rect listViewRect = new Rect(contentRect.x, contentRect.y, dragLineDrawer.MinX - contentRect.x, contentRect.height);

            // EGUI.DrawAreaLine(listViewRect, Color.blue);
            GUILayout.BeginArea(listViewRect);
            {
                listViewDrawer.OnGUILayout();
            }
            GUILayout.EndArea();

            Rect objectRect = new Rect(dragLineDrawer.MaxX, contentRect.y, contentRect.width - dragLineDrawer.MaxX, contentRect.height);

            //  EGUI.DrawAreaLine(objectRect, Color.yellow);
            GUILayout.BeginArea(objectRect);
            {
                if (string.IsNullOrEmpty(selectedFilePath))
                {
                    nativeObject.OnGUILayout();
                }
                else
                {
                    GUILayout.TextField(File.ReadAllText(selectedFilePath), GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
                }
            }
            GUILayout.EndArea();
        }