// ----------------------------------------------------------------------
        void DisplayColumnData()
        {
            Rect dataArea = new Rect(-myScrollbarPosition.x, -myScrollbarPosition.y, myColumnDataSize.x, myColumnDataSize.y);

            // Display column frames.
            if (myDisplayColumnFrame)
            {
                float x = dataArea.x;
                foreach (var column in myColumns)
                {
                    GUI.Box(new Rect(x, dataArea.y, column.DataSize.x, dataArea.height), "");
                    x += column.DataSize.x;
                }
            }
            // Display column data.
            float y = dataArea.y;

            for (int row = 0; row < myRowHeights.Length; ++row)
            {
                float x = dataArea.x;
                foreach (var column in myColumns)
                {
                    Rect    displayRect = new Rect(x + column.Margins.left, y + column.Margins.top, column.DataSize.x - column.Margins.horizontal, myRowHeights[row] - column.Margins.vertical);
                    Vector2 dataSize    = myDataSource.LayoutSizeForObjectInTableView(this, column, row);
                    displayRect = DSCellView.PerformAlignment(displayRect, dataSize, column.Anchor);
                    myDataSource.DisplayObjectInTableView(this, column, row, displayRect);
                    x += column.DataSize.x;
                }
                y += myRowHeights[row];
            }
        }
        // ======================================================================
        // TitleSubview implementation.
        // ----------------------------------------------------------------------
        void TitleViewDisplay(DSCellView view, Rect displayArea)
        {
            // Just return if we have nothing to display.
            if (myTitle == null || Math3D.IsZero(myTitleSize.x))
            {
                return;
            }
            // Display title.
            GUI.Label(displayArea, Title, TitleGUIStyle);
            // Display title separator.
            if (!myTitleSeperator)
            {
                return;
            }
            float y             = myTitleArea.y + myTitleSize.y;
            Rect  seperatorRect = new Rect(myTitleArea.x, y, myTitleArea.width, 3f);

            if (mySeperatorGUIStyle != null)
            {
                GUI.Box(seperatorRect, "", mySeperatorGUIStyle);
            }
            else
            {
                GUI.Box(seperatorRect, "");
            }
        }
        // ----------------------------------------------------------------------
        void DisplayColumnTitles()
        {
            Rect titleArea = new Rect(-myScrollbarPosition.x, 0, myColumnTitleSize.x, myColumnTitleSize.y);

            foreach (var column in myColumns)
            {
                Rect titleFrameArea = titleArea;
                titleFrameArea.width = column.DataSize.x;
                Rect columnTitleArea = titleFrameArea;
                columnTitleArea.x      += column.Margins.left;
                columnTitleArea.width  -= column.Margins.horizontal;
                columnTitleArea.y      += column.Margins.top;
                columnTitleArea.height -= column.Margins.vertical;
                if (column.Title != null)
                {
                    Rect titleDisplayArea = DSCellView.PerformAlignment(columnTitleArea, ColumnTitleGUIStyle.CalcSize(column.Title), column.Anchor);
                    if (myDisplayColumnFrame)
                    {
                        GUI.Box(titleFrameArea, "");
                    }
                    GUI.Label(titleDisplayArea, column.Title, ColumnTitleGUIStyle);
                }
                titleArea.x     += column.DataSize.x;
                titleArea.width -= column.DataSize.x;
            }
        }
示例#4
0
 void DisplaySelection(DSCellView view, Rect position)
 {
     if (mySelectionIds.Length < 1)
     {
         return;
     }
     mySelectionIdx = GUI.SelectionGrid(position, mySelectionIdx, mySelectionIds, SelectionsPerLine);
 }
示例#5
0
 // ======================================================================
 // Initialization
 // ----------------------------------------------------------------------
 public DSSearchView(RectOffset margins, bool shouldDisplayFrame,
                     int nbOfVisibleCharInSearch, Action <DSSearchView, string> searchAction)
 {
     myCellView                = new DSCellView(margins, shouldDisplayFrame, DisplaySearchField, GetSearchFieldSize);
     mySearchAction            = searchAction;
     myNbOfVisibleCharInSearch = nbOfVisibleCharInSearch;
     ComputeSearchFieldSize();
 }
        // ======================================================================
        // Subview management
        // ----------------------------------------------------------------------
        public void AddSubview(DSView subview, RectOffset margins, DSView.AnchorEnum alignment = DSView.AnchorEnum.TopLeft)
        {
            DSCellView container = new DSCellView(margins, false, subview);

            container.Anchor = alignment;
            mySubviews.Add(container);
            mySubviewFrames.Add(new Rect(0, 0, 0, 0));
        }
