예제 #1
0
        private CGRect ComputeFrame(ArrowPosition position, CGRect refFrame, CGRect superview)
        {
            nfloat xOrigin = 0, yOrigin = 0;

            switch (position)
            {
            case ArrowPosition.Top:
            case ArrowPosition.Any:

                xOrigin = refFrame.GetCenter().X - this.ContentSize.Width / 2;
                yOrigin = refFrame.Y + refFrame.Height;

                break;

            case ArrowPosition.Bottom:

                xOrigin = refFrame.GetCenter().X - this.ContentSize.Width / 2;
                yOrigin = refFrame.Y - this.ContentSize.Height;

                break;

            case ArrowPosition.Right:

                xOrigin = refFrame.X - this.ContentSize.Width;
                yOrigin = refFrame.GetCenter().Y - this.ContentSize.Height / 2;

                break;

            case ArrowPosition.Left:

                xOrigin = refFrame.X + refFrame.Width;
                yOrigin = refFrame.Y - this.ContentSize.Height / 2;

                break;
            }

            var frame = new CGRect(xOrigin, yOrigin, this.ContentSize.Width, this.ContentSize.Height);

            this.AdjustFrame(ref frame, superview);

            return(frame);
        }
예제 #2
0
            void LayoutPortrait()
            {
                var  bounds    = Bounds;
                bool showVideo = songId == Settings.CurrentSong && Settings.CurrentPlaybackIsVideo;
                var  maxWidth  = NMath.Max(200, NMath.Min(bounds.Width, 512));
                var  topHeight = NowPlayingViewController.Current.GetCurrentTopHeight();
                var  frame     = new CGRect((bounds.Width - maxWidth) / 2, topHeight + NowPlayingViewController.StatusBarHeight, maxWidth, maxWidth);

                albumArtImageView.Frame = frame;
                if (TopHeight > 0)
                {
                    var top = topHeight + NowPlayingViewController.StatusBarHeight;
                    albumArtImageView.Center = new CGPoint(bounds.Width / 2, top + (TopHeight - top) / 2);
                }
                albumArtImageView.Alpha = showVideo ? Math.Max(0, 1 - (float)currentPercent) : 1;
                frame = bounds;
                var size = (float)Math.Max(frame.Height, frame.Width);

                size       *= 1.35f;
                frame.Width = frame.Height = size;
                backgroundImageView.Frame  = frame;
                backgroundImageView.Center = albumArtImageView.Center;

                var videoFrame = new CGRect(padding, padding, 160, 90);

                videoFrame.Width += (bounds.Width - videoFrame.Width) * currentPercent;
                videoFrame.X     -= currentPercent * padding;
                videoFrame.Height = videoFrame.Width * widthRatio;
                videoFrame.Y      = NMath.Max((topHeight + (videoFrame.Height / 2)) * currentPercent, padding);
                frame.X           = padding;
                frame.Height      = topHeight;
                var w = showVideo ? 160 : NowPlayingViewController.AlbumArtWidth;

                frame.Width = w + padding;
                smallArtImageView.Center = frame.GetCenter();
                smallArtImageView.Hidden = showVideo;

                videoView.Frame  = showVideo ? videoFrame : frame;
                videoView.Hidden = !showVideo;
                if (isVisible)
                {
                    videoView.Show();
                }
                frame.X         = frame.Right;
                frame.Width     = bounds.Width - frame.X - buttonWidth - (padding * 2);
                labelView.Frame = frame;
            }
예제 #3
0
            void LayoutLandscape()
            {
                var  bounds    = Bounds;
                bool showVideo = songId == Settings.CurrentSong && Settings.CurrentPlaybackIsVideo;
                //Console.WriteLine($"{showVideo} {songId} - {Settings.CurrentSong} - {Settings.CurrentPlaybackIsVideo}");
                var topHeight = NowPlayingViewController.Current.GetCurrentTopHeight();
                var maxWidth  = NMath.Min(bounds.Height - landscapeArtPadding * 2 - topHeight, 512);
                var frame     = new CGRect(landscapeArtPadding, topHeight + landscapeArtPadding, maxWidth, maxWidth);

                albumArtImageView.Frame = frame;

                albumArtImageView.Alpha = showVideo ? Math.Max(0, 1 - (float)currentPercent) : 1;
                frame = bounds;
                var size = (float)Math.Max(bounds.Height, bounds.Width);

                size       *= 2f;
                frame.Width = frame.Height = size;
                backgroundImageView.Frame  = frame;
                backgroundImageView.Center = albumArtImageView.Center;

                var videoFrame = new CGRect(padding, padding, 78, 44);

                videoFrame.Width += (maxWidth - videoFrame.Width) * currentPercent;
                videoFrame.X     -= currentPercent * padding;
                videoFrame.Height = videoFrame.Width * widthRatio;
                videoFrame.Y      = NMath.Max((topHeight + (videoFrame.Height / 2)) * currentPercent, padding);

                frame.X      = padding;
                frame.Height = topHeight;
                var w = showVideo ? 160 : NowPlayingViewController.AlbumArtWidth;

                frame.Width = w + padding;
                smallArtImageView.Center = frame.GetCenter();
                smallArtImageView.Hidden = showVideo;

                videoView.Frame  = showVideo ? videoFrame : frame;
                videoView.Hidden = !showVideo;
                if (isVisible)
                {
                    videoView.Show();
                }
                frame.X         = frame.Right;
                frame.Width     = bounds.Width - frame.X - buttonWidth - (padding * 2);
                labelView.Frame = frame;
            }
