Exemple #1
0
        override public void Render(RenderSupport support, float parentAlpha)
        {
            Rect rect = support.GetNativeDrawRect(this.width, this.height);

            if (this._onGUI != null)
            {
                this._onGUI(this, rect);
            }
        }
Exemple #2
0
        override public void Render(RenderSupport support, float parentAlpha)
        {
            int deg = 0;

            if (this.rotation != 0.0)
            {
                //deg = (int)(this.rotation * 180 / Math.PI);
                deg = (int)this.rotation;
                if (deg != 0)
                {
                    sHelperPoint = support.mvpMatrix.transformCoords(pivotX, pivotY);
                    sPoint.x     = sHelperPoint.x;
                    sPoint.y     = sHelperPoint.y;
                    GUIUtility.RotateAroundPivot(deg, sPoint);
                }
            }

            float alpha = parentAlpha * this.alpha;

            _isRendering = true;
            foreach (DisplayObject child in _children)
            {
                if (child.hasVisibleArea)
                {
                    support.PushMatrix();
                    support.TransformMatrix(child);
                    child.Render(support, alpha);
                    support.PopMatrix();
                }
            }
            _isRendering = false;
            for (int i = 0; i < _cacheAddList.Count; i++)
            {
                int idx = _cacheAddListIdx[i];
                if (idx == _children.Count)
                {
                    _children.Add(_cacheAddList[i]);
                }
                else
                {
                    _children.Insert(idx, _cacheAddList[i]);
                }
            }
            foreach (var obj in _cahcheRemoveList)
            {
                _children.Remove(obj);
            }
            CacheClear();
            if (deg != 0)
            {
                GUIUtility.RotateAroundPivot(-deg, sPoint);
            }
        }
Exemple #3
0
        public override void Render(RenderSupport support, float parentAlpha)
        {
            Rect rect = support.GetNativeDrawRect(this.width, this.height);

            GUI.BeginGroup(rect);
            if (Event.current.type == EventType.Ignore)
            {
                GUI.EndGroup();
                return;
            }
            if (this._onGUI != null)
            {
                this._onGUI(this, rect);
            }
            GUI.EndGroup();
        }
Exemple #4
0
        override public void Render(RenderSupport support, float parentAlpha)
        {
            if (_clipRect != null)
            {
                Rect clipRect = support.PushClipRect(GetClipRectNR(stage));
                if (ToolSet.IsEmptyRect(ref clipRect))
                {
                    // empty clipping bounds - no need to render children.
                    support.PopClipRect();
                    return;
                }
            }
            base.Render(support, parentAlpha);

            if (_clipRect != null)
            {
                support.PopClipRect();
            }
        }
Exemple #5
0
        public Stage()
            : base()
        {
            if (support == null)
            {
                support = new RenderSupport();
            }
            _stageWidth  = Screen.width;
            _stageHeight = Screen.height;

            _lastMousePos     = Vector2.zero;
            _lastMouseDownPos = Vector2.zero;
            _focused          = this;

            //
            _lastHandleInputFrame = -1;

            if (Application.isMobilePlatform)
            {
                touchScreen = true;
            }

            _touches = new TouchInfo[5];
            for (int i = 0; i < _touches.Length; i++)
            {
                _touches[i] = new TouchInfo();
            }

            if (!touchScreen)
            {
                _touches[0].touchId = 0;
            }

            _rollOutChain  = new List <DisplayObject>();
            _rollOverChain = new List <DisplayObject>();

            onStageResized = new EventListener(this, "onStageResized");
            onTouchMove    = new EventListener(this, "onTouchMove");
        }
