internal void SectionDropped(XmlLayoutAccordionSection section)
        {
            if (!allowSectionReordering)
            {
                return;
            }

            var oldIndex = sections.IndexOf(section);

            sections.RemoveAt(oldIndex);

            int newIndex = sectionPlaceholder.rectTransform.GetSiblingIndex();

            if (newIndex > oldIndex)
            {
                newIndex--;
            }

            sections.Insert(newIndex, section);

            XmlLayoutTimer.AtEndOfFrame(() => section.transform.SetSiblingIndex(newIndex), this, true);

            foreach (var s in sections)
            {
                s.content.xmlElement.childElements.First().CanvasGroup.blocksRaycasts = true;
            }

            if (expandSectionAfterReorder)
            {
                ExpandSection(section);
            }
        }
 internal void SectionHeaderClicked(XmlLayoutAccordionSection section)
 {
     if (!section.expanded)
     {
         ExpandSection(section);
     }
     else
     {
         if (collapsible)
         {
             CollapseSection(section);
         }
     }
 }
        public void ExpandSection(XmlLayoutAccordionSection section)
        {
            if (!section.expanded)
            {
                foreach (var sectionToHide in sections)
                {
                    if (section != sectionToHide)
                    {
                        sectionToHide.Collapse();
                    }
                }

                section.Expand();
            }
        }
        internal void SectionDragStart(XmlLayoutAccordionSection draggedSection)
        {
            dragInProgress = true;

            sectionBeingDragged = draggedSection;

            sectionPlaceholder.layoutElement.preferredHeight = 0;
            sectionPlaceholder.gameObject.SetActive(true);

            GrowPlaceholder();

            foreach (var section in sections)
            {
                section.content.xmlElement.childElements.First().CanvasGroup.blocksRaycasts = false;
            }

            sectionBeingDragged.xmlElement.layoutElement.ignoreLayout = true;
        }
        private void Update()
        {
            if (!dragInProgress)
            {
                return;
            }
            if (sectionBeingDragged == null)
            {
                return;
            }
            if (placeHolderAnimationInProgress)
            {
                return;
            }

            sectionBeingDragged.xmlElement.rectTransform.SetAsLastSibling();

            // if the mouse hasn't moved, don't do anything
            if (Mathf.Round(mouseY) == Mathf.Round(Input.mousePosition.y))
            {
                return;
            }
            mouseY = Input.mousePosition.y;

            Vector2 localPoint;

            if (canvas.renderMode == RenderMode.ScreenSpaceOverlay)
            {
                localPoint = rectTransform.InverseTransformPoint(Input.mousePosition);
            }
            else
            {
                RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, canvas.worldCamera ?? Camera.main, out localPoint);
            }

            XmlLayoutAccordionSection closestSection = null;
            float closestDistance         = float.MaxValue;
            float closestDistanceAbsolute = float.MaxValue;

            for (var i = 0; i < sections.Count; i++)
            {
                if (sections[i] == sectionBeingDragged)
                {
                    continue;
                }

                var distance = localPoint.y - sections[i].rectTransform.localPosition.y;
                if (Mathf.Abs(distance) < closestDistanceAbsolute)
                {
                    closestDistance         = distance;
                    closestDistanceAbsolute = Mathf.Abs(closestDistance);
                    closestSection          = sections[i];
                }
            }

            if (closestSection != null)
            {
                var index = sections.IndexOf(closestSection);

                if (sections.IndexOf(sectionBeingDragged) < index)
                {
                    index--;
                }

                if (closestDistance < 0)
                {
                    index++;
                }

                if (placeHolderPosition != index)
                {
                    placeHolderPosition = index;

                    MovePlaceholderToPosition(index);
                }
            }
        }
 public void CollapseSection(XmlLayoutAccordionSection section)
 {
     section.Collapse();
 }