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

using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;

namespace osu.Game.Tests.Visual
{
    internal class TestCaseContextMenu : OsuTestCase
    {
        public override string Description => @"Menu visible on right click";

        private const int start_time = 0;
        private const int duration = 1000;

        private readonly Container container;

        public TestCaseContextMenu()
        {
            Add(container = new MyContextMenuContainer
            {
                Size = new Vector2(200),
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Children = new Drawable[]
                {
                    new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour = Color4.Green,
                    }
                }
            });

            Add(new AnotherContextMenuContainer
            {
                Size = new Vector2(200),
                Anchor = Anchor.CentreLeft,
                Origin = Anchor.CentreLeft,
                Children = new Drawable[]
                {
                    new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour = Color4.Red,
                    }
                }
            });
        }

        protected override void LoadComplete()
        {
            base.LoadComplete();

            // Move box along a square trajectory
            container.Loop(c => c
                .MoveTo(new Vector2(0, 100), duration).Then()
                .MoveTo(new Vector2(100, 100), duration).Then()
                .MoveTo(new Vector2(100, 0), duration).Then()
                .MoveTo(Vector2.Zero, duration)
            );
        }

        private class MyContextMenuContainer : Container, IHasContextMenu
        {
            public MenuItem[] ContextMenuItems => new MenuItem[]
            {
                new OsuMenuItem(@"Some option"),
                new OsuMenuItem(@"Highlighted option", MenuItemType.Highlighted),
                new OsuMenuItem(@"Another option"),
                new OsuMenuItem(@"Choose me please"),
                new OsuMenuItem(@"And me too"),
                new OsuMenuItem(@"Trying to fill"),<commit_msg>Fix TestCaseContextMenu not being updated inline with previous changes<commit_after>﻿// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;
using osu.Game.Graphics.Cursor;

namespace osu.Game.Tests.Visual
{
    internal class TestCaseContextMenu : OsuTestCase
    {
        public override string Description => @"Menu visible on right click";

        private const int start_time = 0;
        private const int duration = 1000;

        private readonly Container container;

        public TestCaseContextMenu()
        {
            Add(new OsuContextMenuContainer
            {
                RelativeSizeAxes = Axes.Both,
                Children = new Drawable[]
                {
                    container = new MyContextMenuContainer
                    {
                        Size = new Vector2(200),
                        Anchor = Anchor.Centre,
                        Origin = Anchor.Centre,
                        Child = new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour = Color4.Green,
                        }
                    },
                    new AnotherContextMenuContainer
                    {
                        Size = new Vector2(200),
                        Anchor = Anchor.CentreLeft,
                        Origin = Anchor.CentreLeft,
                        Child = new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour = Color4.Red,
                        }
                    }
                }
            });
        }

        protected override void LoadComplete()
        {
            base.LoadComplete();

            // Move box along a square trajectory
            container.Loop(c => c
                .MoveTo(new Vector2(0, 100), duration).Then()
                .MoveTo(new Vector2(100, 100), duration).Then()
                .MoveTo(new Vector2(100, 0), duration).Then()
                .MoveTo(Vector2.Zero, duration)
            );
        }

        private class MyContextMenuContainer : Container, IHasContextMenu
        {
            public MenuItem[] ContextMenuItems => new MenuItem[]
            {
                new OsuMenuItem(@"Some option"),
                new OsuMenuItem(@"Highlighted option", MenuItemType.Highlighted),
                new OsuMenuItem(@"Another option"),
                new OsuMenuItem(@"Choose me please"),
                new OsuMenuItem(@"And me too"),
                new OsuMenuItem(@"Trying to fill"),
{'fraction_non_alphanumeric': 0.0828996949578324, 'fraction_numerical': 0.014713798672169388, 'mean_word_length': 1.3994834266035299, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '7649813', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1284, 'n_words': 326}