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

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using OpenTK;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics;
using osu.Framework.Lists;

namespace osu.Framework.Graphics.Containers
{
    /// <summary>
    /// A drawable which can have children added externally.
    /// </summary>
    public class Container : Drawable
    {
        public bool Masking;

        protected override DrawNode BaseDrawNode => new ContainerDrawNode(DrawInfo, Masking ? ScreenSpaceDrawQuad.BoundingRectangle : (Rectangle?)null);

        public new virtual Drawable Add(Drawable drawable)
        {
            return base.Add(drawable);
        }

        public new void Add(IEnumerable<Drawable> drawables)
        {
            base.Add(drawables);
        }

        public new virtual bool Remove(Drawable drawable, bool dispose = true)
        {
            return base.Remove(drawable, dispose);
        }

        public new void Remove(IEnumerable<Drawable> drawables, bool dispose = true)
        {
            base.Remove(drawables);
        }

        public int RemoveAll(Predicate<Drawable> match)
        {
            return base.RemoveAll(match);
        }

        public new virtual void Clear(bool dispose = true)
        {
            base.Clear(dispose);
        }

        /// <summary>
        /// Scale which is only applied to Children.
        /// </summary>
        public new Vector2 ContentScale
        {
            get { return base.ContentScale; }
            set { base.ContentScale = value; }
        }

        public ReadOnlyList<Drawable> Children => base.Children;
    }
}<commit_msg>Add setter to Container to allow for delayed adding of children (and make constructing drawable trees more elegant).<commit_after>﻿//Copyright (c) 2007-2016 ppy Pty Ltd <<EMAIL>>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using OpenTK;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics;
using osu.Framework.Lists;

namespace osu.Framework.Graphics.Containers
{
    /// <summary>
    /// A drawable which can have children added externally.
    /// </summary>
    public class Container : Drawable
    {
        public bool Masking;

        protected override DrawNode BaseDrawNode => new ContainerDrawNode(DrawInfo, Masking ? ScreenSpaceDrawQuad.BoundingRectangle : (Rectangle?)null);

        public new virtual Drawable Add(Drawable drawable)
        {
            return base.Add(drawable);
        }

        public new void Add(IEnumerable<Drawable> drawables)
        {
            base.Add(drawables);
        }

        public new virtual bool Remove(Drawable drawable, bool dispose = true)
        {
            return base.Remove(drawable, dispose);
        }

        public new void Remove(IEnumerable<Drawable> drawables, bool dispose = true)
        {
            base.Remove(drawables);
        }

        public int RemoveAll(Predicate<Drawable> match)
        {
            return base.RemoveAll(match);
        }

        public new virtual void Clear(bool dispose = true)
        {
            base.Clear(dispose);
        }

        /// <summary>
        /// Scale which is only applied to Children.
        /// </summary>
        public new Vector2 ContentScale
        {
            get { return base.ContentScale; }
            set { base.ContentScale = value; }
        }

        public ReadOnlyList<Drawable> Children => base.Children;

        public IEnumerable<Drawable> Kids //todo: think of a better name
        {
            set
            {
                if (!IsLoaded)
                    pendingChildren = value;
                else
                {
                    Clear();
                    Add(value);
                }
            }
        }

        private IEnumerable<Drawable> pendingChildren;

        public override void Load()
        {
            base.Load();

            if (pendingChildren != null)
            {
                Add(pendingChildren);
                pendingChildren = null;
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08987485779294653, 'fraction_numerical': 0.004095563139931741, 'mean_word_length': 1.8997361477572559, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 29, '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': '4144623', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1117, 'n_words': 306}