示例#1
0
        public void TestLifetimeOutwardsPropagation()
        {
            Container          wrapped = null;
            DelayedLoadWrapper wrapper = null;

            AddStep("create child", () =>
            {
                flow.Add(new Container
                {
                    Size     = new Vector2(128),
                    Children = new Drawable[]
                    {
                        wrapper = new DelayedLoadWrapper(wrapped = new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                new TestBox(() => loaded++)
                                {
                                    RelativeSizeAxes = Axes.Both
                                }
                            }
                        }),
                    }
                });

                wrapper.DelayedLoadComplete += content => content.FadeOut(500).Expire();
            });

            AddAssert("wrapper lifetime equals content lifetime", () => wrapper.LifetimeEnd == wrapped.LifetimeEnd);

            AddUntilStep("wrapper expired", () => !wrapper.IsAlive);
        }
示例#2
0
文件: Header.cs 项目: Amryu/osu
        private void updateDisplay()
        {
            title.Text              = BeatmapSet?.Metadata.Title ?? string.Empty;
            artist.Text             = BeatmapSet?.Metadata.Artist ?? string.Empty;
            onlineStatusPill.Status = BeatmapSet?.OnlineInfo.Status ?? BeatmapSetOnlineStatus.None;

            cover?.FadeOut(400, Easing.Out);
            if (BeatmapSet != null)
            {
                downloadButtonsContainer.FadeIn(transition_duration);
                favouriteButton.FadeIn(transition_duration);

                noVideoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 0 : 1, transition_duration);
                videoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 1 : 0, transition_duration);

                coverContainer.Add(cover = new DelayedLoadWrapper(
                                       new BeatmapSetCover(BeatmapSet)
                {
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    RelativeSizeAxes = Axes.Both,
                    FillMode         = FillMode.Fill,
                    OnLoadComplete   = d => d.FadeInFromZero(400, Easing.Out),
                }, 300)
                {
                    RelativeSizeAxes = Axes.Both,
                });
            }
            else
            {
                downloadButtonsContainer.FadeOut(transition_duration);
                favouriteButton.FadeOut(transition_duration);
            }
        }
示例#3
0
        public void TestLifetimeInwardsPropagation()
        {
            Container          wrapped     = null;
            DelayedLoadWrapper wrapper     = null;
            double             lifetimeEnd = 0;

            AddStep("create child", () =>
            {
                flow.Add(new Container
                {
                    Size     = new Vector2(128),
                    Children = new Drawable[]
                    {
                        wrapper = new DelayedLoadWrapper(wrapped = new Container
                        {
                            // this lifetime will be overwritten by the one on the wrapper.
                            LifetimeEnd      = Time.Current + 4000,
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                new TestBox(() => loaded++)
                                {
                                    RelativeSizeAxes = Axes.Both
                                }
                            }
                        })
                        {
                            LifetimeEnd = lifetimeEnd = Time.Current + 2000,
                        }
                    }
                });
            });

            AddUntilStep("wait for load", () => wrapper.DelayedLoadCompleted);

            AddAssert("wrapper lifetime is correct", () => wrapper.LifetimeEnd == lifetimeEnd);
            AddAssert("content lifetime is correct", () => wrapped.LifetimeEnd == lifetimeEnd);

            AddUntilStep("wrapper expired", () => !wrapper.IsAlive);
        }
示例#4
0
            private void load(GameHost host)
            {
                NewsPostBackground bg;

                Child = new DelayedLoadWrapper(bg = new NewsPostBackground(post.FirstImage)
                {
                    RelativeSizeAxes = Axes.Both,
                    FillMode         = FillMode.Fill,
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    Alpha            = 0
                })
                {
                    RelativeSizeAxes = Axes.Both
                };

                bg.OnLoadComplete += d => d.FadeIn(250, Easing.In);

                TooltipText = "view in browser";
                Action      = () => host.OpenUrlExternally("https://osu.ppy.sh/home/news/" + post.Slug);

                HoverColour = Colour4.White;
            }
