Beispiel #1
0
        /// <summary>Called just before the image is about to be drawn (only ever when it's actually visible).
        /// Note that everything else - e.g. ImageMaterial or Width/Height - is always called after this.</summary>
        public override void OnLayout(Css.RenderableData context, LayoutBox box, out float width, out float height)
        {
            // Get the shape of the element:
            width  = box.PaddedWidth;
            height = box.PaddedHeight;

            // Tell the context which may trigger a redraw:
            Context.SetSize((int)width, (int)height);
        }
        public override void GoingOnDisplay(Css.RenderableData context)
        {
            if (Animation == null && SPAFile != null)
            {
                Animation = SPAFile.GetInstance();

                // Set the event context now:
                Animation.SetContext(context);
            }
        }
        /// <summary>Called just before the image is about to be drawn (only ever when it's actually visible).
        /// Note that everything else - e.g. ImageMaterial or Width/Height - is always called after this.</summary>
        public override void OnLayout(Css.RenderableData context, LayoutBox box, out float width, out float height)
        {
            // Get the shape of the element:
            width  = box.PaddedWidth;
            height = box.PaddedHeight;

            if (width != Image.width || height != Image.height)
            {
                Resize((int)width, (int)height);
            }
        }
Beispiel #4
0
        /// <summary>Asks the renderer to perform a paint on the given style object next update.</summary>
        /// <param name="style">The style to paint.</param>
        public void RequestUpdate(Css.RenderableData style, UpdateMode mode)
        {
            if (DoLayout)
            {
                // Full reflow is occuring anyway - do nothing:
                return;
            }

            // Ignore this request if it was for something lesser.
            int previousMode = (int)style.NextUpdateMode;

            if ((int)mode > previousMode)
            {
                // We're now requesting an update:
                style.NextUpdateMode = mode;
            }
            else
            {
                // (e.g. it has already got a reflow queued up but a paint was requested;
                // reflow performs a paint).
                return;
            }

            // Is it the highest update mode?
            if ((int)mode > (int)HighestUpdateMode)
            {
                // Update highest:
                HighestUpdateMode = mode;
            }

            if (previousMode != 0)
            {
                // Already in the queue - don't add again.
                return;
            }

            if (StylesToUpdate == null)
            {
                StylesToUpdate = style;
                style.Next     = null;
            }
            else
            {
                style.Next     = StylesToUpdate;
                StylesToUpdate = style;
            }
        }
Beispiel #5
0
        public override void GoingOnDisplay(Css.RenderableData context)
        {
            // Note that this is only called if Video is set.
            HtmlVideoElement videoElement = context.Node as HtmlVideoElement;

            if (videoElement == null)
            {
                return;
            }

            if (!Video.isPlaying && videoElement["autoplay"] != null)
            {
                // Play now:
                videoElement.play();

                // Clear - don't autoplay again:
                videoElement["autoplay"] = null;
            }
        }
Beispiel #6
0
 /// <summary>Apply this CSS style to the given computed style.
 /// Note that you can grab the element from the computed style if you need that.</summary>
 /// <param name="style">The computed style to apply the property to.</param>
 /// <param name="value">The new value being applied.</param>
 public virtual void ApplyText(TextRenderingProperty text, RenderableData data, ComputedStyle style, Value value)
 {
 }
Beispiel #7
0
		/// <summary>Gets the value as an image, if it is one.</summary>
		public virtual ImageFormat GetImage(RenderableData context,CssProperty property){
			return null;
		}
Beispiel #8
0
 /// <summary>The value of the 'normal' keyword.</summary>
 public virtual float GetNormalValue(RenderableData context)
 {
     return(0f);
 }
