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

            //if (Id == "test")
            //    Debug.Log("UpdateSkinDisplayList: " + Width + ", " + Height);

            float trackSize = Track.Height; //getLayoutBoundsHeight();
            float range     = Maximum - Minimum;

            float thumbPosTrackY = 0;
            float thumbSize      = trackSize;

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

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

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

            // convert thumb position to parent's coordinates.
            Point thumbPos        = Track.LocalToGlobal(new Point(0, thumbPosTrackY));
            float thumbPosParentY = Thumb.Parent.GlobalToLocal(thumbPos).Y;

            //Debug.Log("Moving thumb to: " + Thumb.X + ", " +  Mathf.Round(thumbPosParentY));

            //Thumb.setLayoutBoundsPosition(Mathf.Round(thumbPosParentX), Thumb.getLayoutBoundsY());
            Thumb.Move(Thumb.X, Mathf.Round(thumbPosParentY));
        }