public void OnRender(Renderman renderer) { if (OnRenderInform != null) { OnRenderInform(renderer, this); } }
/// <summary>Lays out this background.</summary> internal void Layout(LayoutBox box, Renderman renderer) { if (Image == null || !Image.Loaded) { // Reject the visibility state change. ImageLocation = null; Text.Include(); return; } // Tell the image that the box has likely changed - this allows it to redraw (e.g. SVGs): float trueImageWidth; float trueImageHeight; Image.Contents.OnLayout(Text.RenderData, box, out trueImageWidth, out trueImageHeight); if (ImageLocation == null) { // Tell it that it's going on screen: Image.GoingOnDisplay(Text.RenderData); // Create an isolated location: ImageLocation = new AtlasLocation(trueImageWidth, trueImageHeight); } // Isolate the text: Text.Isolate(); }
/// <summary>Transforms all the verts by the given delta matrix. Used during a Paint only.</summary> public override void ApplyTransform(Matrix4x4 delta, Renderman renderer) { for (int i = 0; i < Contents.Count; i++) { Contents[i].ApplyTransform(delta, renderer); } }
/// <summary>Draws an underline (or a strikethrough).</summary> public override void DrawUnderline(Renderman renderer) { // Setup the mesh: if (Underline == null) { // We'll need the root gameObject - this should always be on a TextNode, but the parentNode // will always be an Element. Therefore we can grab the gameObject via that parentNode: HtmlElement parent = RenderData.Node.parentNode as HtmlElement; Underline = new MeshBufferExtruded(parent.rootGameObject.transform); // Update material: Underline.SetMaterial(new Material(renderer.CurrentShaderSet.Extruded)); Underline.ExtrudeAmount = Extrude; } // Update colours: Underline.FrontColor = renderer.FontColour; Underline.BackColor = renderer.FontColour; Underline.SideColor = renderer.FontColour; BoxRegion region = renderer.CurrentRegion; // 4 corners (back face): Vector3 a = renderer.PixelToWorldUnit(region.X, region.Y, renderer.TextDepth); Vector3 b = renderer.PixelToWorldUnit(region.MaxX, region.Y, renderer.TextDepth); Vector3 c = renderer.PixelToWorldUnit(region.MaxX, region.MaxY, renderer.TextDepth); Vector3 d = renderer.PixelToWorldUnit(region.X, region.MaxY, renderer.TextDepth); // Build a simple cube: Underline.BuildCube(a, b, c, d); }
/// <summary>Draws a character with x-inverted UV's. Used for rendering e.g. "1 < 2" in right-to-left.</summary> protected override void DrawInvertCharacter(ref float left, Renderman renderer) { float top = renderer.TopOffset; int index = renderer.CharacterIndex; Glyph character = Characters[index]; if (character == null) { return; } if (Kerning != null) { left += Kerning[index] * FontSize; } // Have we got a path at all? (Something like a space does not): if (character.FirstPathNode != null) { float y = top + renderer.TextAscender; float x = left + (character.LeftSideBearing * FontSize); // Map the point to worldspace: Vector3 worldspace = renderer.PixelToWorldUnit(x, y, RenderData.computedStyle.ZIndex); // Build the characters mesh now, using the shared triangulator: Mesh.AddMesh(character, worldspace.x, worldspace.y, TextExtrude.Triangulator); } left += (character.AdvanceWidth * FontSize) + LetterSpacing; }
/// <summary>Renders round corners.</summary> public void RenderCorners(LayoutBox box, Renderman renderer) { // Get the co-ord of the top edge: float top = box.Y; float left = box.X; // And the dimensions of the lines: float boxWidth = box.PaddedWidth + box.Border.Left + box.Border.Right; float boxHeight = box.PaddedHeight + box.Border.Top + box.Border.Bottom; if (TopLeft != null) { // Got a top left corner - render it now: TopLeft.Render(box, renderer, left, top); } if (TopRight != null) { // Got a top left corner - render it now: TopRight.Render(box, renderer, left + boxWidth, top); } if (BottomRight != null) { // Got a top left corner - render it now: BottomRight.Render(box, renderer, left + boxWidth, top + boxHeight); } if (BottomLeft != null) { // Got a top left corner - render it now: BottomLeft.Render(box, renderer, left, top + boxHeight); } }
public override bool Render(bool first, LayoutBox box, Renderman renderer) { base.Render(first, box, renderer); // PostProcess required if this has Resets (i.e. after the element has done all of its kids): return(Resets != null); }
internal override void Layout(LayoutBox box, Renderman renderer) { for (int i = 0; i < Contents.Count; i++) { Contents[i].Layout(box, renderer); } }
/// <summary>Called when the parent element has finished rendering its kids.</summary> public void End(Renderman renderer) { if (OnEnd != null) { OnEnd(renderer, this); } }
public override void Paint(LayoutBox box, Renderman renderer) { for (int i = 0; i < Contents.Count; i++) { Contents[i].Paint(box, renderer); } }
/// <summary>Calculates where the transformation origin should go in screen space.</summary> /// <param name="relativeTo">The computed style of the element that the origin will be /// relative to if the origin position is 'Relative'</param> private Vector3 CalculateOrigin(ComputedStyle relativeTo, LayoutBox box) { // We need to figure out where the origin is and then apply the parent transformation to it. Vector3 origin; if (_OriginOffset == null) { // Default (50%,50%,0): origin = new Vector3(0.5f * box.Width, 0.5f * box.Height, 0f); } else if (_OriginOffset is CssFunction) { RenderableData rd = relativeTo.RenderData; origin = new Vector3( _OriginOffset.GetDecimal(rd, ValueAxis.X), _OriginOffset.GetDecimal(rd, ValueAxis.Y), 0f ); } else { float z = 0f; RenderableData rd = relativeTo.RenderData; if (_OriginOffset.Count == 3) { z = _OriginOffset[2].GetDecimal(rd, ValueAxis.X); } origin = new Vector3( _OriginOffset[0].GetDecimal(rd, ValueAxis.X), _OriginOffset[1].GetDecimal(rd, ValueAxis.Y), z ); } if (_OriginPosition == PositionMode.Relative) { origin.x += box.X; origin.y += box.Y; } // Map origin to world space: Renderman renderer = (relativeTo.Element.document as PowerUI.HtmlDocument).Renderer; origin = renderer.PixelToWorldUnit(origin.x, origin.y, relativeTo.ZIndex); if (Parent != null) { origin = Parent.Apply(origin); } return(origin); }
/// <summary>Make this property visible by forcing it to redraw.</summary> public virtual bool Render(bool first, LayoutBox box, Renderman renderer) { if (first) { ClearBlocks(); } Layout(box, renderer); return(false); }
/// <summary>Transforms all the blocks that this property has allocated. Note that transformations are a post process. /// Special case for borders as it may also internally transform its corners.</summary> /// <param name="topTransform">The transform that should be applied to this property.</param> public override void PostProcess(LayoutBox box, Renderman renderer) { if (Corners == null) { return; } // Render them: Corners.RenderCorners(box, renderer); }
/// <summary>Draws the given Emoji character.</summary> public void DrawEmoji(Glyph character, ref float left, Renderman renderer) { if (!character.Image.Loaded) { return; } BoxRegion screenRegion = renderer.CurrentRegion; float top = renderer.TopOffset; // It's an image (e.g. Emoji). AtlasLocation locatedAt = RequireImage(character.Image); if (locatedAt == null) { // It needs to be isolated. Big emoji image! return; } if (CharacterProviders.FixHeight) { // Set the region: screenRegion.Set(left, top, locatedAt.Width, locatedAt.Height); } else { screenRegion.Set(left, top, FontSize, FontSize); } if (screenRegion.Overlaps(renderer.ClippingBoundary)) { // Ensure correct batch: renderer.SetupBatch(this, locatedAt.Atlas, null); // If the two overlap, this means it's actually visible. MeshBlock block = Add(renderer); // Set it's colour: block.SetColour(renderer.ColorOverlay); // And clip our meshblock to fit within boundary: block.TextUV = null; block.ImageUV = block.SetClipped(renderer.ClippingBoundary, screenRegion, renderer, RenderData.computedStyle.ZIndex, locatedAt, block.ImageUV); block.Done(renderer.Transform); } left += (character.AdvanceWidth) + LetterSpacing; if (character.Charcode == (int)' ') { left += WordSpacing; } }
/// <summary>Called when the parent element has started rendering its kids.</summary> public void Start(Renderman renderer) { // Push: NextInformer = renderer.FirstInformer; renderer.FirstInformer = this; if (OnStart != null) { OnStart(renderer, this); } }
public override bool Render(bool first, LayoutBox box, Renderman renderer) { if (first) { ClearBlocks(); } Layout(box, renderer); // Return true if we've got border-radius corners - that'll trigger a PostProcess event: return(Corners != null); }
/// <summary>Transforms all the blocks that this property has allocated. Note that transformations are a post process. /// Special case for borders as it may also internally transform its corners.</summary> /// <param name="topTransform">The transform that should be applied to this property.</param> public override void PostProcess(LayoutBox box, Renderman renderer) { if (Resets != null) { // Pop all of the counters: for (int i = 0; i < Resets.Count; i++) { // Pop it: renderer.PopCounter(Resets[i]); } } }
public override void Paint(LayoutBox box, Renderman renderer) { MeshBlock block = GetFirstBlock(renderer); if (block == null) { // This can happen if an animation is requesting that a now offscreen element gets painted only. return; } block.PaintColour(BaseColour * renderer.ColorOverlay); }
/// <summary>Transforms all the verts by the given delta matrix. Used during a Paint only.</summary> public virtual void ApplyTransform(Matrix4x4 delta, Renderman renderer) { // Get the first block: MeshBlock block = GetFirstBlock(renderer); for (int i = 0; i < BlockCount; i++) { // Transform the verts: block.TransformVertices(delta); // Seek to the next one: block.Next(); } }
public MeshBlock Add(Renderman renderer) { // Allocate the block: MeshBlock block = renderer.CurrentBatch.Mesh.Allocate(renderer); if (Batch == null) { Batch = renderer.CurrentBatch; FirstBlockIndex = block.Buffer.BlocksBefore + block.BlockIndex; } BlockCount++; return(block); }
public override void Paint(LayoutBox box, Renderman renderer) { Color colour = Colour * renderer.ColorOverlay; MeshBlock block = GetFirstBlock(renderer); // For each block.. for (int i = 0; i < BlockCount; i++) { // Paint the colour: block.PaintColour(colour); // Go to next block: block.Next(); } }
/// <summary>Gets the first rendered block of this property. Used during Paint passes.</summary> public MeshBlock GetFirstBlock(Renderman renderer) { if (Batch == null) { // Layout required. return(null); } // Use the shared block: MeshBlock block = renderer.Block; // Load into it now: block.SetBatchIndex(Batch, FirstBlockIndex); // Return it: return(block); }
public override void Paint(LayoutBox box, Renderman renderer) { // Any meshes in this elements queue should now change colour: Color colour = renderer.ColorOverlay; MeshBlock block = GetFirstBlock(renderer); // For each block.. for (int i = 0; i < BlockCount; i++) { // Paint the colour: block.PaintColour(colour); // Go to next block: block.Next(); } }
public override void Paint(LayoutBox box, Renderman renderer) { // Any meshes in my queue should now change colour: MeshBlock block = GetFirstBlock(renderer); if (BaseColour == null || BaseColour.Count == 1) { // Most common case. This is a single colour border. // Get the default colour - that's the same as the text colour: Color colour = Color.black; // Does this border have a colour? if (BaseColour == null) { // Grab the text colour if there is one: if (RenderData.Text != null) { // It's the same as the font colour: colour = RenderData.Text.BaseColour * renderer.ColorOverlay; } else { // Nope - We need to set alpha: colour.a = renderer.ColorOverlay.a; } } else { colour = BaseColour[0].GetColour(RenderData, Css.Properties.BorderColor.GlobalProperty) * renderer.ColorOverlay; } // For each block.. for (int i = 0; i < BlockCount; i++) { // Paint the colour: block.PaintColour(colour); // Go to next block: block.Next(); } return; } }
internal override void Layout(LayoutBox box, Renderman renderer) { // Get the top left inner corner (inside margin and border): float width = box.PaddedWidth; float height = box.PaddedHeight; float top = box.Y + box.Border.Top; float left = box.X + box.Border.Left; // Is it clipped? if (renderer.IsInvisible(left, top, width, height)) { // Totally not visible. return; } // Ensure we have a batch (doesn't change graphics or font thus both nulls): renderer.SetupBatch(this, null, null); // Get the transform: Transformation transform = renderer.Transform; for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { // Add it: MeshBlock block = Add(renderer); // Set the UV to that of the solid block colour pixel: block.SetSolidColourUV(); // Set the colour - here we set it unevenly to trigger gradients. // block.SetColour(BackingColour * renderer.ColorOverlay); // BoxRegion clipZone=new BoxRegion(left,top,width,height); // Set the verts too: // block.SetClipped(renderer.ClippingBoundary,clipZone,renderer,box.ZIndex-0.006f); block.Done(transform); } } }
public override void Paint(LayoutBox box, Renderman renderer) { // Does the given renderer belong to the worldUI? if (Renderer != null && renderer == Renderer.Renderer) { // Yes! We're actually drawing the element. Do nothing. return; } MeshBlock block = GetFirstBlock(renderer); if (block == null) { // This can happen if an animation is requesting that a now offscreen element gets painted only. return; } block.PaintColour(renderer.ColorOverlay); }
/// <summary>Draws an underline (or a strikethrough).</summary> public virtual void DrawUnderline(Renderman renderer) { // Ensure we have a batch: renderer.SetupBatch(this, null, null); // And get our block ready: MeshBlock block = Add(renderer); // Set the UV to that of the solid block colour pixel: block.SetSolidColourUV(); // Set the colour: block.SetColour(renderer.FontColour); // Set the verts: block.SetClipped(renderer.ClippingBoundary, renderer.CurrentRegion, renderer, renderer.TextDepth); // Ok! block.Done(renderer.Transform); }
public override void Paint(LayoutBox box, Renderman renderer) { // Resolve colour: BaseColour = RenderData.computedStyle.Resolve(Css.Properties.ColorProperty.GlobalProperty) .GetColour(RenderData, Css.Properties.ColorProperty.GlobalProperty); Color colour = BaseColour * renderer.ColorOverlay; MeshBlock block = GetFirstBlock(renderer); // For each block.. for (int i = 0; i < BlockCount; i++) { // Paint the colour: block.PaintColour(colour); // Go to next block: block.Next(); } }
internal override void Layout(LayoutBox box, Renderman renderer) { // Any to increment? if (Increments != null) { for (int i = 0; i < Increments.Count; i++) { // Increment it: renderer.IncrementCounter(Increments[i].Name, Increments[i].Count); } } // Any to 'reset'? if (Resets != null) { for (int i = 0; i < Resets.Count; i++) { // Reset it: renderer.ResetCounter(Resets[i]); } } }
public override void Paint(LayoutBox box, Renderman renderer) { Color fontColour = BaseColour * renderer.ColorOverlay; if (Mesh != null) { // Update it's verts to match the font colour. Mesh.PaintColours(fontColour, fontColour, fontColour); } if (Underline != null) { // Update it's verts to match the line colour. Color lineColour = fontColour; if (TextLine != null && TextLine.ColourOverride) { lineColour = TextLine.BaseColour * renderer.ColorOverlay; } Underline.PaintColours(lineColour, lineColour, lineColour); } }