<commit_before>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Graphics.UserInterface;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osuTK;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;

namespace osu.Game.Graphics.UserInterface
{
    public class GradientLineTabControl<TModel> : PageTabControl<TModel>
    {
        protected override Dropdown<TModel> CreateDropdown() => null;

        protected Color4 LineColour
        {
            get => line.MainColour.Value;
            set => line.MainColour.Value = value;
        }

        private readonly GradientLine line;

        public GradientLineTabControl()
        {
            RelativeSizeAxes = Axes.X;

            AddInternal(line = new GradientLine
            {
                Anchor = Anchor.BottomCentre,
                Origin = Anchor.BottomCentre,
            });
        }

        protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
        {
            Anchor = Anchor.BottomCentre,
            Origin = Anchor.BottomCentre,
            AutoSizeAxes = Axes.X,
            RelativeSizeAxes = Axes.Y,
            Direction = FillDirection.Horizontal,
            Spacing = new Vector2(20, 0),
        };

        private class GradientLine : GridContainer
        {
            public readonly Bindable<Color4> MainColour = new Bindable<Color4>();

            private readonly Box left;
            private readonly Box middle;
            private readonly Box right;

            public GradientLine()
            {
                RelativeSizeAxes = Axes.X;
                Size = new Vector2(0.8f, 1.5f);

                ColumnDimensions = new[]
                {
                    new Dimension(),
                    new Dimension(mode: GridSizeMode.Relative, size: 0.4f),
                    new Dimension(),
                };

                Content = new[]
                {
                    new Drawable[]
                    {
                        left = new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                        middle = new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                        right = new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                    }
                };
            }

            protected override void LoadComplete()
            {
                MainColour.BindValueChanged(onColourChanged, true);
                base.LoadComplete();
            }

            private void onColourChanged(ValueChangedEvent<Color4> colour)
            {
                left.Colour = ColourInfo.GradientHorizontal(colour.NewValue.Opacity(0), colour.NewValue);
                middle.Colour = colour.NewValue;
                right.Colour = ColourInfo.GradientHorizontal(colour.NewValue, colour.NewValue.Opacity(0));
            }
        }
    }
}
<commit_msg>Simplify colour usage in GradientLine<commit_after>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Graphics.UserInterface;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osuTK;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Extensions.Color4Extensions;

namespace osu.Game.Graphics.UserInterface
{
    public class GradientLineTabControl<TModel> : PageTabControl<TModel>
    {
        protected override Dropdown<TModel> CreateDropdown() => null;

        protected Color4 LineColour
        {
            get => line.Colour;
            set => line.Colour = value;
        }

        private readonly GradientLine line;

        public GradientLineTabControl()
        {
            RelativeSizeAxes = Axes.X;

            AddInternal(line = new GradientLine
            {
                Anchor = Anchor.BottomCentre,
                Origin = Anchor.BottomCentre,
            });
        }

        protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
        {
            Anchor = Anchor.BottomCentre,
            Origin = Anchor.BottomCentre,
            AutoSizeAxes = Axes.X,
            RelativeSizeAxes = Axes.Y,
            Direction = FillDirection.Horizontal,
            Spacing = new Vector2(20, 0),
        };

        private class GradientLine : GridContainer
        {
            public GradientLine()
            {
                RelativeSizeAxes = Axes.X;
                Size = new Vector2(0.8f, 1.5f);

                ColumnDimensions = new[]
                {
                    new Dimension(),
                    new Dimension(mode: GridSizeMode.Relative, size: 0.4f),
                    new Dimension(),
                };

                Content = new[]
                {
                    new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour = ColourInfo.GradientHorizontal(Color4.White.Opacity(0), Color4.White)
                        },
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour = ColourInfo.GradientHorizontal(Color4.White, Color4.White.Opacity(0))
                        },
                    }
                };
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.07549668874172186, 'fraction_numerical': 0.006125827814569536, 'mean_word_length': 1.3198924731182795, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4438546', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1448, 'n_words': 318}