Exemple #6
0
        public override void Render(RenderSupport support, float parentAlpha)
        {
            if (_empty || _fillColor.a == 0.0)
            {
                return;
            }

            Rect rect = support.GetNativeDrawRect(_width, _height);

            int deg = 0;

            if (this.rotation != 0.0)
            {
                //deg = (int)(this.rotation * 180 / Math.PI);
                deg = (int)this.rotation;
                if (deg != 0)
                {
                    sPoint.x = rect.x;
                    sPoint.y = rect.y;
                    GUIUtility.RotateAroundPivot(deg, sPoint);
                }
            }

            Color c = GUI.color;

            c.a       = parentAlpha * this.alpha;
            GUI.color = c;
            GUI.Box(rect, GUIContent.none, _style);

            c.a       = 1;
            GUI.color = c;

            if (deg != 0)
            {
                GUIUtility.RotateAroundPivot(-deg, sPoint);
            }
        }
        public override void Render(RenderSupport support, float parentAlpha)
        {
            if (_changed)
            {
                Update();
            }

            if (_textHeight == 0)
            {
                return;
            }

            Color c = GUI.color;

            c.a       = parentAlpha * this.alpha;
            GUI.color = c;

            Rect rect = support.GetNativeDrawRect(_width, _height, false);

            sHelperRect.x      = rect.x;
            sHelperRect.y      = rect.y;
            sHelperRect.width  = rect.width;
            sHelperRect.height = rect.height;
            support.PushClipRect(sHelperRect);
            rect.x += support.projectionMatrix.tx;
            rect.y += support.projectionMatrix.ty;

            GUI.BeginGroup(rect);
            this._compiler.Draw(Time.deltaTime);
            GUI.EndGroup();

            support.PopClipRect();

            c.a       = 1;
            GUI.color = c;
        }
Exemple #8
0
 virtual public void Render(RenderSupport support, float parentAlpha)
 {
 }
Exemple #9
0
        public override void Render(RenderSupport support, float parentAlpha)
        {
            if (_texture == null)
            {
                return;
            }

            Rect rect = support.GetNativeDrawRect(_width, _height);

            int deg = 0;

            if (this.rotation != 0.0)
            {
                //deg = (int)(this.rotation * 180 / Math.PI);
                deg = (int)this.rotation;
                if (deg != 0)
                {
                    sPoint.x = rect.center.x;
                    sPoint.y = rect.center.y;
                    GUIUtility.RotateAroundPivot(deg, sPoint);
                }
            }
            Color c = GUI.color;

            c.a       = parentAlpha * this.alpha;
            GUI.color = c;
            if (_scale9Grid == null || (rect.width == _width && rect.height == _height))
            {
                GUI.DrawTexture(rect, _texture);
            }
            else
            {
                if (_scale9Changed)
                {
                    _scale9Changed = false;
                    if (_scale9Width == 0)
                    {
                        _scale9Width = _width;
                    }
                    if (_scale9Height == 0)
                    {
                        _scale9Height = _height;
                    }

                    Rect tmpScale9Grid = (Rect)_scale9Grid;
                    _rows  = new float[] { 0, tmpScale9Grid.yMin, tmpScale9Grid.yMax, _height };
                    _cols  = new float[] { 0, tmpScale9Grid.xMin, tmpScale9Grid.xMax, _width };
                    _dRows = new float[] { 0, tmpScale9Grid.yMin, _scale9Height - (_height - tmpScale9Grid.yMax), _scale9Height };
                    _dCols = new float[] { 0, tmpScale9Grid.xMin, _scale9Width - (_width - tmpScale9Grid.xMax), _scale9Width };
                    //if (_scale9Height >= tmpScale9Grid.height)
                    //    _dRows = new float[] { 0, tmpScale9Grid.yMin, _scale9Height - (_height - tmpScale9Grid.yMax), _scale9Height };
                    //else
                    //{
                    //    float tmp = tmpScale9Grid.yMin / (_height - tmpScale9Grid.yMax);
                    //    tmp = _scale9Height * tmp / (1 + tmp);//不明算法
                    //    _dRows = new float[] { 0, tmp, tmp, _scale9Height }; //胡来缩放时就会不正确
                    //}

                    //if (_scale9Width >= tmpScale9Grid.width)
                    //    _dCols = new float[] { 0, tmpScale9Grid.xMin, _scale9Width - (_width - tmpScale9Grid.xMax), _scale9Width };
                    //else
                    //{
                    //    float tmp = tmpScale9Grid.xMin / (_width - tmpScale9Grid.xMax);
                    //    tmp = _scale9Width * tmp / (1 + tmp);
                    //    _dCols = new float[] { 0, tmp, tmp, _scale9Width };
                    //}
                }
                float scaleXLeft = rect.width / _scale9Width;
                float scaleYLeft = rect.height / _scale9Height;

                for (int cx = 0; cx < 3; cx++)
                {
                    for (int cy = 0; cy < 3; cy++)
                    {
                        //origin
                        //the texture coordinates are normalized. So in your case you would have 1/8, 2/8, 3/8... positions. i.e a percentage.
                        //the texCoord Y-axis is opposite to the destination.
                        sHelperRect1.x      = _cols[cx] / _width;
                        sHelperRect1.y      = 1 - _rows[cy + 1] / _height;//_rows[cy+1]/height
                        sHelperRect1.width  = (_cols[cx + 1] - _cols[cx]) / _width;
                        sHelperRect1.height = (_rows[cy + 1] - _rows[cy]) / _height;
                        //sHelperRect1 确定九宫格原始比例,针对纹理坐标且纹理是原点是在左下角的
                        //sHelperRect2 位置和缩放功能,屏幕坐标原点左上角
                        //draw
                        sHelperRect2.x      = (rect.x + _dCols[cx]) * scaleXLeft;
                        sHelperRect2.y      = (rect.y + _dRows[cy]) * scaleYLeft;
                        sHelperRect2.width  = (_dCols[cx + 1] - _dCols[cx]) * scaleXLeft;
                        sHelperRect2.height = (_dRows[cy + 1] - _dRows[cy]) * scaleYLeft;

                        if (sHelperRect2.width != 0 && sHelperRect2.height != 0)
                        {
                            GUI.DrawTextureWithTexCoords(sHelperRect2, _texture, sHelperRect1);
                        }
                    }
                }
            }

            c.a       = 1;
            GUI.color = c;

            if (deg != 0)
            {
                GUIUtility.RotateAroundPivot(-deg, sPoint);
            }
        }
