示例#1
0
 public bool Remove(UITransform transform)
 {
     lock (SyncRoot)
     {
         return(RemoveInternal(transform));
     }
 }
示例#2
0
 public void Add(UITransform transform)
 {
     transform.Manager = this;
     Transforms.Add(transform);
     transform.OnMarkedDirty += Transform_MarkedDirty;
     FlagForSort();
 }
示例#3
0
 public void Add(UITransform transform)
 {
     _transforms.Add(transform);
     transform.Container      = this;
     transform.OnMarkedDirty += Transform_MarkedDirty;
     _boundsNeedUpdate        = true;
 }
示例#4
0
 private void Transform_MarkedDirty(UITransform transform, DirtMarkType type)
 {
     if (type.HasFlags(DirtMarkType.DrawOrder))
     {
         FlagForSort();
     }
 }
示例#5
0
 private void Transform_MarkedDirty(UITransform transform, DirtMarkType marks)
 {
     if (marks.HasFlags(DirtMarkType.Boundaries, DirtMarkType.Enabled))
     {
         _boundsNeedUpdate = true;
     }
 }
示例#6
0
 public void Add(UITransform transform)
 {
     lock (SyncRoot)
     {
         AddInternal(transform);
         _needsBoundsUpdate = true;
     }
 }
示例#7
0
 public void Add(UITransform transform)
 {
     lock (SyncRoot)
     {
         Transforms.Add(transform);
         transform.MarkedDirty += Transform_MarkedDirty;
         FlagForSort();
     }
 }
示例#8
0
 private void AddInternal(UITransform transform)
 {
     _transforms.Add(transform);
     lock (transform.SyncRoot)
     {
         transform.SetContainer(this);
         transform.MarkedDirty += Transform_MarkedDirty;
     }
 }
示例#9
0
        public bool Remove(UITransform transform)
        {
            int index = Transforms.FindIndex((x) => x == transform);

            if (index != -1)
            {
                Transforms.GetAndRemoveAt(index).OnMarkedDirty -= Transform_MarkedDirty;
                return(true);
            }
            return(false);
        }
示例#10
0
        public bool Remove(UITransform transform)
        {
            if (transform.Container == this)
            {
                transform.Container = null;
            }
            transform.OnMarkedDirty -= Transform_MarkedDirty;

            _transforms.Remove(transform);
            _boundsNeedUpdate = true;
            return(false);
        }
示例#11
0
        internal bool RemoveInternal(UITransform transform)
        {
            int index = Transforms.FindIndex((x) => x == transform);

            if (index == -1)
            {
                return(false);
            }
            else
            {
                Transforms.GetAndRemoveAt(index).MarkedDirty -= Transform_MarkedDirty;
                return(true);
            }
        }
示例#12
0
 public bool Remove(UITransform transform)
 {
     lock (SyncRoot)
     {
         for (int i = 0, count = _transforms.Count; i < count; i++)
         {
             if (RemoveInternal(transform, _transforms[i], i))
             {
                 return(true);
             }
         }
         _needsBoundsUpdate = true;
         return(false);
     }
 }
示例#13
0
 public bool GetElement(float x, float y, out UIElement output)
 {
     for (int i = 0, count = Transforms.Count; i < count; i++)
     {
         UITransform transform = Transforms[i];
         if (transform.IsActive && transform is UIElement element)
         {
             if (element.Boundaries.Contains(new PointF(x, y)))
             {
                 output = element;
                 return(true);
             }
         }
     }
     output = null;
     return(false);
 }
示例#14
0
        private bool RemoveInternal(UITransform original, UITransform candidate, int i)
        {
            lock (original.SyncRoot)
            {
                if (original.Container == this)
                {
                    original.SetContainer(null);
                }

                original.MarkedDirty -= Transform_MarkedDirty;
            }
            if (candidate.TransformKey == original.TransformKey)
            {
                _transforms.RemoveAt(i);
                return(true);
            }
            return(false);
        }
示例#15
0
 public IEnumerable <UIElement> GetInputSensitiveElements()
 {
     lock (SyncRoot)
     {
         ListArray <UITransform> transforms = GetSortedTransformList();
         for (int i = 0, length = transforms.Count; i < length; i++)
         {
             UITransform transform = transforms[i];
             if (transform.IsActive && transform is UIElement element)
             {
                 if (IsElementInputSensitive(element))
                 {
                     yield return(element);
                 }
             }
         }
     }
 }
示例#16
0
        public virtual void Draw(GameTime time, SpriteBatch spriteBatch)
        {
            lock (Manager.SyncRoot)
            {
                bool         isBatching   = false;
                SamplingMode lastSampling = SamplingMode.LinearClamp;

                var transforms = Manager.GetSortedTransformList();
                for (int i = 0, count = transforms.Count; i < count; i++)
                {
                    UITransform transform = transforms[i];
                    if (transform.IsActive == false || !transform.IsDrawable)
                    {
                        continue;
                    }

                    if (lastSampling != transform.PreferredSampling)
                    {
                        if (isBatching)
                        {
                            spriteBatch.End();
                            isBatching = false;
                        }
                        lastSampling = transform.PreferredSampling;
                    }

                    if (!isBatching)
                    {
                        spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, GetSamplerState(lastSampling));
                        isBatching = true;
                    }

                    transform.Draw(time, spriteBatch);
                }
                spriteBatch.End();
            }
        }
 public static void Draw(this SpriteBatch batch, GameTime time, UITransform transform)
 {
     transform.Draw(time, batch);
 }