示例#7
0
        // ======================================================================
        // Initialization
        // ----------------------------------------------------------------------
        public DSAccordionView(RectOffset margins, bool shouldDisplayFrame, int selectionsPerLine = 1)
        {
            mySelectionsPerLine = selectionsPerLine;
            mySelectionIds      = new GUIContent[0];
            mySubviews          = new DSView[0];

            myMainView      = new DSVerticalLayoutView(margins, shouldDisplayFrame);
            mySelectionView = new DSCellView(new RectOffset(0, 0, 0, 0), false, DisplaySelection, GetSelectionSize);
            myMainView.AddSubview(mySelectionView, new RectOffset(0, 0, kSpacer, 0));
        }
示例#8
0
 // ======================================================================
 // Initialization
 // ----------------------------------------------------------------------
 public DSScrollView(RectOffset margins, bool shouldDisplayFrame, bool useFullWidth = true, bool useFullHeight = true,
                     Action <DSScrollView, Rect> displayDelegate = null,
                     Func <DSScrollView, Rect, Vector2> getSizeToDisplayDelegate = null)
 {
     myUseFullWidth             = useFullWidth;
     myUseFullHeight            = useFullHeight;
     myMainView                 = new DSCellView(margins, shouldDisplayFrame, MainViewDisplay, MainViewGetSizeToDisplay);
     myDisplayDelegate          = displayDelegate;
     myGetSizeToDisplayDelegate = getSizeToDisplayDelegate;
 }
示例#9
0
 // ---------------------------------------------------------------------------------
 bool IsInitialized()
 {
     // Update main view if selection has changed.
     if (myMainView == null || myController == null)
     {
         myController = new iCS_PropertyController(vsObject, vsObject.IStorage);
         myMainView   = new DSCellView(new RectOffset(0, 0, kSpacer, 0), true, myController.View);
         ResizeToFit();
         ResizeToFit();
     }
     return(true);
 }
        // ======================================================================
        // MainView implementation.
        // ----------------------------------------------------------------------
        void MainViewDisplay(DSCellView view, Rect displayArea)
        {
            float titleHeight = TitleAreaHeight();
            float bodyHeight  = displayArea.height - titleHeight;

            if (titleHeight >= displayArea.height)
            {
                titleHeight = displayArea.height;
                bodyHeight  = 0;
            }
            myTitleArea = new Rect(displayArea.x, displayArea.y, displayArea.width, titleHeight);
            myTitleSubview.Display(myTitleArea);
            InvokeDisplayDelegate(new Rect(displayArea.x, displayArea.y + titleHeight, displayArea.width, bodyHeight));
        }
        public bool ReplaceSubview(DSView toRemove, DSView bySubview, RectOffset margins, DSView.AnchorEnum alignment = DSView.AnchorEnum.TopLeft)
        {
            int idx = FindIndexOfSubview(toRemove);

            if (idx < 0)
            {
                return(false);
            }
            DSCellView container = new DSCellView(margins, false, bySubview);

            container.Anchor     = alignment;
            mySubviews[idx]      = container;
            mySubviewFrames[idx] = new Rect(0, 0, 0, 0);
            return(true);
        }
 // ======================================================================
 // Initialization
 // ----------------------------------------------------------------------
 public DSTitleView(RectOffset margins, bool shouldDisplayFrame,
                    GUIContent title, AnchorEnum titleAlignment, bool titleSeperator,
                    Action <DSTitleView, Rect> displayDelegate = null,
                    Func <DSTitleView, Rect, Vector2> getSizeToDisplayDelegate = null)
 {
     // Create subviews
     myMainView     = new DSCellView(margins, shouldDisplayFrame, MainViewDisplay, MainViewGetSizeToDisplay);
     myTitleSubview = new DSCellView(new RectOffset(0, 0, 0, 0), false, TitleViewDisplay, TitleViewGetSizeToDisplay);
     // initialize title related information.
     Title                      = title;
     TitleAlignment             = titleAlignment;
     TitleSeperator             = titleSeperator;
     myDisplayDelegate          = displayDelegate;
     myGetSizeToDisplayDelegate = getSizeToDisplayDelegate;
 }
