<commit_before>﻿// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Select.Filter;
using Container = osu.Framework.Graphics.Containers.Container;
using osu.Framework.Graphics.UserInterface.Tab;
using osu.Framework.Input;

namespace osu.Game.Screens.Select
{
    public class FilterControl : Container
    {
        public Action FilterChanged;

        public string Search => searchTextBox.Text;

        private OsuTabControl<SortMode> sortTabs;

        TabControl<GroupMode> groupTabs;

        private SortMode sort = SortMode.Title;
        public SortMode Sort
        { 
            get { return sort; } 
            set
            {
                if (sort != value)
                {
                    sort = value;
                    FilterChanged?.Invoke();
                }
            } 
        }

        private GroupMode group = GroupMode.All;
        public GroupMode Group
        {
            get { return group; }
            set
            {
                if (group != value)
                {
                    group = value;
                    FilterChanged?.Invoke();
                }
            }
        }

        public Action Exit;

        private SearchTextBox searchTextBox;

        public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || groupTabs.Contains(screenSpacePos) || sortTabs.Contains(screenSpacePos);

        public FilterControl()
        {
            Children = new Drawable[]
            {
                new Box
                {
                    Colour = Color4.Black,
                    Alpha = 0.8f,
                    RelativeSizeAxes = Axes.Both,
                },
                new Container
                {
                    Padding = new MarginPadding(20),
                    BypassContainsCheck = true,
                    RelativeSizeAxes = Axes.Y,
                    Width = 500,
                    Anchor = Anchor.TopRight,
                    Origin = Anchor.TopRight,
                    Children = new Drawable[]
                    {
                        searchTextBox = new SearchTextBox
                        {
                            RelativeSizeAxes = Axes.X,
                            OnChange = (sender, newText) =>
                            {
                                if (newText)
                                    FilterChanged?.Invoke();
                            },
                            Exit = () => Exit?.Invoke(),
                        },
                        new Box
                        {<commit_msg>Size FilterControl relatively now that we can.<commit_after>﻿// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Select.Filter;
using Container = osu.Framework.Graphics.Containers.Container;
using osu.Framework.Graphics.UserInterface.Tab;
using osu.Framework.Input;

namespace osu.Game.Screens.Select
{
    public class FilterControl : Container
    {
        public Action FilterChanged;

        public string Search => searchTextBox.Text;

        private OsuTabControl<SortMode> sortTabs;

        TabControl<GroupMode> groupTabs;

        private SortMode sort = SortMode.Title;
        public SortMode Sort
        { 
            get { return sort; } 
            set
            {
                if (sort != value)
                {
                    sort = value;
                    FilterChanged?.Invoke();
                }
            } 
        }

        private GroupMode group = GroupMode.All;
        public GroupMode Group
        {
            get { return group; }
            set
            {
                if (group != value)
                {
                    group = value;
                    FilterChanged?.Invoke();
                }
            }
        }

        public Action Exit;

        private SearchTextBox searchTextBox;

        public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || groupTabs.Contains(screenSpacePos) || sortTabs.Contains(screenSpacePos);

        public FilterControl()
        {
            Children = new Drawable[]
            {
                new Box
                {
                    Colour = Color4.Black,
                    Alpha = 0.8f,
                    RelativeSizeAxes = Axes.Both,
                },
                new Container
                {
                    Padding = new MarginPadding(20),
                    BypassContainsCheck = true,
                    RelativeSizeAxes = Axes.Both,
                    Width = 0.5f,
                    Anchor = Anchor.TopRight,
                    Origin = Anchor.TopRight,
                    Children = new Drawable[]
                    {
                        searchTextBox = new SearchTextBox
                        {
                            RelativeSizeAxes = Axes.X,
                            OnChange = (sender, newText) =>
                            {
                                if (newText)
                                    FilterChanged?.Invoke();
                            },
                            Exit = () => Exit?.Invoke(),
                        },
                        new Box
                        {
{'fraction_non_alphanumeric': 0.07724183656555611, 'fraction_numerical': 0.005469915464942815, 'mean_word_length': 1.202993793355239, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2876171', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1384, 'n_words': 316}