Exemple #1
0
        internal void Draw()
        {
            // Update viewport (if SVG doc):
            SVGDocument svgDoc = (Drawing.document as SVGDocument);

            if (svgDoc != null)
            {
                svgDoc.Viewport.Update(Width, Height);
            }

            // Draw now!
            Filter.Draw(DrawInfo);
        }
        /// <summary>Updates the FlatWorldUI so it builds the mesh for this element.</summary>
        private void UpdateRenderer(LayoutBox box, float width, float height)
        {
            // - Set w/h to width and height:
            int w = (int)width;
            int h = (int)height;

            if (Renderer.SetDimensions(w, h))
            {
                // Output texture changed.

                if (Filter == null)
                {
                    // Update output:
                    Output = Renderer.Texture;

                    if (Material != null)
                    {
                        // Hook up the output:
                        Material.SetTexture("_MainTex", Output);
                    }
                }
                else
                {
                    Filter.Set("source0", Renderer.Texture);
                    // Output will be updated shortly.

                    // Always mark as changed:
                    Filter.Changed = true;
                }
            }

            // Redraw:
            if (Filter != null)
            {
                if (FilterDrawInfo != null)
                {
                    FilterDrawInfo.SetSize(w, h);
                }

                // Draw now:
                Output = Filter.Draw(FilterDrawInfo);

                if (Material != null)
                {
                    // Hook up the output:
                    Material.SetTexture("_MainTex", Output);
                }
            }

            // Temporarily set the positioning of box such that it's at the origin:
            float _x   = box.X;
            float _y   = box.Y;
            float _pX  = box.ParentOffsetLeft;
            float _pY  = box.ParentOffsetTop;
            int   _pos = box.PositionMode;

            // Clear:
            box.X = -box.Border.Left;
            box.Y = -box.Border.Top;
            box.ParentOffsetTop  = box.X;
            box.ParentOffsetLeft = box.Y;
            box.PositionMode     = PositionMode.Fixed;

            // Put the RenderData in the render only queue of *Renderer* and ask it to layout now:
            RenderableData _next = RenderData.Next;
            UpdateMode     _mode = RenderData.NextUpdateMode;

            // Clear:
            RenderData.Next           = null;
            RenderData.NextUpdateMode = UpdateMode.Render;

            // Queue:
            Renderer.Renderer.StylesToUpdate = RenderData;

            // Draw now!
            Renderer.Renderer.Update();

            // Restore (box):
            box.X = _x;
            box.Y = _y;
            box.ParentOffsetTop  = _pX;
            box.ParentOffsetLeft = _pY;
            box.PositionMode     = _pos;

            // Restore (queue):
            RenderData.Next           = _next;
            RenderData.NextUpdateMode = _mode;
        }