Наследование: EventDispatcher
Пример #1
0
    static int RemoveChild(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(FairyGUI.Container), typeof(FairyGUI.DisplayObject)))
            {
                FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.ToObject(L, 1);
                FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.ToObject(L, 2);
                FairyGUI.DisplayObject o    = obj.RemoveChild(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(FairyGUI.Container), typeof(FairyGUI.DisplayObject), typeof(bool)))
            {
                FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.ToObject(L, 1);
                FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.ToObject(L, 2);
                bool arg1 = LuaDLL.lua_toboolean(L, 3);
                FairyGUI.DisplayObject o = obj.RemoveChild(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: FairyGUI.Container.RemoveChild"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Пример #2
0
    static int SetFous(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                FairyGUI.Stage         obj  = (FairyGUI.Stage)ToLua.CheckObject <FairyGUI.Stage>(L, 1);
                FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 2);
                obj.SetFous(arg0);
                return(0);
            }
            else if (count == 3)
            {
                FairyGUI.Stage         obj  = (FairyGUI.Stage)ToLua.CheckObject <FairyGUI.Stage>(L, 1);
                FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 2);
                bool arg1 = LuaDLL.luaL_checkboolean(L, 3);
                obj.SetFous(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: FairyGUI.Stage.SetFous"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 static public int set_onPaint(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject  self = (FairyGUI.DisplayObject)checkSelf(l);
         FairyGUI.EventCallback0 v;
         int op = LuaDelegation.checkDelegate(l, 2, out v);
         if (op == 0)
         {
             self.onPaint = v;
         }
         else if (op == 1)
         {
             self.onPaint += v;
         }
         else if (op == 2)
         {
             self.onPaint -= v;
         }
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #4
0
    static int RemoveChildAt(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                FairyGUI.Container obj = (FairyGUI.Container)ToLua.CheckObject <FairyGUI.Container>(L, 1);
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                FairyGUI.DisplayObject o = obj.RemoveChildAt(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 3)
            {
                FairyGUI.Container obj = (FairyGUI.Container)ToLua.CheckObject <FairyGUI.Container>(L, 1);
                int  arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                bool arg1 = LuaDLL.luaL_checkboolean(L, 3);
                FairyGUI.DisplayObject o = obj.RemoveChildAt(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: FairyGUI.Container.RemoveChildAt"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 public void FreeObject(DisplayObject obj)
 {
     GLoader loader = obj.gOwner as GLoader;
     if (loader != null)
     {
         loader.url = null;
         pool.Push(loader);
     }
 }
        public void Dispose()
        {
            _target.LeavePaintingMode(1);
            _target.onPaint -= OnRenderImage;
            _target = null;

            if (Application.isPlaying)
                Material.Destroy(_blitMaterial);
            else
                Material.DestroyImmediate(_blitMaterial);
        }
 static public int Dispose(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         self.Dispose();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_blendMode(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.blendMode);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_worldSpaceContainer(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.worldSpaceContainer);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_onRemovedFromStage(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.onRemovedFromStage);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_scaleY(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.scaleY);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject o;
         o = new FairyGUI.DisplayObject();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        public static void Capture(DisplayObject target, RenderTexture texture, Vector2 offset)
        {
            CheckMain();

            Matrix4x4 matrix = target.cachedTransform.localToWorldMatrix;
            float unitsPerPixel = new Vector4(matrix.m00, matrix.m10, matrix.m20, matrix.m30).magnitude;

            Vector3 forward;
            forward.x = matrix.m02;
            forward.y = matrix.m12;
            forward.z = matrix.m22;

            Vector3 upwards;
            upwards.x = matrix.m01;
            upwards.y = matrix.m11;
            upwards.z = matrix.m21;

            float halfHeight = (float)texture.height / 2;

            Camera camera = _main.cachedCamera;
            camera.targetTexture = texture;
            camera.orthographicSize = halfHeight * unitsPerPixel;
            _main.cachedTransform.localPosition = target.cachedTransform.TransformPoint(halfHeight * camera.aspect - offset.x, -halfHeight + offset.y, 0);
            _main.cachedTransform.localRotation = Quaternion.LookRotation(forward, upwards);

            int oldLayer = 0;

            if (target.graphics != null)
            {
                oldLayer = target.graphics.gameObject.layer;
                target.graphics.gameObject.layer = CaptureCamera.layer;
            }

            if (target is Container)
            {
                oldLayer = ((Container)target).numChildren > 0 ? ((Container)target).GetChildAt(0).layer : CaptureCamera.hiddenLayer;
                ((Container)target).SetChildrenLayer(CaptureCamera.layer);
            }

            RenderTexture old = RenderTexture.active;
            RenderTexture.active = texture;
            GL.Clear(true, true, Color.clear);
            camera.Render();
            RenderTexture.active = old;

            if (target.graphics != null)
                target.graphics.gameObject.layer = oldLayer;

            if (target is Container)
                ((Container)target).SetChildrenLayer(oldLayer);
        }
 static public int set_id(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         System.UInt32          v;
         checkType(l, 2, out v);
         self.id = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_blendMode(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         FairyGUI.BlendMode     v;
         checkEnum(l, 2, out v);
         self.blendMode = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_filter(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         FairyGUI.IFilter       v;
         checkType(l, 2, out v);
         self.filter = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int LeavePaintingMode(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         System.Int32           a1;
         checkType(l, 2, out a1);
         self.LeavePaintingMode(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int Update(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         FairyGUI.UpdateContext a1;
         checkType(l, 2, out a1);
         self.Update(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_scaleX(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.scaleX = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_visible(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.visible = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_size(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         UnityEngine.Vector2    v;
         checkType(l, 2, out v);
         self.size = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int LocalToGlobal(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         UnityEngine.Vector2    a1;
         checkType(l, 2, out a1);
         var ret = self.LocalToGlobal(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int GetBounds(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         FairyGUI.DisplayObject a1;
         checkType(l, 2, out a1);
         var ret = self.GetBounds(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #24
0
 static int SetNativeObject(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.GGraph        obj  = (FairyGUI.GGraph)ToLua.CheckObject <FairyGUI.GGraph>(L, 1);
         FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 2);
         obj.SetNativeObject(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #25
0
 static int GetChild(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.CheckObject(L, 1, typeof(FairyGUI.Container));
         string                 arg0 = ToLua.CheckString(L, 2);
         FairyGUI.DisplayObject o    = obj.GetChild(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #26
0
 static int DisplayObjectToGObject(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.GRoot         obj  = (FairyGUI.GRoot)ToLua.CheckObject(L, 1, typeof(FairyGUI.GRoot));
         FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject(L, 2, typeof(FairyGUI.DisplayObject));
         FairyGUI.GObject       o    = obj.DisplayObjectToGObject(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #27
0
 static int SwapChildren(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.CheckObject <FairyGUI.Container>(L, 1);
         FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 2);
         FairyGUI.DisplayObject arg1 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 3);
         obj.SwapChildren(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #28
0
 static int IsAncestorOf(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.CheckObject <FairyGUI.Container>(L, 1);
         FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 2);
         bool o = obj.IsAncestorOf(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #29
0
 static int GetBounds(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.CheckObject <FairyGUI.Container>(L, 1);
         FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 2);
         UnityEngine.Rect       o    = obj.GetBounds(arg0);
         ToLua.PushValue(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #30
0
 static int AddChild(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.CheckObject <FairyGUI.Container>(L, 1);
         FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 2);
         FairyGUI.DisplayObject o    = obj.AddChild(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #31
0
 static int SetChildIndex(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.CheckObject <FairyGUI.Container>(L, 1);
         FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 2);
         int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         obj.SetChildIndex(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #32
0
 static int GetChildAt(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Container obj = (FairyGUI.Container)ToLua.CheckObject <FairyGUI.Container>(L, 1);
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         FairyGUI.DisplayObject o = obj.GetChildAt(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #33
0
 static int GetChildIndex(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.CheckObject <FairyGUI.Container>(L, 1);
         FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 2);
         int o = obj.GetChildIndex(arg0);
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #34
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public GObject DisplayObjectToGObject(DisplayObject obj)
        {
            while (obj != null)
            {
                if (obj.gOwner != null)
                    return obj.gOwner;

                obj = obj.parent;
            }
            return null;
        }
Пример #35
0
        /// <summary>
        /// 设置内容为一个原生对象。这个图形对象相当于一个占位的用途。
        /// </summary>
        /// <param name="obj">原生对象</param>
        public void SetNativeObject(DisplayObject obj)
        {
            if (displayObject == obj)
                return;

            if (displayObject != null)
            {
                if (displayObject.parent != null)
                    displayObject.parent.RemoveChild(displayObject, true);
                else
                    displayObject.Dispose();
                _shape = null;
                displayObject.gOwner = null;
                displayObject = null;
            }

            displayObject = obj;

            if (displayObject != null)
            {
                displayObject.alpha = this.alpha;
                displayObject.rotation = this.rotation;
                displayObject.visible = this.visible;
                displayObject.touchable = this.touchable;
                displayObject.gOwner = this;
            }

            if (parent != null)
                parent.ChildStateChanged(this);
            HandlePositionChanged();
        }
Пример #36
0
 public void SwapChildren(DisplayObject child1, DisplayObject child2)
 {
     int index1 = _children.IndexOf(child1);
     int index2 = _children.IndexOf(child2);
     if (index1 == -1 || index2 == -1)
         throw new Exception("Not a child of this container");
     SwapChildrenAt(index1, index2);
 }
Пример #37
0
 public void SetChildIndex(DisplayObject child, int index)
 {
     int oldIndex = _children.IndexOf(child);
     if (oldIndex == index) return;
     if (oldIndex == -1) throw new ArgumentException("Not a child of this container");
     _children.RemoveAt(oldIndex);
     if (index >= _children.Count)
         _children.Add(child);
     else
         _children.Insert(index, child);
     InvalidateBatchingState(true);
 }
Пример #38
0
        public DisplayObject RemoveChild(DisplayObject child, bool dispose)
        {
            if (child.parent != this)
                throw new Exception("obj is not a child");

            int i = _children.IndexOf(child);
            if (i >= 0)
                return RemoveChildAt(i, dispose);
            else
                return null;
        }
Пример #39
0
 public DisplayObject RemoveChild(DisplayObject child)
 {
     return RemoveChild(child, false);
 }
Пример #40
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="targetSpace">null if to world space</param>
        /// <returns></returns>
        public Rect TransformRect(Rect rect, DisplayObject targetSpace)
        {
            if (targetSpace == this)
                return rect;

            if (targetSpace == parent && rotation == 0f) // optimization
            {
                float scaleX = this.scaleX;
                float scaleY = this.scaleY;
                rect = new Rect(this.x + rect.x, this.y + rect.y, rect.width, rect.height);
                rect.x *= scaleX;
                rect.y *= scaleY;
                rect.width *= scaleX;
                rect.height *= scaleY;

                return rect;
            }
            else
            {
                float xMin = float.MaxValue, xMax = float.MinValue;
                float yMin = float.MaxValue, yMax = float.MinValue;
                Rect result = Rect.MinMaxRect(xMin, yMin, xMax, yMax);

                TransformRectPoint(rect.xMin, rect.yMin, targetSpace, ref result);
                TransformRectPoint(rect.xMax, rect.yMin, targetSpace, ref result);
                TransformRectPoint(rect.xMin, rect.yMax, targetSpace, ref result);
                TransformRectPoint(rect.xMax, rect.yMax, targetSpace, ref result);

                return result;
            }
        }
Пример #41
0
 public virtual Rect GetBounds(DisplayObject targetSpace)
 {
     if (targetSpace == this || targetSpace == null || contentRect.width == 0 || contentRect.height == 0) // optimization
     {
         return contentRect;
     }
     else if (targetSpace == parent && _rotation == 0f)
     {
         Rect rect = new Rect(_x - contentRect.x * _scaleX,
             _y - contentRect.y * _scaleY,
             contentRect.width * _scaleX,
             contentRect.height * _scaleY);
         return rect;
     }
     else
         return TransformRect(contentRect, targetSpace);
 }
Пример #42
0
        public DisplayObject AddChildAt(DisplayObject child, int index)
        {
            int count = _children.Count;
            if (index >= 0 && index <= count)
            {
                if (child.parent == this)
                {
                    SetChildIndex(child, index);
                }
                else
                {
                    child.RemoveFromParent();
                    if (index == count)
                        _children.Add(child);
                    else
                        _children.Insert(index, child);
                    child.SetParent(this);

                    if (stage != null)
                    {
                        if (child is Container)
                            child.onAddedToStage.BroadcastCall();
                        else
                            child.onAddedToStage.Call();
                    }

                    InvalidateBatchingState(true);
                }
                return child;
            }
            else
            {
                throw new Exception("Invalid child index");
            }
        }
Пример #43
0
 public bool Contains(DisplayObject child)
 {
     return _children.Contains(child);
 }
Пример #44
0
 public DisplayObject AddChild(DisplayObject child)
 {
     AddChildAt(child, _children.Count);
     return child;
 }
Пример #45
0
 public void Update(DisplayObject obj)
 {
     obj.SetXY((int)(start.x + change1.x * value + change2.x * value * value), (int)(start.y + change1.y * value + change2.y * value * value));
 }
Пример #46
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="targetSpace"></param>
        /// <returns></returns>
        public virtual Rect GetBounds(DisplayObject targetSpace)
        {
            EnsureSizeCorrect();

            if (targetSpace == this || _contentRect.width == 0 || _contentRect.height == 0) // optimization
            {
                return _contentRect;
            }
            else if (targetSpace == parent && _rotation.z == 0)
            {
                float sx = this.scaleX;
                float sy = this.scaleY;
                return new Rect(this.x, this.y, _contentRect.width * sx, _contentRect.height * sy);
            }
            else
                return TransformRect(_contentRect, targetSpace);
        }
Пример #47
0
 protected void TransformRectPoint(float px, float py, DisplayObject targetSpace, ref Rect rect)
 {
     Vector2 v = this.cachedTransform.TransformPoint(px, -py, 0);
     if (targetSpace != null)
     {
         v = targetSpace.cachedTransform.InverseTransformPoint(v);
         v.y = -v.y;
     }
     if (rect.xMin > v.x) rect.xMin = v.x;
     if (rect.xMax < v.x) rect.xMax = v.x;
     if (rect.yMin > v.y) rect.yMin = v.y;
     if (rect.yMax < v.y) rect.yMax = v.y;
 }
Пример #48
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="targetSpace">null if to world space</param>
        /// <returns></returns>
        public Rect TransformRect(Rect rect, DisplayObject targetSpace)
        {
            if (targetSpace == this)
                return rect;

            if (targetSpace == parent && _rotation.z == 0) // optimization
            {
                Vector3 vec = cachedTransform.localScale;
                return new Rect((this.x + rect.x) * vec.x, (this.y + rect.y) * vec.y,
                    rect.width * vec.x, rect.height * vec.y);
            }
            else
            {
                Rect result = Rect.MinMaxRect(float.MaxValue, float.MaxValue, float.MinValue, float.MinValue);

                TransformRectPoint(rect.xMin, rect.yMin, targetSpace, ref result);
                TransformRectPoint(rect.xMax, rect.yMin, targetSpace, ref result);
                TransformRectPoint(rect.xMin, rect.yMax, targetSpace, ref result);
                TransformRectPoint(rect.xMax, rect.yMax, targetSpace, ref result);

                return result;
            }
        }
        public void Dispose()
        {
            if ((_target is Image) || (_target is MovieClip))
                _target.graphics.materialKeywords = null;
            else
                _target.LeavePaintingMode(1);

            _target = null;
        }
Пример #50
0
        public Vector2 TransformPoint(Vector2 point, DisplayObject targetSpace)
        {
            if (targetSpace == this)
                return point;

            point.y = -point.y;
            if (this.scaleOverrided)
            {
                point.x *= _scaleX;
                point.y *= _scaleY;
            }
            Vector3 v = this.cachedTransform.TransformPoint(point);
            if (targetSpace != null)
            {
                if (targetSpace != Stage.inst || this.stage != null)
                    v = targetSpace.cachedTransform.InverseTransformPoint(v);
                v.y = -v.y;
                if (targetSpace.scaleOverrided)
                {
                    if (targetSpace._scaleX != 0)
                        v.x /= targetSpace._scaleX;
                    if (targetSpace._scaleY != 0)
                        v.y /= targetSpace._scaleY;
                }
                v.x -= targetSpace._pivotX;
                v.y -= targetSpace._pivotY;
            }
            return v;
        }
Пример #51
0
        public override Rect GetBounds(DisplayObject targetSpace)
        {
            if (_clipRect != null)
                return TransformRect((Rect)_clipRect, targetSpace);

            int count = _children.Count;

            Rect rect;
            if (count == 0)
            {
                Vector2 v = TransformPoint(Vector2.zero, targetSpace);
                rect = Rect.MinMaxRect(v.x, v.y, 0, 0);
            }
            else if (count == 1)
            {
                rect = _children[0].GetBounds(targetSpace);
            }
            else
            {
                float minX = float.MaxValue, maxX = float.MinValue;
                float minY = float.MaxValue, maxY = float.MinValue;

                for (int i = 0; i < count; ++i)
                {
                    rect = _children[i].GetBounds(targetSpace);
                    minX = minX < rect.xMin ? minX : rect.xMin;
                    maxX = maxX > rect.xMax ? maxX : rect.xMax;
                    minY = minY < rect.yMin ? minY : rect.yMin;
                    maxY = maxY > rect.yMax ? maxY : rect.yMax;
                }

                rect = Rect.MinMaxRect(minX, minY, maxX, maxY);
            }

            return rect;
        }
Пример #52
0
        public Rect TransformRect(Rect rect, DisplayObject targetSpace)
        {
            if (targetSpace == this)
                return rect;

            float xMin = float.MaxValue, xMax = float.MinValue;
            float yMin = float.MaxValue, yMax = float.MinValue;
            Rect result = Rect.MinMaxRect(xMin, yMin, xMax, yMax);

            bool skilInversing = targetSpace != Stage.inst || this.stage != null;

            TransformRectPoint(rect.xMin, rect.yMin, targetSpace, ref result, skilInversing);
            TransformRectPoint(rect.xMax, rect.yMin, targetSpace, ref result, skilInversing);
            TransformRectPoint(rect.xMin, rect.yMax, targetSpace, ref result, skilInversing);
            TransformRectPoint(rect.xMax, rect.yMax, targetSpace, ref result, skilInversing);

            return result;
        }
Пример #53
0
 public int GetChildIndex(DisplayObject child)
 {
     return _children.IndexOf(child);
 }
Пример #54
0
        public bool IsAncestorOf(DisplayObject obj)
        {
            if (obj == null)
                return false;

            Container p = obj.parent;
            while (p != null)
            {
                if (p == this)
                    return true;

                p = p.parent;
            }
            return false;
        }
Пример #55
0
        void HandleTouchEvents()
        {
            for (int i = 0; i < Input.touchCount; ++i)
            {
                Touch uTouch = Input.GetTouch(i);

                if (uTouch.phase == TouchPhase.Stationary)
                    continue;

                bool hitTested = false;
                Vector2 touchPosition = uTouch.position;
                touchPosition.y = stageHeight - touchPosition.y;
                TouchInfo touch = null;
                for (int j = 0; j < 5; j++)
                {
                    if (_touches[j].touchId == uTouch.fingerId)
                    {
                        touch = _touches[j];
                        break;
                    }

                    if (_touches[j].touchId == -1)
                        touch = _touches[j];
                }
                if (touch == null)
                    continue;

                touch.touchId = uTouch.fingerId;
                mouseX = touchPosition.x;
                mouseY = touchPosition.y;

                if (touch.x != mouseX || touch.y != mouseY)
                {
                    touch.x = mouseX;
                    touch.y = mouseY;

                    _objectUnderMouse = HitTest(touchPosition, true);
                    hitTested = true;
                    touch.target = _objectUnderMouse;

                    touch.UpdateEvent();
                    onMouseMove.Call(touch.evt);

                    //no rollover/rollout on mobile
                    //if (evt.lastRollOver != _objectUnderMouse)
                    //HandleRollOver(evt);
                }

                if (uTouch.phase == TouchPhase.Began)
                {
                    if (!touch.began)
                    {
                        touch.began = true;
                        touch.clickCancelled = false;
                        touch.downX = touch.x;
                        touch.downY = touch.y;

                        if (!hitTested)
                        {
                            _objectUnderMouse = HitTest(touchPosition, true);
                            hitTested = true;
                            touch.target = _objectUnderMouse;
                        }

                        this.focus = _objectUnderMouse;

                        if (_objectUnderMouse != null)
                        {
                            touch.UpdateEvent();
                            _objectUnderMouse.onMouseDown.BubbleCall(touch.evt);
                        }
                    }
                }
                else if (uTouch.phase == TouchPhase.Canceled || uTouch.phase == TouchPhase.Ended)
                {
                    if (touch.began)
                    {
                        touch.began = false;

                        if (!hitTested)
                        {
                            _objectUnderMouse = HitTest(touchPosition, true);
                            hitTested = true;
                            touch.target = _objectUnderMouse;
                        }

                        if (_objectUnderMouse != null)
                        {
                            touch.UpdateEvent();
                            _objectUnderMouse.onMouseUp.BubbleCall(touch.evt);

                            if (!touch.clickCancelled && Mathf.Abs(touch.x - touch.downX) < 50 && Mathf.Abs(touch.y - touch.downY) < 50)
                            {
                                touch.clickCount = uTouch.tapCount;
                                touch.UpdateEvent();
                                _objectUnderMouse.onClick.BubbleCall(touch.evt);
                            }
                        }
                    }

                    touch.Reset();
                }
            }
        }
Пример #56
0
 private void TransformRectPoint(float px, float py, DisplayObject targetSpace, ref Rect rect, bool skipInversing)
 {
     if (this.scaleOverrided)
     {
         px *= _scaleX;
         py *= _scaleY;
     }
     Vector2 v = this.cachedTransform.TransformPoint(px, -py, 0);
     if (skipInversing)
         v = targetSpace.cachedTransform.InverseTransformPoint(v);
     v.y = -v.y;
     if (targetSpace.scaleOverrided)
     {
         if (targetSpace._scaleX != 0)
             v.x /= targetSpace._scaleX;
         if (targetSpace._scaleY != 0)
             v.y /= targetSpace._scaleY;
     }
     if (rect.xMin > v.x) rect.xMin = v.x;
     if (rect.xMax < v.x) rect.xMax = v.x;
     if (rect.yMin > v.y) rect.yMin = v.y;
     if (rect.yMax < v.y) rect.yMax = v.y;
 }
Пример #57
0
		public override Rect GetBounds(DisplayObject targetSpace)
		{
			if (_textChanged && _autoSize)
				BuildLines();

			return base.GetBounds(targetSpace);
		}
Пример #58
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="point"></param>
        /// <param name="targetSpace">null if to world space</param>
        /// <returns></returns>
        public Vector2 TransformPoint(Vector2 point, DisplayObject targetSpace)
        {
            if (targetSpace == this)
                return point;

            point.y = -point.y;
            Vector3 v = this.cachedTransform.TransformPoint(point);
            if (targetSpace != null)
            {
                v = targetSpace.cachedTransform.InverseTransformPoint(v);
                v.y = -v.y;
            }
            return v;
        }
Пример #59
0
 public void Update(DisplayObject obj)
 {
     obj.x = (int)(start.x + change1.x * value + change2.x * value * value);
     obj.y = (int)(start.y + change1.y * value + change2.y * value * value);
 }
Пример #60
0
 public void Reset()
 {
     touchId = -1;
     x = 0;
     y = 0;
     clickCount = 0;
     keyCode = KeyCode.None;
     modifiers = 0;
     mouseWheelDelta = 0;
     lastClickTime = 0;
     began = false;
     target = null;
     lastRollOver = null;
     clickCancelled = false;
 }