Beispiel #9
0
        /// <summary>Update causes all changes to be applied and layouts to occur.</summary>
        public void Update()
        {
            if (DoLayout && AllowLayout)
            {
                // Layout RootDocument.
                Layout();
            }
            else if (StylesToUpdate != null)
            {
                // Local update - these events typically fire from changes to things like colour/z-index etc
                // as well as for reflows of "flow root" nodes.
                // It's done down here incase a full layout request is made (above).
                // If a full layout request was made, it would cover all of these anyway.

                UpdateMode modeToUse = HighestUpdateMode;
                HighestUpdateMode = UpdateMode.None;

                bool anyReflowMode = ((int)modeToUse > (int)UpdateMode.PaintAll);

                if (anyReflowMode)
                {
                    // We'll be re-rendering.
                    Reset();

                    // Invalidate input pointers:
                    // (So they figure out what elements are under the mouse/fingers)
                    PowerUI.Input.PointersInvalid = true;

                    // First, push all batches to the pool - inlined for speed:
                    // Note that no isolated batches enter either the queue or the pool until their no longer isolated.
                    if (FirstBatch != null)
                    {
                        LastBatch.BatchAfter = UIBatchPool.First;
                        UIBatchPool.First    = FirstBatch;
                    }

                    FirstBatch = LastBatch = null;

                    // Note: Batches are Prepared For Layout as they are added.
                    LayoutOccuring = true;
                }

                Css.RenderableData style = StylesToUpdate;
                StylesToUpdate = null;

                while (style != null)
                {
                    UpdateMode mode = style.NextUpdateMode;

                    switch (mode)
                    {
                    case UpdateMode.PaintAll:

                        // Don't bother if we're doing either kind of reflow:
                        if (anyReflowMode)
                        {
                            continue;
                        }

                        // Repaint it:
                        style.RepaintAll(this);

                        break;

                    case UpdateMode.Paint:

                        // Repaint it:
                        style.Repaint(this);

                        // Must also repaint the nodes child text nodes too (as they share the same CS):
                        NodeList kids = style.Node.childNodes_;

                        if (kids != null)
                        {
                            // For each child node..
                            for (int i = 0; i < kids.length; i++)
                            {
                                // Get it as a text node:
                                Node child = kids[i];

                                if (child is TextNode)
                                {
                                    // Repaint it too:
                                    (child as IRenderableNode).RenderData.Repaint(this);
                                }
                            }
                        }

                        break;

                    case UpdateMode.Reflow:

                        // Flow root reflow request.

                        // Must setup stacks and any other renderer settings here!

                        // Perform the initial reflow now:
                        style.UpdateCss(this);
                        style.Reflow(this);

                        break;

                    case UpdateMode.Render:

                        // Only call render:
                        style.Render(this);

                        break;

                        /*
                         * case UpdateMode.FastReflow:
                         *
                         *      // Fast reflow request only requires a repaint.
                         *
                         * break;
                         */
                    }

                    // Clear its update mode:
                    style.NextUpdateMode = UpdateMode.None;
                    style = style.Next;
                }


                if (!anyReflowMode)
                {
                    // Only a flush is required:
                    UIBatch toFlush = FirstBatch;

                    while (toFlush != null)
                    {
                        toFlush.Flush();
                        toFlush = toFlush.BatchAfter;
                    }
                }
                else
                {
                    // Position elements locally.
                    // This sets their ParentOffset values and as a result finds their PixelWidth.
                    IRenderableNode root = RootDocument.documentElement as IRenderableNode;

                    if (root != null)
                    {
                        // Finally, position them globally:
                        // This calculates OffsetLeft/Top and also fires the render event on the computed style object.
                        root.RenderData.Render(this);
                    }

                    LayoutOccuring = false;

                    // Tell each batch we're done laying them out:
                    UIBatch currentBatch = FirstBatch;

                    while (currentBatch != null)
                    {
                        currentBatch.CompletedLayout();
                        currentBatch = currentBatch.BatchAfter;
                    }

                    // Hide all pool entries:
                    UIBatchPool.HideAll();
                }
            }
        }
Beispiel #10
0
 /// <summary>Creates a new box-shadow property for the given element.</summary>
 /// <param name="data">The renderable object to give a shadow to.</param>
 public BackgroundShadow(RenderableData data) : base(data)
 {
 }
Beispiel #11
0
 /// <summary>Creates a new displayable property for the given render data.</summary>
 public DisplayableProperty(RenderableData data)
 {
     RenderData = data;
 }
 /// <summary>Creates a new text rendering property. Note that this must not be called directly.
 /// Set content: instead; if you're doing that from a tag, take a look at BR.</summary>
 /// <param name="data">The renderable object that this is rendering 3D text for.</param>
 public TextRenderingProperty3D(RenderableData data) : base(data)
 {
 }
Beispiel #13
0
 /// <summary>Creates a new solid background colour property for the given element.</summary>
 /// <param name="data">The renderable object to give a bg colour to.</param>
 public BackgroundColour(RenderableData data) : base(data)
 {
 }
 /// <summary>Called when this image is going to be displayed.</summary>
 public virtual void GoingOnDisplay(Css.RenderableData context)
 {
 }
Beispiel #15
0
		/// <summary>If this is a pixel integer, the raw pixel value.</summary>
		public int GetInteger(RenderableData context,CssProperty property){
			return (int)GetDecimal(context,property);
		}
Beispiel #16
0
		/// <summary>If this is a boolean, the raw bool value.</summary>
		public virtual bool GetBoolean(RenderableData context,CssProperty property){
			return false;
		}
Beispiel #17
0
		/// <summary>If this is a text value, e.g. "auto", the raw text value.</summary>
		public virtual string GetText(RenderableData context,CssProperty property){
			return "";
		}
Beispiel #18
0
		/// <summary>If this is a decimal, the raw decimal value. This is generally the main output.</summary>
		public virtual float GetDecimal(RenderableData context,CssProperty property){
			return 0f;
		}
Beispiel #19
0
		/// <summary>Gets this value as a vector path (or null if it isn't one).</summary>
		public virtual Blaze.VectorPath GetPath(RenderableData context,CssProperty property){
			
			return null;
			
		}
 /// <summary>Creates a new border property for the given element.</summary>
 /// <param name="data">The renderable object to give a border to.</param>
 public BorderProperty(RenderableData data) : base(data)
 {
 }