public bool RemoveSubview()
 {
     mySubview                  = null;
     myDisplayDelegate          = null;
     myGetSizeToDisplayDelegate = null;
     return(true);
 }
 // ======================================================================
 // DSVerticalLayoutView implementation.
 // ----------------------------------------------------------------------
 void DisplayVerticalLayout(DSView view, Rect displayArea)
 {
     Relayout(displayArea);
     for (int i = 0; i < mySubviews.Count; ++i)
     {
         mySubviews[i].Display(mySubviewFrames[i]);
     }
 }
        // ======================================================================
        // 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));
        }
        Vector2 GetVerticalLayoutSize(DSView view, Rect displayArea)
        {
            Vector2 size = Vector2.zero;

            foreach (var subview in mySubviews)
            {
                var subviewSize = subview.GetSizeToDisplay(displayArea);
                size.x  = Mathf.Max(size.x, subviewSize.x);
                size.y += subviewSize.y;
            }
            return(size);
        }
        public bool RemoveSubview(DSView subview)
        {
            int idx = FindIndexOfSubview(subview);

            if (idx < 0)
            {
                return(false);
            }
            mySubviews.RemoveAt(idx);
            mySubviewFrames.RemoveAt(idx);
            return(true);
        }
        int FindIndexOfSubview(DSView subview)
        {
            int idx = -1;

            for (int i = 0; i < mySubviews.Count; ++i)
            {
                if (mySubviews[i].Subview == subview)
                {
                    idx = i;
                    break;
                }
            }
            return(idx);
        }
        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);
        }
Esempio n. 8
0
 // ======================================================================
 // Subview management
 // ----------------------------------------------------------------------
 public void AddSubview(GUIContent selecionId, DSView subview)
 {
     // Add to selection id array.
     System.Array.Resize(ref mySelectionIds, mySelectionIds.Length + 1);
     mySelectionIds[mySelectionIds.Length - 1] = selecionId;
     // Add to subview array.
     System.Array.Resize(ref mySubviews, mySubviews.Length + 1);
     mySubviews[mySubviews.Length - 1] = subview;
     // Prime first subview.
     if (mySubviews.Length == 1)
     {
         mySelectionIdx = 0;
         AddSwapableSubview(mySelectionIdx);
     }
 }
Esempio n. 9
0
        // ----------------------------------------------------------------------
        public bool RemoveSubview(DSView subview)
        {
            bool found = false;
            int  idx   = 0;

            for (; idx < mySubviews.Length; ++idx)
            {
                if (mySubviews[idx] == subview)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                return(false);
            }
            // Recompute selected subview if it was removed.
            bool needNewSelection = false;

            if (idx == mySelectionIdx)
            {
                RemoveSwapableSubview(mySelectionIdx);
                needNewSelection = true;
            }
            // Cleanup internal information.
            for (int i = idx + 1; i < mySelectionIds.Length; ++i)
            {
                mySelectionIds[i - 1] = mySelectionIds[i];
            }
            System.Array.Resize(ref mySelectionIds, mySelectionIds.Length - 1);
            for (int i = idx + 1; i < mySubviews.Length; ++i)
            {
                mySubviews[i - 1] = mySubviews[i];
            }
            System.Array.Resize(ref mySubviews, mySubviews.Length - 1);
            // Rearrange selection.
            if (needNewSelection)
            {
                if (mySelectionIdx != 0)
                {
                    --mySelectionIdx;
                }
                AddSwapableSubview(mySelectionIdx);
            }
            return(true);
        }
Esempio n. 10
0
 // ======================================================================
 // DSSearchView implementation.
 // ----------------------------------------------------------------------
 void DisplaySearchField(DSView view, Rect displayArea)
 {
     if (mySearchFieldGUIStyle == null)
     {
         mySearchString = GUI.TextField(displayArea, mySearchString);
     }
     else
     {
         mySearchString = GUI.TextField(displayArea, mySearchString, mySearchFieldGUIStyle);
     }
     if (GUI.changed)
     {
         if (mySearchAction != null)
         {
             mySearchAction(this, mySearchString);
         }
     }
 }
Esempio n. 11
0
 Vector2 GetSearchFieldSize(DSView view, Rect displayArea)
 {
     return(mySearchFieldSize);
 }
 public DSTitleView(RectOffset margins, bool shouldDisplayFrame,
                    GUIContent title, AnchorEnum titleAlignment, bool titleSeperator,
                    DSView subview)
     : this(margins, shouldDisplayFrame, title, titleAlignment, titleSeperator,
            (v, f) => { subview.Display(f); },
            (v, f) => { return(subview.GetSizeToDisplay(f)); }) {}
 // ======================================================================
 // Subview management
 // ----------------------------------------------------------------------
 public void SetSubview(DSView subview)
 {
     myDisplayDelegate          = (v, f) => subview.Display(f);
     myGetSizeToDisplayDelegate = (v, f) => subview.GetSizeToDisplay(f);
 }
 public DSCellView(RectOffset margins, bool shouldDisplayFrame, DSView subview)
     : this(margins, shouldDisplayFrame, (v, f) => subview.Display(f), (v, f) => subview.GetSizeToDisplay(f))
 {
     mySubview = subview;
 }
Esempio n. 15
0
 public DSScrollView(RectOffset margins, bool shouldDisplayFrame, bool useFullWidth, bool useFullHeight, DSView subview)
     : this(margins, shouldDisplayFrame, useFullWidth, useFullHeight, (v, f) => subview.Display(f), (v, f) => subview.GetSizeToDisplay(f))
 {
 }