示例#13
0
 Vector2 MainViewGetSizeToDisplay(DSCellView view, Rect displayArea)
 {
     myContentSize  = InvokeGetSizeToDisplayDelegate(displayArea);
     myIsHScrollbar = false;
     myIsVScrollbar = false;
     if (myContentSize.x > displayArea.width)
     {
         myIsHScrollbar = true;
     }
     if (myContentSize.y > displayArea.height)
     {
         myIsVScrollbar = true;
     }
     if (myIsVScrollbar && myContentSize.x > displayArea.width - kScrollbarSize)
     {
         myIsHScrollbar = true;
     }
     if (myIsHScrollbar && myContentSize.y > displayArea.height - kScrollbarSize)
     {
         myIsVScrollbar = true;
     }
     if (myIsVScrollbar && myContentSize.x > displayArea.width - kScrollbarSize)
     {
         myIsHScrollbar = true;
     }
     if (myIsHScrollbar && myContentSize.y > displayArea.height - kScrollbarSize)
     {
         myIsVScrollbar = true;
     }
     myContentSizeWithScrollbars = myContentSize;
     if (myIsVScrollbar)
     {
         myContentSizeWithScrollbars.x += kScrollbarSize;
     }
     if (myIsHScrollbar)
     {
         myContentSizeWithScrollbars.y += kScrollbarSize;
     }
     if (myUseFullWidth && myContentSizeWithScrollbars.x < displayArea.width)
     {
         myContentSizeWithScrollbars.x = displayArea.width;
     }
     if (myUseFullHeight && myContentSizeWithScrollbars.y < displayArea.height)
     {
         myContentSizeWithScrollbars.y = displayArea.height;
     }
     return(myContentSizeWithScrollbars);
 }
示例#14
0
 // ======================================================================
 // Initialization
 // ----------------------------------------------------------------------
 public DSTreeView(RectOffset margin, bool shouldDisplayFrame, DSTreeViewDataSource dataSource, float indentOffset = kHorizontalSpacer, int nbOfFoldDictionaries = 1)
 {
     myMainView     = new DSCellView(margin, shouldDisplayFrame);
     myDataSource   = dataSource;
     myIndentOffset = indentOffset;
     if (nbOfFoldDictionaries < 1)
     {
         nbOfFoldDictionaries = 1;
     }
     myIsFoldedDictionaries = new List <Dictionary <object, bool> >();
     for (int i = 0; i < nbOfFoldDictionaries; ++i)
     {
         myIsFoldedDictionaries.Add(new Dictionary <object, bool>());
     }
     myRowInfo = new Dictionary <object, Rect>();
 }
        Vector2 MainViewGetSizeToDisplay(DSCellView view, Rect displayArea)
        {
            // Adjust display area to remove title area.
            float titleAreaHeight = TitleAreaHeight();

            displayArea.y      += titleAreaHeight;
            displayArea.height -= titleAreaHeight; if (displayArea.height < 0)
            {
                displayArea.height = 0;
            }
            // Now compute using content size.
            var   contentSize = InvokeGetSizeToDisplayDelegate(displayArea);
            float width       = Mathf.Max(contentSize.x, myTitleSize.x);
            float height      = contentSize.y + titleAreaHeight;

            return(new Vector2(width, height));
        }
示例#16
0
        // ======================================================================
        // Selection view implementation.
        // ----------------------------------------------------------------------
        Vector2 GetSelectionSize(DSCellView view, Rect displaySize)
        {
            float width  = 0;
            float height = 0;

            foreach (var selection in mySelectionIds)
            {
                var sSize = GUI.skin.button.CalcSize(selection);
                if (sSize.x > width)
                {
                    width = sSize.x;
                }
                if (sSize.y > height)
                {
                    height = sSize.y;
                }
            }
            return(new Vector2((width + kSpacer) * mySelectionsPerLine, height * ((mySelectionsPerLine + mySelectionsPerLine - 1) / mySelectionsPerLine)));
        }
 // ======================================================================
 // Initialization
 // ----------------------------------------------------------------------
 public DSVerticalLayoutView(RectOffset margins, bool shouldDisplayFrame = true)
 {
     myMainView      = new DSCellView(margins, shouldDisplayFrame, DisplayVerticalLayout, GetVerticalLayoutSize);
     mySubviews      = new List <DSCellView>();
     mySubviewFrames = new List <Rect>();
 }
示例#18
0
 // ======================================================================
 // MainView implementation.
 // ----------------------------------------------------------------------
 void MainViewDisplay(DSCellView view, Rect displayArea)
 {
     myScrollPosition = GUI.BeginScrollView(displayArea, myScrollPosition, ContentArea, false, false);
     InvokeDisplayDelegate(ContentAreaWithScrollbars);
     GUI.EndScrollView();
 }
 Vector2 TitleViewGetSizeToDisplay(DSCellView view, Rect displayArea)
 {
     return(new Vector2(myTitleSize.x, TitleAreaHeight()));
 }