示例#5
0
        private void load(OverlayColourProvider colours)
        {
            ButtonsContainer = new Container
            {
                Anchor           = Anchor.CentreRight,
                Origin           = Anchor.CentreRight,
                RelativeSizeAxes = Axes.Y,
                AutoSizeAxes     = Axes.X
            };

            InternalChildren = new[]
            {
                // This resolves internal 1px gaps due to applying the (parenting) corner radius and masking across multiple filling background sprites.
                new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = colours.Background5,
                },
                CreateBackground().With(d =>
                {
                    d.RelativeSizeAxes = Axes.Both;
                }),
                wrapper = new DelayedLoadWrapper(() =>
                                                 new Container
                {
                    Name             = @"Room content",
                    RelativeSizeAxes = Axes.Both,
                    // This negative padding resolves 1px gaps between this background and the background above.
                    Padding = new MarginPadding {
                        Left = 20, Vertical = -0.5f
                    },
                    Child = new Container
                    {
                        RelativeSizeAxes = Axes.Both,
                        Masking          = true,
                        CornerRadius     = CORNER_RADIUS,
                        Children         = new Drawable[]
                        {
                            new GridContainer
                            {
                                RelativeSizeAxes = Axes.Both,
                                ColumnDimensions = new[]
                                {
                                    new Dimension(GridSizeMode.Relative, 0.2f)
                                },
                                Content = new[]
                                {
                                    new Drawable[]
                                    {
                                        new Box
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Colour           = colours.Background5,
                                        },
                                        new Box
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Colour           = ColourInfo.GradientHorizontal(colours.Background5, colours.Background5.Opacity(0.3f))
                                        },
                                    }
                                }
                            },
                            new Container
                            {
                                Name             = @"Left details",
                                RelativeSizeAxes = Axes.Both,
                                Padding          = new MarginPadding
                                {
                                    Left     = 20,
                                    Vertical = 5
                                },
                                Children = new Drawable[]
                                {
                                    new FillFlowContainer
                                    {
                                        RelativeSizeAxes = Axes.X,
                                        AutoSizeAxes     = Axes.Y,
                                        Direction        = FillDirection.Vertical,
                                        Children         = new Drawable[]
                                        {
                                            new FillFlowContainer
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Direction    = FillDirection.Horizontal,
                                                Spacing      = new Vector2(5),
                                                Children     = new Drawable[]
                                                {
                                                    new RoomStatusPill
                                                    {
                                                        Anchor = Anchor.CentreLeft,
                                                        Origin = Anchor.CentreLeft
                                                    },
                                                    specialCategoryPill = new RoomSpecialCategoryPill
                                                    {
                                                        Anchor = Anchor.CentreLeft,
                                                        Origin = Anchor.CentreLeft
                                                    },
                                                    endDateInfo = new EndDateInfo
                                                    {
                                                        Anchor = Anchor.CentreLeft,
                                                        Origin = Anchor.CentreLeft,
                                                    },
                                                }
                                            },
                                            new FillFlowContainer
                                            {
                                                RelativeSizeAxes = Axes.X,
                                                AutoSizeAxes     = Axes.Y,
                                                Padding          = new MarginPadding {
                                                    Top = 3
                                                },
                                                Direction = FillDirection.Vertical,
                                                Children  = new Drawable[]
                                                {
                                                    new RoomNameText(),
                                                    new RoomStatusText()
                                                }
                                            }
                                        },
                                    },
                                    new FillFlowContainer
                                    {
                                        Anchor             = Anchor.BottomLeft,
                                        Origin             = Anchor.BottomLeft,
                                        AutoSizeAxes       = Axes.Both,
                                        Direction          = FillDirection.Horizontal,
                                        Spacing            = new Vector2(5),
                                        ChildrenEnumerable = CreateBottomDetails()
                                    }
                                }
                            },
                            new FillFlowContainer
                            {
                                Name             = "Right content",
                                Anchor           = Anchor.CentreRight,
                                Origin           = Anchor.CentreRight,
                                AutoSizeAxes     = Axes.X,
                                RelativeSizeAxes = Axes.Y,
                                Spacing          = new Vector2(5),
                                Padding          = new MarginPadding
                                {
                                    Right    = 10,
                                    Vertical = 20,
                                },
                                Children = new Drawable[]
                                {
                                    ButtonsContainer,
                                    drawableRoomParticipantsList = new DrawableRoomParticipantsList
                                    {
                                        Anchor          = Anchor.CentreRight,
                                        Origin          = Anchor.CentreRight,
                                        NumberOfCircles = NumberOfAvatars
                                    }
                                }
                            },
                            passwordIcon = new PasswordProtectedIcon {
                                Alpha = 0
                            }
                        },
                    },
                }, 0)
                {
                    RelativeSizeAxes = Axes.Both,
                }
            };
        }
示例#6
0
 private void load()
 {
     InternalChild = new DelayedLoadWrapper(CreateImageContainer(url));
 }