Example #1
0
        /**
         *
         */
        override protected void UpdateSkinDisplayList()
        {
            if (null == Thumb || null == Track)
            {
                return;
            }

            float trackSize = Track.Width; //getLayoutBoundsWidth();
            float range     = Maximum - Minimum;

            Point thumbPos;
            float thumbPosTrackX = 0;
            float thumbPosParentX;
            float thumbSize = trackSize;

            if (range > 0)
            {
                if (!(bool)GetStyle("fixedThumbSize"))
                {
                    thumbSize = Mathf.Min((PageSize / (range + PageSize)) * trackSize, trackSize);
                    thumbSize = Mathf.Max(Thumb.MinWidth, thumbSize);
                }
                else
                {
                    thumbSize = Thumb.Width;
                }

                // calculate new thumb position.
                thumbPosTrackX = (Value - Minimum) * ((trackSize - thumbSize) / range);
            }

            if (!(bool)GetStyle("fixedThumbSize"))
            {
                Thumb.SetActualSize(thumbSize, Thumb.GetExplicitOrMeasuredHeight()); /*setLayoutBoundsSize*/
            }
            if ((bool)GetStyle("autoThumbVisibility"))
            {
                Thumb.Visible = thumbSize < trackSize;
            }

            // convert thumb position to parent's coordinates.
            thumbPos        = Track.LocalToGlobal(new Point(thumbPosTrackX, 0));
            thumbPosParentX = Thumb.Parent.GlobalToLocal(thumbPos).X;

            //Thumb.setLayoutBoundsPosition(Mathf.Round(thumbPosParentX), Thumb.getLayoutBoundsY());
            //Debug.Log("Moving thumb to " + thumbPosParentX);

            Thumb.Move(Mathf.Round(thumbPosParentX), Thumb.Y);
        }