Пример #1
0
        public LabelObject(WindowObject parent, Font font, string text, LabelAlign horizontalAlign, LabelAlign verticalAlign, bool richText = false)
            : base(parent)
        {
            m_color = 0xffffff;
            m_alpha = 1.0f;
            m_font  = font;

            float x = 1;
            float y = 1;

            switch (horizontalAlign)
            {
            case LabelAlign.Start:
                x = 0;
                break;

            case LabelAlign.Center:
                x = 0.5f;
                break;
            }
            switch (verticalAlign)
            {
            case LabelAlign.Start:
                y = 0;
                break;

            case LabelAlign.Center:
                y = 0.5f;
                break;
            }

            m_pivot = new Vector2(x, y);

            Init(text, richText);
        }
Пример #2
0
        public override bool Update()
        {
            if (!base.Update())
            {
                return(false);
            }

            bool hasChanges = false;

            for (int i = 0; i < m_children.Count; i++)
            {
                WindowObject child = m_children[i];
                if (!child.Update())
                {
                    m_children.RemoveAt(i);
                    hasChanges = true;
                }
                else
                {
                    if (child.HasChanges)
                    {
                        hasChanges = true;
                    }
                }
            }

            HasChanges = hasChanges;

            return(true);
        }
Пример #3
0
 public WindowObject FindChild(Func <WindowObject, bool> checker)
 {
     WindowObject[] result = new WindowObject[1];
     if (FindChildren(this, checker, result, false))
     {
         return(result[0]);
     }
     return(null);
 }
Пример #4
0
        public ImageObject(WindowObject parent, ISprite sprite)
            : base(parent, sprite == null ? new Transform() : sprite.Transform)
        {
            m_sprite = sprite;

            if (sprite != null)
            {
                Size = sprite.Size;
            }
        }
Пример #5
0
        protected WindowObject(WindowObject parent, Transform transform = null)
        {
            m_parent    = parent;
            m_transform = transform == null ? new Transform() : transform;
            if (parent != null)
            {
                m_transform.Parent = parent.Transform;
            }

            m_flags = WindowObjectFlags.Default;
        }
Пример #6
0
        public bool RemoveChild(WindowObject child)
        {
            if (child.Parent != this)
            {
                return(false);
            }

            m_children.Remove(child);

            return(true);
        }
Пример #7
0
        public void AddChild(WindowObject child)
        {
            var parentContainer = child.Parent as IWindowContainer;

            if (parentContainer != null && parentContainer != this)
            {
                parentContainer.RemoveChild(child);
            }

            m_children.Add(child);
            child.Parent = this;
        }
Пример #8
0
        public static void StartCustomAnimation(WindowObject owner, AnimationKind kind, object param, int time, Action <int, object> tick, Action callback)
        {
            if (kind != AnimationKind.None)
            {
                RemoveAnimation(owner, kind);
            }

            BaseAnimatorTask task = new CustomAnimatorTask(owner, kind, param, time, tick, callback);

            s_tasks.AddLast(task);

            ReSchedule(s_tasks.Count == 1);
        }
Пример #9
0
        public static void StartAnimation <T>(WindowObject owner, AnimationKind kind, T valueFrom, T valueTo, int time, Action <float, T, T> tick, Action callback)
        {
            if (kind != AnimationKind.None)
            {
                RemoveAnimation(owner, kind);
            }

            BaseAnimatorTask task = new InterpolateAnimatorTask <T>(owner, kind, valueFrom, valueTo, time, tick, callback);

            s_tasks.AddLast(task);

            ReSchedule(s_tasks.Count == 1);
        }
Пример #10
0
        public static void RemoveAnimation(WindowObject owner, AnimationKind kind = AnimationKind.None)
        {
            LinkedListNode <BaseAnimatorTask> node = s_tasks.First;

            while (node != null)
            {
                if (node.Value.Key.Owner == owner && (kind == AnimationKind.None || node.Value.Key.Kind == kind))
                {
                    s_tasks.Remove(node);
                }

                node = node.Next;
            }
        }
Пример #11
0
 public void AddChild(WindowObject child)
 {
     m_children.Add(child);
     child.Parent = this;
 }