Exemple #10
0
        public override void Render(RenderSupport support, float parentAlpha)
        {
            if (_text != null)
            {
                Color c = GUI.color;
                c.a       = parentAlpha * this.alpha;
                GUI.color = c;

                Rect rect = support.GetNativeDrawRect(_width, _height, false);
                sHelperRect.x      = rect.x;
                sHelperRect.y      = rect.y;
                sHelperRect.width  = rect.width;
                sHelperRect.height = rect.height;
                support.PushClipRect(sHelperRect);
                rect.x += support.projectionMatrix.tx;
                rect.y += support.projectionMatrix.ty;

                GUIStyle lastStyle;
                if (_input)
                {
                    GUI.SetNextControlName(internalId);
                    if (_singleLine)
                    {
                        lastStyle          = GUI.skin.textField;
                        GUI.skin.textField = _textFormat.style;
                        _text = GUI.TextField(rect, _text, _maxLength);
                        if (GUI.changed)
                        {
                            DispatchEventObsolete(sChange);
                            onChanged.Call();
                        }

                        GUI.skin.textField = lastStyle;
                    }
                    else if (_displayAsPassword)
                    {
                        _text = GUI.PasswordField(rect, _text, '*', _maxLength);
                        if (GUI.changed)
                        {
                            DispatchEventObsolete(sChange);
                            onChanged.Call();
                        }
                    }
                    else
                    {
                        lastStyle         = GUI.skin.textArea;
                        GUI.skin.textArea = _textFormat.style;
                        _text             = GUI.TextArea(rect, _text, _maxLength);
                        if (GUI.changed)
                        {
                            DispatchEventObsolete(sChange);
                            onChanged.Call();
                        }

                        GUI.skin.textArea = lastStyle;
                    }
                }
                else
                {
                    lastStyle      = GUI.skin.label;
                    GUI.skin.label = _textFormat.style;
                    GUI.Label(rect, _text);
                    GUI.skin.label = lastStyle;
                }
                support.PopClipRect();

                c.a       = 1;
                GUI.color = c;
            }
        }