예제 #4
0
                void LayoutLandscape()
                {
                    var bounds = Bounds;

                    bounds.Height -= BottomOffset;
                    slider.SizeToFit();
                    var frame = slider.Frame;

                    frame.X      = frame.Y = 0;
                    frame.Y      = (frame.Height / 2 + 1) * -1;
                    frame.Width  = bounds.Width;
                    slider.Frame = frame;

                    var y = frame.Bottom - 10;

                    frame           = timeLabel.Frame;
                    frame.X         = padding;
                    frame.Y         = y;
                    timeLabel.Frame = frame;

                    frame.X = bounds.Width - frame.Width - padding;
                    remainingTimeLabel.Frame = frame;

                    y = frame.Bottom;

                    var height = bounds.Height - y;
                    var fourth = height / 4 - padding;

                    y -= smallPadding;
                    var contentWidth = bounds.Width - ContentStart;

                    backgroundBluredView.Frame = CGRect.Empty;
                    frame           = new CGRect(ContentStart + padding, y, contentWidth - 2 * padding, fourth);
                    labelView.Frame = frame;

                    frame.Y = frame.Bottom + padding + padding;

                    var center = frame.GetCenter();

                    playButton.Center = center;

                    const float centerDiff = 65;

                    center.X -= centerDiff;
                    previousButton.Center = center;
                    center.X -= centerDiff;

                    thumbsDownButton.Center = center;

                    center    = playButton.Center;
                    center.X += centerDiff;

                    nextButton.Center = center;
                    center.X         += centerDiff;

                    thumbsUpButton.Center = center;

                    frame.Y += fourth + padding * 2;

                    center = frame.GetCenter();

                    y = frame.Bottom + padding;

                    //Volume views have sizing issues.  Let them choose their own heights
                    volumeView.SizeToFit();
                    frame.Height      = volumeView.Frame.Height;
                    volumeView.Frame  = frame;
                    volumeView.Center = center;

                    frame.Height = fourth;
                    frame.Y      = y - 44;


                    center = frame.GetCenter();
                    var x       = center.X = ContentStart;
                    var right   = bounds.Width - 20;
                    var spacing = (right - x) / 3;

                    shareButton.Center = center;
                    center.X          += spacing;

                    shuffleButton.Center = center;

                    center.X           += spacing;
                    repeatButton.Center = center;

                    center.X          = right;
                    menuButton.Center = center;
                }
예제 #5
0
                public void LayoutPortrait()
                {
                    var bounds = Bounds;

                    bounds.Height -= BottomOffset;
                    backgroundBluredView.Frame = bounds.WithHeight(bounds.Height * 2);
                    slider.SizeToFit();
                    var frame = slider.Frame;

                    frame.X      = frame.Y = 0;
                    frame.Y      = (frame.Height / 2 + 1) * -1;
                    frame.Width  = bounds.Width;
                    slider.Frame = frame;

                    var y = frame.Bottom;

                    frame           = timeLabel.Frame;
                    frame.X         = padding;
                    frame.Y         = y;
                    timeLabel.Frame = frame;

                    frame.X = bounds.Width - frame.Width - padding;
                    remainingTimeLabel.Frame = frame;

                    y = frame.Bottom;

                    var height = bounds.Height - y;
                    var fourth = height / 4 - padding;

                    y -= padding;

                    var offset = MaxHeight - Frame.Height;

                    frame           = new CGRect(padding, y + offset, bounds.Width - 2 * padding, fourth);
                    labelView.Frame = frame;

                    y = frame.Bottom;
                    var frameTop = frame.Top;

                    frame.Y = y - offset - frame.Height;
                    if (frame.Bottom > frameTop)
                    {
                        frame.Y += frame.Bottom - frameTop;
                    }
                    var center = frame.GetCenter();

                    playButton.Center = center;

                    const float centerDiff = 65;

                    center.X -= centerDiff;
                    previousButton.Center = center;
                    center.X -= centerDiff;

                    thumbsDownButton.Center = center;

                    center    = playButton.Center;
                    center.X += centerDiff;

                    nextButton.Center = center;
                    center.X         += centerDiff;

                    thumbsUpButton.Center = center;

                    frame.Y += fourth + padding;

                    center = frame.GetCenter();

                    y = frame.Bottom;

                    //Volume views have sizing issues.  Let them choose their own heights
                    volumeView.SizeToFit();
                    frame.Height      = volumeView.Frame.Height;
                    volumeView.Frame  = frame;
                    volumeView.Center = center;

                    frame.Height = fourth;
                    frame.Y      = y + padding * 2 + smallPadding;



                    center = frame.GetCenter();
                    var x       = center.X = 20;
                    var right   = bounds.Width - 20;
                    var spacing = (right - x) / 3;

                    shareButton.Center = center;
                    center.X          += spacing;

                    shuffleButton.Center = center;

                    center.X           += spacing;
                    repeatButton.Center = center;

                    center.X          = right;
                    menuButton.Center = center;
                }